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.Collections;
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() {
24 return Collections.singletonList(
25 new Object[] { NormalizedNodeStreamVersion.MAGNESIUM, 4, 94, 332, 2_376, 716_618, 912_975 });
39 public int twiceSize65536;
42 public void testEmptyIdentifier() {
43 assertSame(fillIdentifier(0), emptySize);
47 public void testOneIdentifier() {
48 assertEquals(fillIdentifier(1), oneSize);
52 public void test29() {
53 assertEquals(fillIdentifier(29), size29);
57 public void test256() {
58 assertEquals(fillIdentifier(256), size256);
62 public void test65536() {
63 final AugmentationIdentifier id = fillIdentifier(65536);
64 assertEquals(id, size65536);
65 assertEqualsTwice(id, twiceSize65536);
68 private static AugmentationIdentifier fillIdentifier(final int size) {
69 final AugmentationIdentifier ret = AugmentationIdentifier.create(ImmutableSet.copyOf(generateQNames(size)));
70 Assert.assertEquals(size, ret.getPossibleChildNames().size());