atob.js/test.js

28 lines
531 B
JavaScript
Raw Normal View History

2011-09-09 04:18:42 +00:00
(function () {
"use strict";
2018-03-28 04:26:00 +00:00
var atob = require('.');
var encoded = "SGVsbG8sIFdvcmxkIQ=="
var unencoded = "Hello, World!";
2021-03-04 05:08:29 +00:00
var malformed = "SGVsbG8s{"
2012-09-19 20:22:55 +00:00
/*
, encoded = "SGVsbG8sIBZM"
, unencoded = "Hello, 世界"
*/
2011-09-09 04:18:42 +00:00
2011-09-09 20:56:22 +00:00
if (unencoded !== atob(encoded)) {
2012-09-19 20:22:55 +00:00
console.log('[FAIL]', unencoded, atob(encoded));
2011-09-09 04:18:42 +00:00
return;
}
2021-03-04 05:08:29 +00:00
try {
const decoded = atob(malformed)
console.log('[FAIL]', malformed, decoded);
return;
} catch (_) {
/* pass */
}
2011-09-09 04:18:42 +00:00
console.log('[PASS] all tests pass');
}());