-
Notifications
You must be signed in to change notification settings - Fork 8
/
test.html
58 lines (51 loc) · 1.32 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<html>
<head>
<title>Test page for base64.js</title>
<script type="text/javascript" src="base64.js"></script>
</head>
<body>
<h1>Test page for base64.js</h1>
<span id="test-span"></span>
<script type="text/javascript">
var test_span = document.getElementById("test-span");
function add_text(str) {
test_span.appendChild(document.createTextNode(str));
}
function br() {
test_span.appendChild(document.createElement("br"));
}
function encode_decode_test(str) {
add_text(str);
add_text(" ");
add_text(base64.encode(str));
add_text(" ");
add_text(base64.decode(base64.encode(str)));
br();
}
function print_settings() {
test_span.appendChild(document.createTextNode(JSON.stringify(base64.settings)));
br();
}
function run_test() {
// Tests are from http://www.madore.org/~david/misc/unitest/
print_settings();
encode_decode_test("a");
encode_decode_test("ab");
encode_decode_test("ab~");
encode_decode_test("السلام عليكم");
encode_decode_test("你好");
encode_decode_test("नमस्ते");
encode_decode_test("Привет");
encode_decode_test("שלום");
br();
}
run_test();
base64.settings.pad = null;
run_test();
base64.settings.char62 = "-";
base64.settings.char63 = "_";
base64.settings.pad = undefined;
run_test();
</script>
</body>
</html>