Populate codec/ directory
[yangtools.git] / codec / yang-data-codec-binfmt / src / test / java / org / opendaylight / yangtools / yang / data / codec / binfmt / AidSerializationTest.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 com.google.common.collect.ImmutableSet;
11 import java.util.Arrays;
12 import org.junit.Assert;
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 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
19
20 @RunWith(Parameterized.class)
21 public class AidSerializationTest extends AbstractSerializationTest {
22     @Parameters(name = "{0}")
23     public static Iterable<Object[]> data() {
24         return Arrays.asList(
25             new Object[] { NormalizedNodeStreamVersion.LITHIUM,    8,  97, 530, 4162, 1_175_362, 2_158_407 },
26             new Object[] { NormalizedNodeStreamVersion.NEON_SR2,   9, 100, 421, 3145,   913_225,   913_231 },
27             new Object[] { NormalizedNodeStreamVersion.SODIUM_SR1, 4,  94, 332, 2376,   716_618,   912_975 },
28             new Object[] { NormalizedNodeStreamVersion.MAGNESIUM,  4,  94, 332, 2376,   716_618,   912_975 });
29     }
30
31     @Parameter(1)
32     public int emptySize;
33     @Parameter(2)
34     public int oneSize;
35     @Parameter(3)
36     public int size29;
37     @Parameter(4)
38     public int size256;
39     @Parameter(5)
40     public int size65536;
41     @Parameter(6)
42     public int twiceSize65536;
43
44     @Test
45     public void testEmptyIdentifier() {
46         assertSame(fillIdentifier(0), emptySize);
47     }
48
49     @Test
50     public void testOneIdentifier() {
51         assertEquals(fillIdentifier(1), oneSize);
52     }
53
54     @Test
55     public void test29() {
56         assertEquals(fillIdentifier(29), size29);
57     }
58
59     @Test
60     public void test256() {
61         assertEquals(fillIdentifier(256), size256);
62     }
63
64     @Test
65     public void test65536() {
66         final AugmentationIdentifier id = fillIdentifier(65536);
67         assertEquals(id, size65536);
68         assertEqualsTwice(id, twiceSize65536);
69     }
70
71     private static AugmentationIdentifier fillIdentifier(final int size) {
72         final AugmentationIdentifier ret = AugmentationIdentifier.create(ImmutableSet.copyOf(generateQNames(size)));
73         Assert.assertEquals(size, ret.getPossibleChildNames().size());
74         return ret;
75     }
76 }