atob.js/test.js

28 lines
531 B
JavaScript

(function () {
"use strict";
var atob = require('.');
var encoded = "SGVsbG8sIFdvcmxkIQ=="
var unencoded = "Hello, World!";
var malformed = "SGVsbG8s{"
/*
, encoded = "SGVsbG8sIBZM"
, unencoded = "Hello, 世界"
*/
if (unencoded !== atob(encoded)) {
console.log('[FAIL]', unencoded, atob(encoded));
return;
}
try {
const decoded = atob(malformed)
console.log('[FAIL]', malformed, decoded);
return;
} catch (_) {
/* pass */
}
console.log('[PASS] all tests pass');
}());