Ejemplo n.º 1
0
  @Test
  public void testDelete() throws Exception {
    String inString = "The quick brown fox jumped over the lazy dog";

    String noThe = StringUtils.delete(inString, "the");
    assertTrue(
        "Result has no the [" + noThe + "]",
        noThe.equals("The quick brown fox jumped over  lazy dog"));

    String nohe = StringUtils.delete(inString, "he");
    assertTrue(
        "Result has no he [" + nohe + "]", nohe.equals("T quick brown fox jumped over t lazy dog"));

    String nosp = StringUtils.delete(inString, " ");
    assertTrue("Result has no spaces", nosp.equals("Thequickbrownfoxjumpedoverthelazydog"));

    String killEnd = StringUtils.delete(inString, "dog");
    assertTrue("Result has no dog", killEnd.equals("The quick brown fox jumped over the lazy "));

    String mismatch = StringUtils.delete(inString, "dxxcxcxog");
    assertTrue("Result is unchanged", mismatch.equals(inString));

    String nochange = StringUtils.delete(inString, "");
    assertTrue("Result is unchanged", nochange.equals(inString));
  }