use of org.opensolaris.opengrok.analysis.c.CXref in project OpenGrok by OpenGrok.
the class JFlexXrefTest method testUnterminatedElements.
/**
* Unterminated string literals or comments made CXref produce output
* that was not valid XML, due to missing end tags. Test that it is no
* longer so.
*/
@Test
public void testUnterminatedElements() throws Exception {
for (String str : Arrays.asList("#define STR \"abc\n", "void f(); /* unterminated comment\n", "const char c = 'x\n")) {
StringReader in = new StringReader(str);
CXref xref = new CXref(in);
StringWriter out = new StringWriter();
xref.write(out);
// Used to throw SAXParseException.
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader("<doc>" + out + "</doc>")));
}
}
use of org.opensolaris.opengrok.analysis.c.CXref in project OpenGrok by OpenGrok.
the class JFlexXrefTest method testBug15890LineCount.
/**
* Regression test case for bug #15890. Check that we get the expected the
* expected line count from input with some special characters that used
* to cause trouble.
*/
@Test
public void testBug15890LineCount() throws Exception {
String fileContents = "line 1\n" + "line 2\n" + "line 3\n" + "line 4 with char\n" + "line 5 with char\n" + "line 6 with
char\n" + "line 7 with
char\n" + "line 8 with
char\n" + "line 9\n";
bug15890LineCount(new CXref(new StringReader(fileContents)));
bug15890LineCount(new CxxXref(new StringReader(fileContents)));
bug15890LineCount(new LispXref(new StringReader(fileContents)));
bug15890LineCount(new JavaXref(new StringReader(fileContents)));
bug15890LineCount(new ScalaXref(new StringReader(fileContents)));
bug15890LineCount(new FortranXref(new StringReader(fileContents)));
bug15890LineCount(new HaskellXref(new StringReader(fileContents)));
bug15890LineCount(new XMLXref(new StringReader(fileContents)));
bug15890LineCount(new ShXref(new StringReader(fileContents)));
bug15890LineCount(new TclXref(new StringReader(fileContents)));
bug15890LineCount(new SQLXref(new StringReader(fileContents)));
bug15890LineCount(new TroffXref(new StringReader(fileContents)));
bug15890LineCount(new PlainXref(new StringReader(fileContents)));
bug15890LineCount(new PerlXref(new StringReader(fileContents)));
}
use of org.opensolaris.opengrok.analysis.c.CXref in project OpenGrok by OpenGrok.
the class JFlexXrefTest method testJFlexRule.
/**
* Test that JFlex rules that contain quotes don't cause invalid xref
* to be produced.
*/
@Test
public void testJFlexRule() throws Exception {
StringReader in = new StringReader("\\\" { yybegin(STRING); }");
// JFlex files are usually analyzed with CAnalyzer.
CXref xref = new CXref(in);
StringWriter out = new StringWriter();
xref.write(out);
// Verify that the xref is well-formed XML. Used to throw
// SAXParseException: The element type "span" must be terminated
// by the matching end-tag "</span>".
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader("<doc>" + out + "</doc>")));
}
Aggregations