Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import junit.framework.TestCase;
- public class SubStringFinderTest extends TestCase {
- public void testHariWithPrefixes() {
- assertSubStringFinderEquals(true, "hari");
- assertSubStringFinderEquals(true, "xhari");
- assertSubStringFinderEquals(true, "xxhari");
- assertSubStringFinderEquals(true, "xxxhari");
- }
- public void testWrongOrder() {
- assertSubStringFinderEquals(false, "irah");
- assertSubStringFinderEquals(false, "xirah");
- assertSubStringFinderEquals(false, "xxirah");
- assertSubStringFinderEquals(false, "xxxirah"); // We seem to have a problem here.
- assertSubStringFinderEquals(false, "xxxxirah");
- assertSubStringFinderEquals(false, "xxxxxirah");
- assertSubStringFinderEquals(false, "xxxxxxirah");
- }
- public void testSmallSubstrings() {
- assertSubStringFinderEquals(false, "");
- assertSubStringFinderEquals(false, "har");
- assertSubStringFinderEquals(false, "ha");
- assertSubStringFinderEquals(false, "h");
- }
- private void assertSubStringFinderEquals(final boolean expectedResult, final String searchString) {
- assertEquals("Expected this result when searching string <" + searchString + ">;",
- expectedResult, SubStringFinder.searchString(searchString));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement