Skip to content

Commit

Permalink
Add a test case that exposes the regression introduced with tomasbjer…
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 6, 2020
1 parent 2b96ad7 commit 5ded780
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/se/bjurr/violations/lib/CPPCheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import static se.bjurr.violations.lib.model.Violation.violationBuilder;
import static se.bjurr.violations.lib.reports.Parser.CPPCHECK;

import java.io.*;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.Test;

import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.parsers.CPPCheckParser;
import se.bjurr.violations.lib.reports.Parser;

public class CPPCheckTest {
Expand Down Expand Up @@ -155,6 +158,24 @@ public void testThatViolationsCanBeParsedWhenErrorTagHasNoEndtag() {
.startsWith("The scope of the variable");
}

@Test
public void testThatViolationsCanBeParse() throws Exception {
List<Violation> violations = new CPPCheckParser().parseReportOutput(
getResourceFileAsString("results-version-2.xml"));

assertThat(violations).hasSize(4);
}

static String getResourceFileAsString(String fileName) throws IOException {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
try (InputStream is = classLoader.getResourceAsStream(fileName)) {
if (is == null) return null;
try (InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr)) {
return reader.lines().collect(Collectors.joining(System.lineSeparator()));
}
}
}
@Test
public void testThatViolationsCanBeParsedWithVersion2() {
final String rootFolder = getRootFolder();
Expand Down

0 comments on commit 5ded780

Please sign in to comment.