summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2010-08-26 11:34:44 -0500
committerJoel Martin <github@martintribe.org>2010-08-26 11:34:44 -0500
commit4ff85f496c0a96d0d31096baa3038822dc692dd0 (patch)
treef430db6470458d0092df4497b68a3b26e1ddc005 /tests
parent67b4e9879a0dc223dd0dfd8dce2392d4341aa5ff (diff)
downloadwebsockify-4ff85f496c0a96d0d31096baa3038822dc692dd0.tar.gz
Test both builtin and base64.js functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/base64.html30
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/base64.html b/tests/base64.html
index b66fc42..58eb7ac 100644
--- a/tests/base64.html
+++ b/tests/base64.html
@@ -3,6 +3,7 @@
<head>
<title>Native Base64 Tests</title>
<script src="include/util.js"></script>
+ <script src="include/base64.js"></script>
</head>
<body>
<h1>Native Base64 Tests</h1>
@@ -40,19 +41,19 @@
return true;
}
+ function Base64_decode(data) {
+ var arr = Base64.decode (data);
+ return arr.map(function (num) {
+ return String.fromCharCode(num); } ).join('');
+
+ }
+
window.onload = function() {
var str;
debug('onload');
fail = 0;
pass = 0;
assertRun('window.btoa("hello world")', 'aGVsbG8gd29ybGQ=');
- assertRun('window.atob("aGVsbG8gd29ybGQ=")', 'hello world');
- assertRun('window.atob("YQ==")', 'a');
- assertRun('window.atob("YWI=")', 'ab');
- assertRun('window.atob("YWJj")', 'abc');
- assertRun('window.atob("YWJjZA==")', 'abcd');
- assertRun('window.atob("YWJjZGU=")', 'abcde');
- assertRun('window.atob("YWJjZGVm")', 'abcdef');
assertRun('window.btoa("a")', 'YQ==');
assertRun('window.btoa("ab")', 'YWI=');
assertRun('window.btoa("abc")', 'YWJj');
@@ -62,6 +63,21 @@
assertRun('window.btoa("abcdefg")', 'YWJjZGVmZw==');
assertRun('window.btoa("abcdefgh")', 'YWJjZGVmZ2g=');
+ assertRun('window.atob("aGVsbG8gd29ybGQ=")', 'hello world');
+ assertRun('Base64_decode("aGVsbG8gd29ybGQ=")', 'hello world');
+ assertRun('window.atob("YQ==")', 'a');
+ assertRun('Base64_decode("YQ==")', 'a');
+ assertRun('window.atob("YWI=")', 'ab');
+ assertRun('Base64_decode("YWI=")', 'ab');
+ assertRun('window.atob("YWJj")', 'abc');
+ assertRun('Base64_decode("YWJj")', 'abc');
+ assertRun('window.atob("YWJjZA==")', 'abcd');
+ assertRun('Base64_decode("YWJjZA==")', 'abcd');
+ assertRun('window.atob("YWJjZGU=")', 'abcde');
+ assertRun('Base64_decode("YWJjZGU=")', 'abcde');
+ assertRun('window.atob("YWJjZGVm")', 'abcdef');
+ assertRun('Base64_decode("YWJjZGVm")', 'abcdef');
+
assertRun('typeof window.btoa', 'function');
assertRun('window.btoa("")', '');
assertRun('window.btoa(null)', '');