1024N/A/*
1024N/A * CDDL HEADER START
1024N/A *
1024N/A * The contents of this file are subject to the terms of the
1024N/A * Common Development and Distribution License (the "License").
1024N/A * You may not use this file except in compliance with the License.
1024N/A *
1024N/A * See LICENSE.txt included in this distribution for the specific
1024N/A * language governing permissions and limitations under the License.
1024N/A *
1024N/A * When distributing Covered Code, include this CDDL HEADER in each
1024N/A * file and include the License file at LICENSE.txt.
1024N/A * If applicable, add the following below this CDDL HEADER, with the
1024N/A * fields enclosed by brackets "[]" replaced with your own identifying
1024N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1024N/A *
1024N/A * CDDL HEADER END
1024N/A */
1024N/A
1024N/A/*
1024N/A * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
1024N/A * Use is subject to license terms.
1024N/A */
1024N/A
524N/Apackage org.opensolaris.opengrok.analysis;
524N/A
524N/Aimport java.util.Set;
524N/Aimport org.junit.After;
524N/Aimport org.junit.AfterClass;
524N/Aimport org.junit.Before;
524N/Aimport org.junit.BeforeClass;
524N/Aimport org.junit.Test;
524N/Aimport static org.junit.Assert.*;
524N/A
524N/A/**
524N/A *
524N/A * @author austvik
524N/A */
524N/Apublic class DefinitionsTest {
524N/A
524N/A public DefinitionsTest() {
524N/A }
524N/A
524N/A @BeforeClass
524N/A public static void setUpClass() throws Exception {
524N/A }
524N/A
524N/A @AfterClass
524N/A public static void tearDownClass() throws Exception {
524N/A }
524N/A
524N/A @Before
524N/A public void setUp() {
524N/A }
524N/A
524N/A @After
524N/A public void tearDown() {
524N/A }
524N/A
524N/A /**
524N/A * Test of getSymbols method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void getSymbols() {
524N/A Definitions instance = new Definitions();
524N/A Set<String> result = instance.getSymbols();
524N/A assertNotNull(result);
524N/A assertEquals(result.size(), 0);
524N/A instance.addTag(1, "found", "", "");
524N/A result = instance.getSymbols();
524N/A assertNotNull(result);
524N/A assertEquals(result.size(), 1);
524N/A }
524N/A
524N/A /**
524N/A * Test of hasSymbol method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void hasSymbol() {
524N/A Definitions instance = new Definitions();
524N/A instance.addTag(1, "found", "", "");
524N/A assertEquals(instance.hasSymbol("notFound"), false);
524N/A assertEquals(instance.hasSymbol("found"), true);
524N/A }
524N/A
524N/A /**
524N/A * Test of hasDefinitionAt method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void hasDefinitionAt() {
524N/A Definitions instance = new Definitions();
1108N/A String[] type= new String[1];
1108N/A type[0]="";
524N/A instance.addTag(1, "found", "", "");
1108N/A assertEquals(instance.hasDefinitionAt("found", 0, type), false);
1108N/A assertEquals(instance.hasDefinitionAt("found", 1, type), true);
1108N/A assertEquals(instance.hasDefinitionAt("found", 2, type), false);
1108N/A assertEquals(instance.hasDefinitionAt("notFound", 0, type), false);
1108N/A assertEquals(instance.hasDefinitionAt("notFound", 1, type), false);
524N/A }
524N/A
524N/A /**
524N/A * Test of occurrences method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void occurrences() {
524N/A Definitions instance = new Definitions();
524N/A instance.addTag(1, "one", "", "");
524N/A instance.addTag(1, "two", "", "");
524N/A instance.addTag(3, "two", "", "");
524N/A assertEquals(instance.occurrences("one"), 1);
524N/A assertEquals(instance.occurrences("two"), 2);
524N/A assertEquals(instance.occurrences("notFound"), 0);
524N/A }
524N/A
524N/A /**
524N/A * Test of numberOfSymbols method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void numberOfSymbols() {
524N/A Definitions instance = new Definitions();
524N/A assertEquals(instance.numberOfSymbols(), 0);
524N/A instance.addTag(1, "one", "", "");
524N/A assertEquals(instance.numberOfSymbols(), 1);
524N/A instance.addTag(1, "two", "", "");
524N/A instance.addTag(3, "two", "", "");
524N/A assertEquals(instance.numberOfSymbols(), 2);
524N/A }
524N/A
524N/A /**
524N/A * Test of getTags method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void getTags() {
524N/A Definitions instance = new Definitions();
524N/A assertEquals(instance.getTags().size(), 0);
524N/A instance.addTag(1, "one", "", "");
524N/A assertEquals(instance.getTags().size(), 1);
524N/A instance.addTag(1, "two", "", "");
524N/A assertEquals(instance.getTags().size(), 2);
524N/A instance.addTag(3, "two", "", "");
524N/A assertEquals(instance.getTags().size(), 3);
524N/A }
524N/A
524N/A /**
524N/A * Test of addTag method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void addTag() {
524N/A Definitions instance = new Definitions();
524N/A assertEquals(instance.getTags().size(), 0);
524N/A instance.addTag(1, "one", "", "");
524N/A assertEquals(instance.getTags().size(), 1);
524N/A }
524N/A
524N/A /**
524N/A * Test of serialize method, of class Definitions.
524N/A */
524N/A @Test
524N/A public void serialize() throws Exception {
524N/A Definitions instance = new Definitions();
524N/A instance.addTag(1, "one", "", "");
524N/A byte serial[] = instance.serialize();
524N/A Definitions instance2 = Definitions.deserialize(serial);
524N/A assertEquals(instance.getTags().size(), instance2.getTags().size());
524N/A assertEquals(instance.getSymbols().size(), instance2.getSymbols().size());
524N/A }
524N/A
524N/A
1024N/A}