diff options
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/POITestCase.java | 8 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/TestPOITestCase.java | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/POITestCase.java b/src/testcases/org/apache/poi/POITestCase.java index a8cc8e1db6..a6cb26a901 100644 --- a/src/testcases/org/apache/poi/POITestCase.java +++ b/src/testcases/org/apache/poi/POITestCase.java @@ -44,6 +44,14 @@ import org.apache.poi.util.Internal; */ @Internal public final class POITestCase { + public static void assertStartsWith(String string, String prefix) { + assertNotNull(string); + assertNotNull(prefix); + + final int len = Math.min(string.length(), prefix.length()); + assertEquals("string does not start with prefix", prefix, string.substring(0, len)); + } + public static void assertContains(String haystack, String needle) { assertNotNull(haystack); assertTrue( diff --git a/src/testcases/org/apache/poi/TestPOITestCase.java b/src/testcases/org/apache/poi/TestPOITestCase.java index fd9f3d1ad9..314009604c 100644 --- a/src/testcases/org/apache/poi/TestPOITestCase.java +++ b/src/testcases/org/apache/poi/TestPOITestCase.java @@ -34,6 +34,13 @@ import org.junit.Test; */ public final class TestPOITestCase { @Test + public void assertStartsWith() { + POITestCase.assertStartsWith("Apache POI", ""); + POITestCase.assertStartsWith("Apache POI", "Apache"); + POITestCase.assertStartsWith("Apache POI", "Apache POI"); + } + + @Test public void assertContains() { POITestCase.assertContains("There is a needle in this haystack", "needle"); /*try { |