Do not pretty-print body class
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / codec / Uint64CodecStringTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.impl.codec;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.yangtools.yang.common.Uint64;
14 import org.opendaylight.yangtools.yang.data.api.codec.Uint64Codec;
15 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
16
17 /**
18  * Unit tests for Uint64CodecString.
19  *
20  * @author Thomas Pantelis
21  */
22 public class Uint64CodecStringTest {
23     @SuppressWarnings("unchecked")
24     @Test
25     public void testSerialize() {
26         Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
27             Uint64Codec.class);
28         assertEquals("123456789", codec.serialize(Uint64.valueOf(123456789)));
29     }
30
31     @SuppressWarnings("unchecked")
32     @Test
33     public void testDeserialize() {
34         final String hexa = "0X75EDC78edCBA";
35         final String octal = "03536670743556272";
36         final String integer = "129664115727546";
37
38         Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
39             Uint64Codec.class);
40
41         assertEquals(Uint64.valueOf("75EDC78edCBA", 16), codec.deserialize(hexa));
42         assertEquals(Uint64.valueOf(octal, 8), codec.deserialize(octal));
43         assertEquals(Uint64.valueOf(integer, 10), codec.deserialize(integer));
44
45         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "12345o");
46         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "");
47     }
48 }