Skip to content

Commit

Permalink
test: add test for the range of ACSII
Browse files Browse the repository at this point in the history
  • Loading branch information
BBboy01 authored Sep 17, 2023
1 parent 48fe4a4 commit 2ec6c25
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ var atob = base64.atob;
describe ('Base64.js', function() {

it ('can encode ASCII input', function() {
for (let i = 0; i < 255; i++) {
const char = String.fromCharCode(i);
assert.strictEqual (btoa (char), btoa(char));
}
assert.strictEqual (btoa (''), '');
assert.strictEqual (btoa ('f'), 'Zg==');
assert.strictEqual (btoa ('fo'), 'Zm8=');
Expand Down Expand Up @@ -49,6 +53,10 @@ describe ('Base64.js', function() {
});

it ('can decode Base64-encoded input', function() {
for (let i = 0; i < 255; i++) {
const char = String.fromCharCode(i);
assert.strictEqual (atob(btoa (char)), char);
}
assert.strictEqual (atob (''), '');
assert.strictEqual (atob ('Zg=='), 'f');
assert.strictEqual (atob ('Zm8='), 'fo');
Expand Down

0 comments on commit 2ec6c25

Please sign in to comment.