Move yang-common(-netty)
[yangtools.git] / codec / yang-data-codec-binfmt / src / test / java / org / opendaylight / yangtools / yang / data / codec / binfmt / StringSerializationTest.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.codec.binfmt;
9
10 import static org.junit.Assume.assumeTrue;
11
12 import java.util.Arrays;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.junit.runners.Parameterized;
16 import org.junit.runners.Parameterized.Parameter;
17 import org.junit.runners.Parameterized.Parameters;
18
19 @RunWith(Parameterized.class)
20 public class StringSerializationTest extends AbstractSerializationTest {
21     private static final String STR_MEDIUM = "a".repeat(32767);
22     private static final String STR_HUGE = "©".repeat(16777216);
23
24     @Parameters(name = "{0}")
25     public static Iterable<Object[]> data() {
26         return Arrays.asList(
27             new Object[] { NormalizedNodeStreamVersion.LITHIUM,     98,  99, 32867, 33554532 },
28             new Object[] { NormalizedNodeStreamVersion.NEON_SR2,   100, 101, 32869, 33554534 },
29             new Object[] { NormalizedNodeStreamVersion.SODIUM_SR1,  96,  99, 32865, 33554532 },
30             new Object[] { NormalizedNodeStreamVersion.MAGNESIUM,   96,  99, 32865, 33554532 });
31     }
32
33     @Parameter(1)
34     public int emptySize;
35     @Parameter(2)
36     public int oneSize;
37     @Parameter(3)
38     public int mediumSize;
39     @Parameter(4)
40     public int hugeSize;
41
42     @Test
43     public void testEmptyString() {
44         assertEquals("", emptySize);
45     }
46
47     @Test
48     public void testEmptySame() {
49         assumeTrue(version.compareTo(NormalizedNodeStreamVersion.SODIUM_SR1) >= 0);
50         assertSame("", emptySize);
51     }
52
53     @Test
54     public void testOne() {
55         assertEquals("a", oneSize);
56     }
57
58     @Test
59     public void testMedium() {
60         assertEquals(STR_MEDIUM, mediumSize);
61     }
62
63     @Test
64     public void testHuge() {
65         assertEquals(STR_HUGE, hugeSize);
66     }
67 }