hrydgard/nodeprep — pull request #1 by zond (2014-06-28 15:24:45+00:00)
Title: Added some random string tests.

* Added a subdirectory `python` containing the python code to use the XMPP package in python to nodeprep strings.
* Added a test that generates random UTF8 strings, and then compares the results of `Nodeprep`ing them once and twice with the same using the python tool. The generation of these UTF8 strings is what takes time, so a more clever way would be nice...

As expected, bug were uncovered, but they seem to be limited to certain characters at least...

```
[0:zond@pelican ~/go/src/github.com/zond/nodeprep]$go test -v -test.run=Test_RandomStrings
=== RUN Test_RandomStrings
Generated 9999 random and valid UTF8 strings
Found 55109/213044249 valid code points (on average 0.00025867396214013737 of the possible runes are valid code points)
--- FAIL: Test_RandomStrings (16.52 seconds)
nodeprep_test.go:126: Python prepping "燒" produced "", but Go prepping it produced "燒"
nodeprep_test.go:133: Python prepping "燒" twice produced "", but Go prepping it twice produced "燒"
nodeprep_test.go:126: Python prepping "ᤦ\U000fa693" produced "", but Go prepping it produced "ᤦ"
nodeprep_test.go:133: Python prepping "ᤦ\U000fa693" twice produced "", but Go prepping it twice produced "ᤦ"
nodeprep_test.go:126: Python prepping "㢾" produced "", but Go prepping it produced "㢾"
nodeprep_test.go:133: Python prepping "㢾" twice produced "", but Go prepping it twice produced "㢾"
nodeprep_test.go:126: Python prepping "᤟" produced "", but Go prepping it produced "᤟"
nodeprep_test.go:133: Python prepping "᤟" twice produced "", but Go prepping it twice produced "᤟"
nodeprep_test.go:126: Python prepping "徰" produced "", but Go prepping it produced "徰"
nodeprep_test.go:133: Python prepping "徰" twice produced "", but Go prepping it twice produced "徰"
nodeprep_test.go:126: Python prepping "徵" produced "", but Go prepping it produced "徵"
nodeprep_test.go:133: Python prepping "徵" twice produced "", but Go prepping it twice produced "徵"
nodeprep_test.go:126: Python prepping "᭳" produced "", but Go prepping it produced "᭳"
nodeprep_test.go:133: Python prepping "᭳" twice produced "", but Go prepping it twice produced "᭳"
nodeprep_test.go:126: Python prepping "\U0010a1dc⢢" produced "", but Go prepping it produced "⢢"
nodeprep_test.go:133: Python prepping "\U0010a1dc⢢" twice produced "", but Go prepping it twice produced "⢢"
nodeprep_test.go:126: Python prepping "޽" produced "", but Go prepping it produced "޽"
nodeprep_test.go:133: Python prepping "޽" twice produced "", but Go prepping it twice produced "޽"
nodeprep_test.go:126: Python prepping "圐" produced "", but Go prepping it produced "圐"
nodeprep_test.go:133: Python prepping "圐" twice produced "", but Go prepping it twice produced "圐"
nodeprep_test.go:126: Python prepping "舐\U0010e5c3" produced "", but Go prepping it produced "舐"
nodeprep_test.go:133: Python prepping "舐\U0010e5c3" twice produced "", but Go prepping it twice produced "舐"
nodeprep_test.go:126: Python prepping "\U000f9081⿁" produced "", but Go prepping it produced "鬼"
nodeprep_test.go:133: Python prepping "\U000f9081⿁" twice produced "", but Go prepping it twice produced "鬼"
nodeprep_test.go:126: Python prepping "\U0010c504←" produced "", but Go prepping it produced "←"
nodeprep_test.go:133: Python prepping "\U0010c504←" twice produced "", but Go prepping it twice produced "←"
nodeprep_test.go:126: Python prepping "鄉" produced "", but Go prepping it produced "鄉"
nodeprep_test.go:133: Python prepping "鄉" twice produced "", but Go prepping it twice produced "鄉"
nodeprep_test.go:126: Python prepping "簀\U000fbc95" produced "", but Go prepping it produced "簀"
nodeprep_test.go:133: Python prepping "簀\U000fbc95" twice produced "", but Go prepping it twice produced "簀"
nodeprep_test.go:126: Python prepping "亰" produced "", but Go prepping it produced "亰"
nodeprep_test.go:133: Python prepping "亰" twice produced "", but Go prepping it twice produced "亰"
nodeprep_test.go:126: Python prepping "砬" produced "", but Go prepping it produced "砬"
nodeprep_test.go:133: Python prepping "砬" twice produced "", but Go prepping it twice produced "砬"
nodeprep_test.go:126: Python prepping "⑻" produced "", but Go prepping it produced "⑻"
nodeprep_test.go:133: Python prepping "⑻" twice produced "", but Go prepping it twice produced "⑻"
nodeprep_test.go:126: Python prepping "᪯" produced "", but Go prepping it produced "᪯"
nodeprep_test.go:133: Python prepping "᪯" twice produced "", but Go prepping it twice produced "᪯"
nodeprep_test.go:126: Python prepping "氼" produced "", but Go prepping it produced "氼"
nodeprep_test.go:133: Python prepping "氼" twice produced "", but Go prepping it twice produced "氼"
nodeprep_test.go:126: Python prepping "\U00109a73픍\U000fb65c" produced "", but Go prepping it produced "픍"
nodeprep_test.go:133: Python prepping "\U00109a73픍\U000fb65c" twice produced "", but Go prepping it twice produced "픍"
nodeprep_test.go:126: Python prepping "Ἑ" produced "", but Go prepping it produced "Ἑ"
nodeprep_test.go:133: Python prepping "Ἑ" twice produced "", but Go prepping it twice produced "Ἑ"
nodeprep_test.go:126: Python prepping "\U00107da6酠" produced "", but Go prepping it produced "酠"
nodeprep_test.go:133: Python prepping "\U00107da6酠" twice produced "", but Go prepping it twice produced "酠"
nodeprep_test.go:126: Python prepping "\U00107edd₀" produced "", but Go prepping it produced "₀"
nodeprep_test.go:133: Python prepping "\U00107edd₀" twice produced "", but Go prepping it twice produced "₀"
nodeprep_test.go:126: Python prepping "户" produced "", but Go prepping it produced "户"
nodeprep_test.go:133: Python prepping "户" twice produced "", but Go prepping it twice produced "户"
nodeprep_test.go:126: Python prepping "\U000f022e制" produced "", but Go prepping it produced "制"
nodeprep_test.go:133: Python prepping "\U000f022e制" twice produced "", but Go prepping it twice produced "制"
nodeprep_test.go:126: Python prepping "舝" produced "", but Go prepping it produced "舝"
nodeprep_test.go:133: Python prepping "舝" twice produced "", but Go prepping it twice produced "舝"
nodeprep_test.go:126: Python prepping "榇\U0010e126" produced "", but Go prepping it produced "榇"
nodeprep_test.go:133: Python prepping "榇\U0010e126" twice produced "", but Go prepping it twice produced "榇"
nodeprep_test.go:126: Python prepping "琎" produced "", but Go prepping it produced "琎"
nodeprep_test.go:133: Python prepping "琎" twice produced "", but Go prepping it twice produced "琎"
nodeprep_test.go:126: Python prepping "翕" produced "", but Go prepping it produced "翕"
nodeprep_test.go:133: Python prepping "翕" twice produced "", but Go prepping it twice produced "翕"
nodeprep_test.go:126: Python prepping "ठ\U00105a5a" produced "", but Go prepping it produced "ठ"
nodeprep_test.go:133: Python prepping "ठ\U00105a5a" twice produced "", but Go prepping it twice produced "ठ"
nodeprep_test.go:126: Python prepping "䤞\U0010c0e8" produced "", but Go prepping it produced "䤞"
nodeprep_test.go:133: Python prepping "䤞\U0010c0e8" twice produced "", but Go prepping it twice produced "䤞"
nodeprep_test.go:126: Python prepping "쒇\U000f0bc3堖" produced "", but Go prepping it produced "쒇堖"
nodeprep_test.go:133: Python prepping "쒇\U000f0bc3堖" twice produced "", but Go prepping it twice produced "쒇堖"
nodeprep_test.go:126: Python prepping "\U000fc7f9㋗" produced "", but Go prepping it produced "㋗"
nodeprep_test.go:133: Python prepping "\U000fc7f9㋗" twice produced "", but Go prepping it twice produced "㋗"
nodeprep_test.go:126: Python prepping "쌜\U000fa049" produced "", but Go prepping it produced "쌜"
nodeprep_test.go:133: Python prepping "쌜\U000fa049" twice produced "", but Go prepping it twice produced "쌜"
nodeprep_test.go:126: Python prepping "䍊" produced "", but Go prepping it produced "䍊"
nodeprep_test.go:133: Python prepping "䍊" twice produced "", but Go prepping it twice produced "䍊"
nodeprep_test.go:126: Python prepping "䯶" produced "", but Go prepping it produced "䯶"
nodeprep_test.go:133: Python prepping "䯶" twice produced "", but Go prepping it twice produced "䯶"
nodeprep_test.go:126: Python prepping "䄸" produced "", but Go prepping it produced "䄸"
nodeprep_test.go:133: Python prepping "䄸" twice produced "", but Go prepping it twice produced "䄸"
nodeprep_test.go:126: Python prepping "\U000f6176縳" produced "", but Go prepping it produced "縳"
nodeprep_test.go:133: Python prepping "\U000f6176縳" twice produced "", but Go prepping it twice produced "縳"
nodeprep_test.go:126: Python prepping "褅" produced "", but Go prepping it produced "褅"
nodeprep_test.go:133: Python prepping "褅" twice produced "", but Go prepping it twice produced "褅"
nodeprep_test.go:126: Python prepping "礋" produced "", but Go prepping it produced "礋"
nodeprep_test.go:133: Python prepping "礋" twice produced "", but Go prepping it twice produced "礋"
nodeprep_test.go:126: Python prepping "혽" produced "", but Go prepping it produced "b"
nodeprep_test.go:133: Python prepping "혽" twice produced "", but Go prepping it twice produced "b"
nodeprep_test.go:126: Python prepping "战" produced "", but Go prepping it produced "战"
nodeprep_test.go:133: Python prepping "战" twice produced "", but Go prepping it twice produced "战"
nodeprep_test.go:126: Python prepping "躄\U00106a6f" produced "", but Go prepping it produced "躄"
nodeprep_test.go:133: Python prepping "躄\U00106a6f" twice produced "", but Go prepping it twice produced "躄"
nodeprep_test.go:126: Python prepping "翱홺" produced "", but Go prepping it produced "翱k"
nodeprep_test.go:133: Python prepping "翱홺" twice produced "", but Go prepping it twice produced "翱k"
nodeprep_test.go:126: Python prepping "퐎" produced "", but Go prepping it produced "o"
nodeprep_test.go:133: Python prepping "퐎" twice produced "", but Go prepping it twice produced "o"
nodeprep_test.go:126: Python prepping "遷䗓" produced "", but Go prepping it produced "遷䗓"
nodeprep_test.go:133: Python prepping "遷䗓" twice produced "", but Go prepping it twice produced "遷䗓"
nodeprep_test.go:126: Python prepping "഼" produced "", but Go prepping it produced "഼"
nodeprep_test.go:133: Python prepping "഼" twice produced "", but Go prepping it twice produced "഼"
nodeprep_test.go:126: Python prepping "៊" produced "", but Go prepping it produced "៊"
nodeprep_test.go:133: Python prepping "៊" twice produced "", but Go prepping it twice produced "៊"
nodeprep_test.go:126: Python prepping "杞" produced "", but Go prepping it produced "杞"
nodeprep_test.go:133: Python prepping "杞" twice produced "", but Go prepping it twice produced "杞"
nodeprep_test.go:126: Python prepping "㻛" produced "", but Go prepping it produced "㻛"
nodeprep_test.go:133: Python prepping "㻛" twice produced "", but Go prepping it twice produced "㻛"
nodeprep_test.go:126: Python prepping "\U00107087୑" produced "", but Go prepping it produced "୑"
nodeprep_test.go:133: Python prepping "\U00107087୑" twice produced "", but Go prepping it twice produced "୑"
nodeprep_test.go:126: Python prepping "姬黂" produced "", but Go prepping it produced "姬黂"
nodeprep_test.go:133: Python prepping "姬黂" twice produced "", but Go prepping it twice produced "姬黂"
nodeprep_test.go:126: Python prepping "\U000f84b9ᣣ" produced "", but Go prepping it produced "ᣣ"
nodeprep_test.go:133: Python prepping "\U000f84b9ᣣ" twice produced "", but Go prepping it twice produced "ᣣ"
nodeprep_test.go:126: Python prepping "\U000f7e82加" produced "", but Go prepping it produced "加"
nodeprep_test.go:133: Python prepping "\U000f7e82加" twice produced "", but Go prepping it twice produced "加"
nodeprep_test.go:126: Python prepping "饯\U000fd063" produced "", but Go prepping it produced "饯"
nodeprep_test.go:133: Python prepping "饯\U000fd063" twice produced "", but Go prepping it twice produced "饯"
nodeprep_test.go:126: Python prepping "樚" produced "", but Go prepping it produced "樚"
nodeprep_test.go:133: Python prepping "樚" twice produced "", but Go prepping it twice produced "樚"
nodeprep_test.go:126: Python prepping "ƣ" produced "", but Go prepping it produced "ƣ"
nodeprep_test.go:133: Python prepping "ƣ" twice produced "", but Go prepping it twice produced "ƣ"
nodeprep_test.go:126: Python prepping "该" produced "", but Go prepping it produced "该"
nodeprep_test.go:133: Python prepping "该" twice produced "", but Go prepping it twice produced "该"
nodeprep_test.go:126: Python prepping "ѯ" produced "", but Go prepping it produced "ѯ"
nodeprep_test.go:133: Python prepping "ѯ" twice produced "", but Go prepping it twice produced "ѯ"
nodeprep_test.go:126: Python prepping "슁\U0010642b毠" produced "", but Go prepping it produced "슁毠"
nodeprep_test.go:133: Python prepping "슁\U0010642b毠" twice produced "", but Go prepping it twice produced "슁毠"
nodeprep_test.go:126: Python prepping "ⶺ" produced "", but Go prepping it produced "ⶺ"
nodeprep_test.go:133: Python prepping "ⶺ" twice produced "", but Go prepping it twice produced "ⶺ"
nodeprep_test.go:126: Python prepping "斆" produced "", but Go prepping it produced "斆"
nodeprep_test.go:133: Python prepping "斆" twice produced "", but Go prepping it twice produced "斆"
nodeprep_test.go:126: Python prepping "" produced "", but Go prepping it produced ""
nodeprep_test.go:133: Python prepping "" twice produced "", but Go prepping it twice produced ""
nodeprep_test.go:126: Python prepping "\U0010b895ꃐ" produced "", but Go prepping it produced "ꃐ"
nodeprep_test.go:133: Python prepping "\U0010b895ꃐ" twice produced "", but Go prepping it twice produced "ꃐ"
nodeprep_test.go:126: Python prepping "♇\U001004bc" produced "", but Go prepping it produced "♇"
nodeprep_test.go:133: Python prepping "♇\U001004bc" twice produced "", but Go prepping it twice produced "♇"
nodeprep_test.go:126: Python prepping "魅" produced "", but Go prepping it produced "魅"
nodeprep_test.go:133: Python prepping "魅" twice produced "", but Go prepping it twice produced "魅"
nodeprep_test.go:126: Python prepping "杪" produced "", but Go prepping it produced "杪"
nodeprep_test.go:133: Python prepping "杪" twice produced "", but Go prepping it twice produced "杪"
nodeprep_test.go:126: Python prepping "㩹" produced "", but Go prepping it produced "㩹"
nodeprep_test.go:133: Python prepping "㩹" twice produced "", but Go prepping it twice produced "㩹"
nodeprep_test.go:126: Python prepping "㏲" produced "", but Go prepping it produced "㏲"
nodeprep_test.go:133: Python prepping "㏲" twice produced "", but Go prepping it twice produced "㏲"
nodeprep_test.go:126: Python prepping "ಕ" produced "", but Go prepping it produced "ಕ"
nodeprep_test.go:133: Python prepping "ಕ" twice produced "", but Go prepping it twice produced "ಕ"
nodeprep_test.go:126: Python prepping "婟" produced "", but Go prepping it produced "婟"
nodeprep_test.go:133: Python prepping "婟" twice produced "", but Go prepping it twice produced "婟"
nodeprep_test.go:155: 144/10000 strings badly encoded (but 186 non zero strings correctly encoded :)
FAIL
exit status 1
FAIL	github.com/zond/nodeprep	16.532s
[1:zond@pelican ~/go/src/github.com/zond/nodeprep]$
```