mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-18 05:23:59 +00:00
Update Strman.java (#97)
* Update Strman.java fix bug in between() * Update StrmanTests.java * Update StrmanTests.java
This commit is contained in:
@@ -115,7 +115,9 @@ public abstract class Strman {
|
||||
validate(end, NULL_STRING_PREDICATE, () -> "'end' should be not null.");
|
||||
|
||||
String[] parts = value.split(end);
|
||||
return Arrays.stream(parts).map(subPart -> subPart.substring(subPart.indexOf(start) + start.length()))
|
||||
return Arrays.stream(parts)
|
||||
.filter(subPart -> subPart.contains(start))
|
||||
.map(subPart -> subPart.substring(subPart.indexOf(start) + start.length()))
|
||||
.toArray(String[]::new);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,9 +92,9 @@ public class StrmanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void between_shouldReturnFullStringWhenStartAndEndDoesNotExist() throws Exception {
|
||||
assertThat(between("[abc][def]", "{", "}"), arrayContaining("[abc][def]"));
|
||||
assertThat(between("", "{", "}"), arrayContaining(""));
|
||||
public void between_shouldReturnEmptyArrayWhenStartAndEndDoesNotExist() throws Exception {
|
||||
assertThat(between("[abc][def]", "{", "}").length, equalTo(0));
|
||||
assertThat(between("", "{", "}").length, equalTo(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user