@Test public void testGetDefinitions() throws Exception { // Test that we can get definitions for one of the files in the // repository. File f1 = new File(repository.getSourceRoot() + "/c/foobar.c"); Definitions defs1 = IndexDatabase.getDefinitions(f1); assertNotNull(defs1); assertTrue(defs1.hasSymbol("foobar")); assertTrue(defs1.hasSymbol("a")); assertFalse(defs1.hasSymbol("b")); assertTrue(defs1.hasDefinitionAt("foobar", 1, new String[1])); // same for windows delimiters f1 = new File(repository.getSourceRoot() + "\\c\\foobar.c"); defs1 = IndexDatabase.getDefinitions(f1); assertNotNull(defs1); assertTrue(defs1.hasSymbol("foobar")); assertTrue(defs1.hasSymbol("a")); assertFalse(defs1.hasSymbol("b")); assertTrue(defs1.hasDefinitionAt("foobar", 1, new String[1])); // Test that we get null back if we request definitions for a file // that's not in the repository. File f2 = new File(repository.getSourceRoot() + "/c/foobar.d"); Definitions defs2 = IndexDatabase.getDefinitions(f2); assertNull(defs2); }
@BeforeClass public static void setUpClass() throws Exception { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); assertTrue("No ctags available", env.validateExuberantCtags()); repository = new TestRepository(); repository.create(IndexDatabase.class.getResourceAsStream("source.zip")); env.setSourceRoot(repository.getSourceRoot()); env.setDataRoot(repository.getDataRoot()); Indexer indexer = Indexer.getInstance(); indexer.prepareIndexer( env, true, true, "/c", null, false, false, false, null, null, new ArrayList<String>(), false); indexer.doIndexerExecution(true, 1, null, null); }