Skip to content

Instantly share code, notes, and snippets.

@d4rken
Last active May 28, 2019 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d4rken/00237405f5c900a46ad5ae3c753d0d74 to your computer and use it in GitHub Desktop.
Save d4rken/00237405f5c900a46ad5ae3c753d0d74 to your computer and use it in GitHub Desktop.
fun claresSimpleQuestion(input: String) : Boolean {
val pattern = Pattern.compile("^[A-Z].*?$")
return pattern.matcher(input).matches()
}
@Test
fun testClaresSimpleQuestion() {
assertThat(claresSimpleQuestion(""),`is`(false))
assertThat(claresSimpleQuestion("a"),`is`(false))
assertThat(claresSimpleQuestion("A"),`is`(true))
assertThat(claresSimpleQuestion("Aa"),`is`(true))
assertThat(claresSimpleQuestion("aA"),`is`(false))
}
fun String.test() : Boolean = Pattern.compile("^[A-Z].*?$").matcher(this).matches()
assert("Aa".test() && !"aA".test())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment