Skip to content

Commit

Permalink
Adding a bogus test to check SonarQube on loops
Browse files Browse the repository at this point in the history
DeepSource (correctly) complained about our use of raw `for` loops, where SonarQube has remained silent on this. I've added a bogus test that uses a (new) raw `for` loop to see if that causes SonarQube to say something.
  • Loading branch information
NicMcPhee committed Jan 12, 2024
1 parent a9a7607 commit 853da52
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/test/java/hellos/HellosTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,27 @@ void setUp() {
lines = output.split("\n");
}

@Test
void sillyTest() {
int numLines = 0;

for (int i = 0; i < lines.length; ++i) {
++numLines;
}

assertEquals(lines.length, numLines, "Number of lines in output doesn't match");
}

@Test
void testLineStructure() {
// This regex supports unicode letters spaces, apostrophes, and hyphens
// Taken from
// https://stackoverflow.com/questions/15805555/java-regex-to-validate-full-name-allow-only-spaces-and-letters
// The pattern needs to include
// - some name,
// - the "says",
// - and the single quotes, and
// - they must speak with emphasis as noted by the required "!"
// - some name,
// - the "says",
// - and the single quotes, and
// - they must speak with emphasis as noted by the required "!"
String linePattern = "[\\p{L} .'-]+ says '+[\\p{L} .'-]+!'";

for (int i = 0; i < lines.length; ++i) {
Expand Down

0 comments on commit 853da52

Please sign in to comment.