Created
November 10, 2015 14:05
-
-
Save patrickhammond/cdb7f33b4fa2c761ee5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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