Skip to content

Commit d284802

Browse files
committed
Remove Match#startsWith(), endsWith(). Don't seem to add a lot of value.
1 parent 620159c commit d284802

File tree

2 files changed

+0
-127
lines changed

2 files changed

+0
-127
lines changed

mug/src/main/java/com/google/mu/util/Substring.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,26 +2006,6 @@ public String remove() {
20062006
}
20072007
}
20082008

2009-
/**
2010-
* Returns true if this match starts with {@code prefix}.
2011-
*
2012-
* @since 6.1
2013-
*/
2014-
public boolean startsWith(String prefix) {
2015-
return prefix.length() <= length()
2016-
&& context.regionMatches(startIndex, prefix, 0, prefix.length());
2017-
}
2018-
2019-
/**
2020-
* Returns true if this match ends with {@code suffix}.
2021-
*
2022-
* @since 6.1
2023-
*/
2024-
public boolean endsWith(String suffix) {
2025-
return suffix.length() <= length()
2026-
&& context.regionMatches(startIndex + (length() - suffix.length()), suffix, 0, suffix.length());
2027-
}
2028-
20292009
/**
20302010
* Returns a copy of the original string with the matched substring replaced with {@code
20312011
* replacement}.

mug/src/test/java/com/google/mu/util/SubstringTest.java

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,113 +2048,6 @@ public void skipFromEnd_toString() {
20482048
assertThat(first("foo").skip(0, 2).toString()).isEqualTo("first('foo').skip(0, 2)");
20492049
}
20502050

2051-
@Test
2052-
public void matchStartsWith_empty() {
2053-
Substring.Match match = Substring.first("").in("abc").get();
2054-
assertThat(match.startsWith("")).isTrue();
2055-
assertThat(match.startsWith("a")).isFalse();
2056-
}
2057-
2058-
@Test
2059-
public void matchStartsWith_singleChars() {
2060-
Substring.Match match = Substring.first("c").in("abcd").get();
2061-
assertThat(match.startsWith("")).isTrue();
2062-
assertThat(match.startsWith("c")).isTrue();
2063-
assertThat(match.startsWith("bc")).isFalse();
2064-
assertThat(match.startsWith("cd")).isFalse();
2065-
assertThat(match.startsWith("d")).isFalse();
2066-
}
2067-
2068-
@Test
2069-
public void matchStartsWith_twoChars() {
2070-
Substring.Match match = Substring.first("bc").in("abcd").get();
2071-
assertThat(match.startsWith("")).isTrue();
2072-
assertThat(match.startsWith("b")).isTrue();
2073-
assertThat(match.startsWith("bc")).isTrue();
2074-
assertThat(match.startsWith("bcd")).isFalse();
2075-
assertThat(match.startsWith("c")).isFalse();
2076-
}
2077-
2078-
@Test
2079-
public void matchStartsWith_threeChars() {
2080-
Substring.Match match = Substring.first("bcd").in("abcde").get();
2081-
assertThat(match.startsWith("")).isTrue();
2082-
assertThat(match.startsWith("b")).isTrue();
2083-
assertThat(match.startsWith("bc")).isTrue();
2084-
assertThat(match.startsWith("bcd")).isTrue();
2085-
assertThat(match.startsWith("bcde")).isFalse();
2086-
assertThat(match.startsWith("c")).isFalse();
2087-
assertThat(match.startsWith("d")).isFalse();
2088-
assertThat(match.startsWith("e")).isFalse();
2089-
}
2090-
2091-
@Test
2092-
public void matchStartsWith_withSkip() {
2093-
Substring.Match match = Substring.first("bc").in("abcd").get();
2094-
assertThat(match.skip(1, 0).startsWith("c")).isTrue();
2095-
}
2096-
2097-
@Test
2098-
public void matchStartsWith_withLimit() {
2099-
Substring.Match match = Substring.first("bc").in("abcd").get();
2100-
assertThat(match.limit(1).startsWith("b")).isTrue();
2101-
assertThat(match.limit(1).startsWith("bc")).isFalse();
2102-
}
2103-
2104-
@Test
2105-
public void matchEndsWith_empty() {
2106-
Substring.Match match = Substring.first("").in("abc").get();
2107-
assertThat(match.endsWith("")).isTrue();
2108-
assertThat(match.endsWith("c")).isFalse();
2109-
}
2110-
2111-
@Test
2112-
public void matchEndsWith_singleChars() {
2113-
Substring.Match match = Substring.first("b").in("abcd").get();
2114-
assertThat(match.endsWith("")).isTrue();
2115-
assertThat(match.endsWith("b")).isTrue();
2116-
assertThat(match.endsWith("bc")).isFalse();
2117-
assertThat(match.endsWith("ab")).isFalse();
2118-
assertThat(match.endsWith("d")).isFalse();
2119-
}
2120-
2121-
@Test
2122-
public void matchEndsWith_twoChars() {
2123-
Substring.Match match = Substring.first("bc").in("abcd").get();
2124-
assertThat(match.endsWith("")).isTrue();
2125-
assertThat(match.endsWith("c")).isTrue();
2126-
assertThat(match.endsWith("bc")).isTrue();
2127-
assertThat(match.endsWith("bcd")).isFalse();
2128-
assertThat(match.endsWith("d")).isFalse();
2129-
}
2130-
2131-
@Test
2132-
public void matchEndsWith_threeChars() {
2133-
Substring.Match match = Substring.first("bcd").in("abcde").get();
2134-
assertThat(match.endsWith("")).isTrue();
2135-
assertThat(match.endsWith("cd")).isTrue();
2136-
assertThat(match.endsWith("bcd")).isTrue();
2137-
assertThat(match.endsWith("abcd")).isFalse();
2138-
assertThat(match.endsWith("de")).isFalse();
2139-
}
2140-
2141-
@Test
2142-
public void matchEndsWith_withLimit() {
2143-
Substring.Match match = Substring.first("bc").in("abcd").get();
2144-
assertThat(match.limit(1).endsWith("b")).isTrue();
2145-
assertThat(match.limit(1).endsWith("")).isTrue();
2146-
assertThat(match.limit(1).endsWith("bc")).isFalse();
2147-
}
2148-
2149-
@Test
2150-
public void matchEndsWith_withSkip() {
2151-
Substring.Match match = Substring.first("bcd").in("abcde").get();
2152-
assertThat(match.skip(1, 1).endsWith("")).isTrue();
2153-
assertThat(match.skip(1, 1).endsWith("c")).isTrue();
2154-
assertThat(match.skip(1, 1).endsWith("cd")).isFalse();
2155-
assertThat(match.skip(1, 1).endsWith("bc")).isFalse();
2156-
}
2157-
21582051
@Test public void or_toString() {
21592052
assertThat(first("foo").or(last("bar")).toString()).isEqualTo("first('foo').or(last('bar'))");
21602053
}

0 commit comments

Comments
 (0)