Created
June 17, 2010 00:45
-
-
Save etorreborre/441492 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
// 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