gecko/services/sync/tests/unit/test_utils_encodeBase32.js
Philipp von Weitershausen 61179044c7 Bug 589979 - Generate username from email address (part 1) [r=mconnor]
Implement Utils.encodeBases32 and Utils.sha1Base32.
2010-09-13 17:17:37 +02:00

16 lines
601 B
JavaScript

Cu.import("resource://services-sync/util.js");
function run_test() {
// Test vectors from RFC 4648
do_check_eq(Utils.encodeBase32(""), "");
do_check_eq(Utils.encodeBase32("f"), "MY======");
do_check_eq(Utils.encodeBase32("fo"), "MZXQ====");
do_check_eq(Utils.encodeBase32("foo"), "MZXW6===");
do_check_eq(Utils.encodeBase32("foob"), "MZXW6YQ=");
do_check_eq(Utils.encodeBase32("fooba"), "MZXW6YTB");
do_check_eq(Utils.encodeBase32("foobar"), "MZXW6YTBOI======");
do_check_eq(Utils.encodeBase32("Bacon is a vegetable."),
"IJQWG33OEBUXGIDBEB3GKZ3FORQWE3DFFY======");
}