Skip to content

Instantly share code, notes, and snippets.

@etorreborre
Created June 17, 2010 00:45
Show Gist options
  • Save etorreborre/441492 to your computer and use it in GitHub Desktop.
Save etorreborre/441492 to your computer and use it in GitHub Desktop.
// you can refactor all those mustEqual examples
// to be more concise and provide a complete description in the reports
"Json" should {
"quote strings" in {
"unicode within latin-1" in {
Json.quote("hello\n\u009f") mustEqual "\"hello\\n\\u009f\""
}
"unicode outside of latin-1 (the word Tokyo)" in {
Json.quote("\u6771\u4eac") mustEqual "\"\\u6771\\u4eac\""
}
}
}
// Just introduce a method called "quote", like this:
"Json" should {
"quote strings" in {
quote("unicode within latin-1", "hello\n\u009f", "\"hello\\n\\u009f\"")
quote("unicode outside of latin-1 (the word Tokyo)", "\u6771\u4eac", "\"\\u6771\\u4eac\"")
def quote(desc: String, input: String, output: String) = {
(desc+": "+input+" --> "+output) in {
Json.quote(input) mustEqual output
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment