Search in sources :

Example 1 with CStringStorage

use of org.eclipse.linuxtools.changelog.tests.fixtures.CStringStorage in project linuxtools by eclipse.

the class CParserTest method canParseCurrentFunctionFromCStringInIStorageEditorInput.

/**
 * Given an IStorageEditorInput we should be able to retrieve the currently
 * active C function.
 *
 * @throws Exception
 */
@Test
public void canParseCurrentFunctionFromCStringInIStorageEditorInput() throws Exception {
    final String expectedFunctionName = "doSomething";
    final String cSourceCode = "static int " + expectedFunctionName + "(char *test)\n" + "{\n" + "int index = 0;\n" + "// " + OFFSET_MARKER + "\n" + "return 0;\n" + "}\n";
    // prepare IStorageEditorInput
    IStorage cStringStorage = new CStringStorage(cSourceCode);
    IStorageEditorInput cStringStorageEditorInput = new CStringStorageInput(cStringStorage);
    // Figure out the desired offset
    int selectOffset = cSourceCode.indexOf(OFFSET_MARKER);
    assertTrue(selectOffset >= 0);
    final String actualFunctionName = cParser.parseCurrentFunction(cStringStorageEditorInput, selectOffset);
    assertEquals(expectedFunctionName, actualFunctionName);
}
Also used : CStringStorage(org.eclipse.linuxtools.changelog.tests.fixtures.CStringStorage) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) CStringStorageInput(org.eclipse.linuxtools.changelog.tests.fixtures.CStringStorageInput) IStorage(org.eclipse.core.resources.IStorage) Test(org.junit.Test)

Aggregations

IStorage (org.eclipse.core.resources.IStorage)1 CStringStorage (org.eclipse.linuxtools.changelog.tests.fixtures.CStringStorage)1 CStringStorageInput (org.eclipse.linuxtools.changelog.tests.fixtures.CStringStorageInput)1 IStorageEditorInput (org.eclipse.ui.IStorageEditorInput)1 Test (org.junit.Test)1