private void somethingIsWrongWithGenerateHash() {
    String randomString = "";
    int randomLength = (int) (Math.random() * 40);
    for (int i = 0; i < randomLength; i++) {
      randomString += (char) (Math.random() * Character.MAX_VALUE);
    }

    try {
      stringSearching.generateHash(null, 0);
      fail("Null character sequence did not throw exception.");
    } catch (IllegalArgumentException e) {
      assertNotNull("IllegalArgumentException needs a message", e.getMessage());
      assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
    }

    try {
      stringSearching.generateHash(randomString, (int) (Math.random() * Integer.MIN_VALUE));
      fail("Negative length did not throw exception.");
    } catch (IllegalArgumentException e) {
      assertNotNull("IllegalArgumentException needs a message!", e.getMessage());
      assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
    }

    try {
      stringSearching.generateHash(randomString, randomLength + (int) (Math.random() * 5));
      fail("length greater than randomString.length() did not throw" + "Exception");
    } catch (IllegalArgumentException e) {
      assertNotNull("IllegalArgumentException needs a message!");
      assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
    }
  }
 private void somethingIsWrongWithBuildFailureTable() {
   try {
     stringSearching.buildFailureTable(null);
     fail("Didn't throw exception for null pattern.");
   } catch (IllegalArgumentException e) {
     assertNotNull("IllegalArgumentException needs a message!");
     assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
   }
 }
 private void somethingIsWrongWithUpdateHash() {
   try {
     stringSearching.updateHash(1, (int) (Math.random() * Integer.MIN_VALUE), 'c', 'a');
     fail("Random negative length did not throw Exception");
   } catch (IllegalArgumentException e) {
     assertNotNull("IllegalArgumentException needs a message!");
     assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
   }
 }
 private void somethingIsWrongWithBoyerMoore() {
   try {
     stringSearching.boyerMoore(null, mattText);
     fail("Didn't throw exception for null pattern.");
   } catch (IllegalArgumentException e) {
     assertNotNull("IllegalArgumentException needs a message!");
     assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
   }
   try {
     stringSearching.boyerMoore("", mattText);
     fail("Didn't throw exception for empty pattern.");
   } catch (IllegalArgumentException e) {
     assertNotNull("IllegalArgumentException needs a message!");
     assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
   }
   try {
     stringSearching.boyerMoore(matt, null);
     fail("Didn't throw exception for null text.");
   } catch (IllegalArgumentException e) {
     assertNotNull("IllegalArgumentException needs a message!");
     assertTrue("Make sure the message is useful.", e.getMessage().length() > 10);
   }
 }