Advertisement
JeffGrigg

SubStringFinderTest

Jul 20th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.34 KB | None | 0 0
  1. import junit.framework.TestCase;
  2.  
  3. public class SubStringFinderTest extends TestCase {
  4.  
  5.     public void testHariWithPrefixes() {
  6.         assertSubStringFinderEquals(true, "hari");
  7.  
  8.         assertSubStringFinderEquals(true, "xhari");
  9.         assertSubStringFinderEquals(true, "xxhari");
  10.         assertSubStringFinderEquals(true, "xxxhari");
  11.     }
  12.  
  13.     public void testWrongOrder() {
  14.         assertSubStringFinderEquals(false, "irah");
  15.  
  16.         assertSubStringFinderEquals(false, "xirah");
  17.         assertSubStringFinderEquals(false, "xxirah");
  18.         assertSubStringFinderEquals(false, "xxxirah");  // We seem to have a problem here.
  19.         assertSubStringFinderEquals(false, "xxxxirah");
  20.         assertSubStringFinderEquals(false, "xxxxxirah");
  21.         assertSubStringFinderEquals(false, "xxxxxxirah");
  22.     }
  23.  
  24.     public void testSmallSubstrings() {
  25.         assertSubStringFinderEquals(false, "");
  26.         assertSubStringFinderEquals(false, "har");
  27.         assertSubStringFinderEquals(false, "ha");
  28.         assertSubStringFinderEquals(false, "h");
  29.     }
  30.  
  31.     private void assertSubStringFinderEquals(final boolean expectedResult, final String searchString) {
  32.         assertEquals("Expected this result when searching string <" + searchString + ">;",
  33.                 expectedResult, SubStringFinder.searchString(searchString));
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement