Skip to content

Commit

Permalink
CxxCognitiveComplexityVisitorTest: clean-up
Browse files Browse the repository at this point in the history
* minor findings while looking at SonarOpenCommunity#1494
* test doesn show the actual values because of a wrong written assertion
  • Loading branch information
ivangalkin committed Jun 21, 2018
1 parent c30efb3 commit b42a9ad
Showing 1 changed file with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,111 +45,112 @@ private int testFile(String fileName) throws UnsupportedEncodingException, IOExc

@Test
public void if_statement() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/if.cc") == 1).isTrue();

assertThat(testFile("src/test/resources/visitors/if.cc")).isEqualTo(1);
}

@Test
public void if_else() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/if_else.cc") == 2).isTrue();
assertThat(testFile("src/test/resources/visitors/if_else.cc")).isEqualTo(2);
}

@Test
public void if_else_if() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/if_else_if.cc") == 2).isTrue();
assertThat(testFile("src/test/resources/visitors/if_else_if.cc")).isEqualTo(2);
}

@Test
public void if_else_if_else() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/if_else_if_else.cc") == 3).isTrue();
assertThat(testFile("src/test/resources/visitors/if_else_if_else.cc")).isEqualTo(3);
}

@Test
public void ternary() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/ternary.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/ternary.cc")).isEqualTo(1);
}

@Test
public void nesting() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/nesting.cc") == 20).isTrue();
assertThat(testFile("src/test/resources/visitors/nesting.cc")).isEqualTo(20);
}

@Test
public void switch_statement() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/switch.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/switch.cc")).isEqualTo(1);
}

@Test
public void for_statement() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/for.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/for.cc")).isEqualTo(1);
}

@Test
public void while_statement() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/while.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/while.cc")).isEqualTo(1);
}

@Test
public void do_while() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/do_while.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/do_while.cc")).isEqualTo(1);
}

@Test
public void catch_statement() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/catch.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/catch.cc")).isEqualTo(1);
}

@Test
public void multiple_catch() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/multiple_catch.cc") == 3).isTrue();
assertThat(testFile("src/test/resources/visitors/multiple_catch.cc")).isEqualTo(3);
}

@Test
public void goto_statement() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/goto.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/goto.cc")).isEqualTo(1);
}

@Test
public void binary_logical() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/binary_logical.cc") == 2).isTrue();
assertThat(testFile("src/test/resources/visitors/binary_logical.cc")).isEqualTo(2);
}

@Test
public void binary_logical_mixed() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/binary_logical_mixed.cc") == 4).isTrue();
assertThat(testFile("src/test/resources/visitors/binary_logical_mixed.cc")).isEqualTo(4);
}

@Test
public void binary_logical_not() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/binary_logical_not.cc") == 3).isTrue();
assertThat(testFile("src/test/resources/visitors/binary_logical_not.cc")).isEqualTo(3);
}

@Test
public void lambda() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/lambda.cc") == 2).isTrue();
assertThat(testFile("src/test/resources/visitors/lambda.cc")).isEqualTo(2);
}

@Test
public void sum_of_primes() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/sum_of_primes.cc") == 7).isTrue();
assertThat(testFile("src/test/resources/visitors/sum_of_primes.cc")).isEqualTo(7);
}

@Test
public void get_words() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/get_words.cc") == 1).isTrue();
assertThat(testFile("src/test/resources/visitors/get_words.cc")).isEqualTo(1);
}

@Test
public void overridden_symbol_from() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/overridden_symbol_from.cc") == 19).isTrue();
assertThat(testFile("src/test/resources/visitors/overridden_symbol_from.cc")).isEqualTo(19);
}

@Test
public void add_version() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/add_version.cc") == 35).isTrue();
assertThat(testFile("src/test/resources/visitors/add_version.cc")).isEqualTo(35);
}

@Test
public void to_regexp() throws UnsupportedEncodingException, IOException {
assertThat(testFile("src/test/resources/visitors/to_regexp.cc") == 20).isTrue();
assertThat(testFile("src/test/resources/visitors/to_regexp.cc")).isEqualTo(20);
}
}

0 comments on commit b42a9ad

Please sign in to comment.