Skip to content

Commit

Permalink
m-m-m/base#8: cover bugfix in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Dec 25, 2024
1 parent 5a59ad9 commit 987a27b
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,56 @@ public void testReadUntilWithSyntaxAltDobuleQuotesLazy() {
check('x', true, syntax, "\"\"a\"\"\"\"b\"\"\"c\"dx", "\"a\"\"b\"cd");
}

/**
* Test of {@link CharStreamScanner#readUntil(CharFilter, boolean)} reading until stop char was hit.
*/
@Test
public void testReadUntilWithCharFilter() {

// arrange
String string = " blabla_$";
CharStreamScanner scanner;
scanner = scanner(string);
// act
String result = scanner.readUntil(cp -> cp == '$', true);
// assert
assertThat(result).isEqualTo(" blabla_");
}

/**
* Test of {@link CharStreamScanner#readUntil(CharFilter, boolean)} reading until EOT if no stop char was hit but
* {@code acceptEnd} was {@code true}.
*/
@Test
public void testReadUntilWithCharFilterEot() {

// arrange
String string = " blabla_$";
CharStreamScanner scanner;
scanner = scanner(string);
// act
String result = scanner.readUntil(CharFilter.NEWLINE, true);
// assert
assertThat(result).isEqualTo(string);
}

/**
* Test of {@link CharStreamScanner#readUntil(CharFilter, boolean)} returning {@code null} if no stop char was hit but
* {@code acceptEnd} was {@code false}.
*/
@Test
public void testReadUntilWithCharFilterNoEot() {

// arrange
String string = " blabla_$";
CharStreamScanner scanner;
scanner = scanner(string);
// act
String result = scanner.readUntil(CharFilter.NEWLINE, false);
// assert
assertThat(result).isNull();
}

/**
* Test of {@link CharStreamScanner#readUntil(CharFilter, boolean, String, boolean ignoreCase, boolean)} with buffer
* limit overflow.
Expand Down

0 comments on commit 987a27b

Please sign in to comment.