diff --git a/src/test/java/se/bjurr/violations/lib/CppLintTest.java b/src/test/java/se/bjurr/violations/lib/CppLintTest.java index bfd83fa6..7b0b0a5e 100644 --- a/src/test/java/se/bjurr/violations/lib/CppLintTest.java +++ b/src/test/java/se/bjurr/violations/lib/CppLintTest.java @@ -4,6 +4,7 @@ import static se.bjurr.violations.lib.TestUtils.getRootFolder; import static se.bjurr.violations.lib.ViolationsApi.violationsApi; import static se.bjurr.violations.lib.model.SEVERITY.ERROR; +import static se.bjurr.violations.lib.model.SEVERITY.WARN; import static se.bjurr.violations.lib.reports.Parser.CPPLINT; import java.util.List; @@ -14,9 +15,9 @@ public class CppLintTest { @Test public void testThatViolationsCanBeParsed() { - String rootFolder = getRootFolder(); + final String rootFolder = getRootFolder(); - List actual = + final List actual = violationsApi() // .withPattern(".*/cpplint/.*\\.txt$") // .inFolder(rootFolder) // @@ -53,4 +54,33 @@ public void testThatViolationsCanBeParsed() { assertThat(actual.get(2).getEndLine()) // .isEqualTo(11); } + + @Test + public void testThatViolationsCanBeParsed2() { + final String rootFolder = getRootFolder(); + + final List actual = + violationsApi() // + .withPattern(".*cpplint-result\\.xml$") // + .inFolder(rootFolder) // + .findAll(CPPLINT) // + .violations(); + + assertThat(actual) // + .hasSize(1); + + final Violation violation = actual.get(0); + assertThat(violation.getMessage()) // + .isEqualTo("Using C-style cast. Use reinterpret_cast(...) instead"); + assertThat(violation.getFile()) // + .isEqualTo("pump/src/hal/stm32f4xx/devices/spi/spi_unit0_com.c"); + assertThat(violation.getSeverity()) // + .isEqualTo(WARN); + assertThat(violation.getRule().get()) // + .isEqualTo("readability/casting"); + assertThat(violation.getStartLine()) // + .isEqualTo(737); + assertThat(violation.getEndLine()) // + .isEqualTo(737); + } } diff --git a/src/test/resources/cpplint/cpplint-result.xml b/src/test/resources/cpplint/cpplint-result.xml new file mode 100644 index 00000000..52b50b88 --- /dev/null +++ b/src/test/resources/cpplint/cpplint-result.xml @@ -0,0 +1,2 @@ +Done processing pump/src/gui/controls/TextValueHolder.cpp +pump/src/hal/stm32f4xx/devices/spi/spi_unit0_com.c:737: Using C-style cast. Use reinterpret_cast(...) instead [readability/casting] [4]