2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.codec.binfmt;
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;
20 @RunWith(Parameterized.class)
21 public class AidSerializationTest extends AbstractSerializationTest {
22 @Parameters(name = "{0}")
23 public static Iterable<Object[]> data() {
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 });
42 public int twiceSize65536;
45 public void testEmptyIdentifier() {
46 assertSame(fillIdentifier(0), emptySize);
50 public void testOneIdentifier() {
51 assertEquals(fillIdentifier(1), oneSize);
55 public void test29() {
56 assertEquals(fillIdentifier(29), size29);
60 public void test256() {
61 assertEquals(fillIdentifier(256), size256);
65 public void test65536() {
66 final AugmentationIdentifier id = fillIdentifier(65536);
67 assertEquals(id, size65536);
68 assertEqualsTwice(id, twiceSize65536);
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());