Skip to content

Commit

Permalink
Testing cpplint variant #35
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Apr 13, 2018
1 parent c36c7bd commit 8455fc5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/test/java/se/bjurr/violations/lib/CppLintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,9 +15,9 @@ public class CppLintTest {

@Test
public void testThatViolationsCanBeParsed() {
String rootFolder = getRootFolder();
final String rootFolder = getRootFolder();

List<Violation> actual =
final List<Violation> actual =
violationsApi() //
.withPattern(".*/cpplint/.*\\.txt$") //
.inFolder(rootFolder) //
Expand Down Expand Up @@ -53,4 +54,33 @@ public void testThatViolationsCanBeParsed() {
assertThat(actual.get(2).getEndLine()) //
.isEqualTo(11);
}

@Test
public void testThatViolationsCanBeParsed2() {
final String rootFolder = getRootFolder();

final List<Violation> 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<uint8_t *>(...) 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);
}
}
2 changes: 2 additions & 0 deletions src/test/resources/cpplint/cpplint-result.xml
Original file line number Diff line number Diff line change
@@ -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<uint8_t *>(...) instead [readability/casting] [4]

0 comments on commit 8455fc5

Please sign in to comment.