Skip to content

Instantly share code, notes, and snippets.

@patrickhammond
Created November 10, 2015 14:05
Show Gist options
  • Save patrickhammond/cdb7f33b4fa2c761ee5a to your computer and use it in GitHub Desktop.
Save patrickhammond/cdb7f33b4fa2c761ee5a to your computer and use it in GitHub Desktop.
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class StringTest {
@Test
public void testAllTheSame() {
assertEquals(true, allDuplicateChars("cccccc"));
}
@Test
public void testNotTheSame() {
assertEquals(false, allDuplicateChars("abcdef"));
}
public boolean allDuplicateChars(String input) {
return input.matches("(.)\\1*");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment