diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2020-03-20 06:21:42 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 10:21:42 +0100 |
commit | 70d93636cb85a5397fe9efcd463e6e39eb20501c (patch) | |
tree | 629b7f589d6bb50cf386bd156abb3f5ab4e7011b /tests | |
parent | dd362ab4c0f574f781fb450b479d9dda8ced1e63 (diff) | |
download | Nim-70d93636cb85a5397fe9efcd463e6e39eb20501c.tar.gz |
Add Base64 safe (#13672)
* Implement RFC-4648 Section-7 * https://github.com/nim-lang/Nim/pull/13672#issuecomment-600993466
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tbase64.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/stdlib/tbase64.nim b/tests/stdlib/tbase64.nim index 9db6e8802..e5b13642c 100644 --- a/tests/stdlib/tbase64.nim +++ b/tests/stdlib/tbase64.nim @@ -39,6 +39,21 @@ proc main() = except ValueError: discard + block base64urlSafe: + doAssert encode("c\xf7>", safe = true) == "Y_c-" + doAssert encode("c\xf7>", safe = false) == "Y/c+" # Not a nice URL :( + doAssert decode("Y/c+") == decode("Y_c-") + # Output must not change with safe=true + doAssert encode("Hello World", safe = true) == "SGVsbG8gV29ybGQ=" + doAssert encode("leasure.", safe = true) == "bGVhc3VyZS4=" + doAssert encode("easure.", safe = true) == "ZWFzdXJlLg==" + doAssert encode("asure.", safe = true) == "YXN1cmUu" + doAssert encode("sure.", safe = true) == "c3VyZS4=" + doAssert encode([1,2,3], safe = true) == "AQID" + doAssert encode(['h','e','y'], safe = true) == "aGV5" + doAssert encode("", safe = true) == "" + doAssert encode("the quick brown dog jumps over the lazy fox", safe = true) == "dGhlIHF1aWNrIGJyb3duIGRvZyBqdW1wcyBvdmVyIHRoZSBsYXp5IGZveA==" + echo "OK" main() |