Skip to content

Commit

Permalink
splitting the parsing tests in more separate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Aug 26, 2015
1 parent 2640f94 commit a18d58e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Expand Up @@ -53,15 +53,16 @@ private void parse(String fileName) throws IOException, ParseException {
assertEquals(0, sourceFileInfoExtractor.getKo());
assertEquals(0, sourceFileInfoExtractor.getUnsupported());

File dstFile = new File("src/test/resources/javaparser_expected_output/" + fileName.replaceAll("/", "_")+ ".txt");
String path = "src/test/resources/javaparser_expected_output/" + fileName.replaceAll("/", "_")+ ".txt";
File dstFile = new File(path);

String expected = readFile(dstFile);

String[] outputLines = output.split("\n");
String[] expectedLines = expected.split("\n");

for (int i=0; i<Math.min(outputLines.length, expectedLines.length); i++) {
assertEquals(expectedLines[i], outputLines[i]);
assertEquals("Line " + (i+1) + " of " + path + " is different from what is expected", expectedLines[i], outputLines[i]);
}

assertEquals(expectedLines.length, outputLines.length);
Expand All @@ -83,9 +84,17 @@ public void parseJavaParser() throws IOException, ParseException {
}

@Test
public void parseStatements() throws IOException, ParseException {
public void parseStatement() throws IOException, ParseException {
parse("com/github/javaparser/ast/stmt/Statement");
}

@Test
public void parseCatchClaus() throws IOException, ParseException {
parse("com/github/javaparser/ast/stmt/CatchClause");
}

@Test
public void parseStatements() throws IOException, ParseException {
parse("com/github/javaparser/ast/stmt/LabeledStmt");
parse("com/github/javaparser/ast/stmt/BreakStmt");
parse("com/github/javaparser/ast/stmt/ReturnStmt");
Expand Down Expand Up @@ -173,6 +182,21 @@ public void parseVisitors() throws IOException, ParseException {
parse("com/github/javaparser/ast/visitor/GenericVisitorAdapter");
}

@Test
public void parseSourcesHelper() throws IOException, ParseException {
parse("com/github/javaparser/SourcesHelper");
}

@Test
public void parseComments() throws IOException, ParseException {
parse("com/github/javaparser/ast/comments/LineComment");
parse("com/github/javaparser/ast/comments/Comment");
parse("com/github/javaparser/ast/comments/CommentsParser");
parse("com/github/javaparser/ast/comments/JavadocComment");
parse("com/github/javaparser/ast/comments/BlockComment");
parse("com/github/javaparser/ast/comments/CommentsCollection");
}

@Test
public void parseTheRest() throws IOException, ParseException {
parse("com/github/javaparser/ast/internal/Utils");
Expand Down Expand Up @@ -206,15 +230,7 @@ public void parseTheRest() throws IOException, ParseException {
parse("com/github/javaparser/ast/CompilationUnit");
parse("com/github/javaparser/ast/TypeParameter");
parse("com/github/javaparser/ast/ImportDeclaration");
parse("com/github/javaparser/ast/comments/LineComment");
parse("com/github/javaparser/ast/comments/Comment");
// TODO fix this one
// parse("com/github/javaparser/ast/comments/CommentsParser");
parse("com/github/javaparser/ast/comments/JavadocComment");
parse("com/github/javaparser/ast/comments/BlockComment");
parse("com/github/javaparser/ast/comments/CommentsCollection");
parse("com/github/javaparser/Position");
parse("com/github/javaparser/SourcesHelper");
parse("com/github/javaparser/ASTHelper");
}

Expand Down
Expand Up @@ -8,7 +8,7 @@
Line 33) s.hasNext() ? s.next() : "" ==> java.lang.String
Line 38) java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A") ==> java.util.Scanner
Line 38) new java.util.Scanner(in).useDelimiter("\\A") ==> java.util.Scanner
Line 39) s.hasNext() ? s.next() : "" ==> java.lang.Object
Line 39) s.hasNext() ? s.next() : "" ==> java.lang.String
Line 43) byte[] rawData = encoding != null ? s.getBytes(encoding) : s.getBytes() ==> byte[]
Line 43) encoding != null ? s.getBytes(encoding) : s.getBytes() ==> byte[]
Line 44) new ByteArrayInputStream(rawData) ==> java.io.ByteArrayInputStream
Expand Down

0 comments on commit a18d58e

Please sign in to comment.