Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test case that exposes the regression introduced with #82 #83

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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