-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
test/built-ins/Uint8Array/prototype/toBase64/omit-padding.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-uint8array.prototype.tobase64 | ||
description: Conversion of Uint8Arrays to base64 strings exercising the omitPadding option | ||
features: [uint8array-base64, TypedArray] | ||
---*/ | ||
|
||
// works with default alphabet | ||
assert.sameValue((new Uint8Array([199, 239])).toBase64(), "x+8="); | ||
assert.sameValue((new Uint8Array([199, 239])).toBase64({ omitPadding: false }), "x+8="); | ||
assert.sameValue((new Uint8Array([199, 239])).toBase64({ omitPadding: true }), "x+8"); | ||
assert.sameValue((new Uint8Array([255])).toBase64({ omitPadding: true }), "/w"); | ||
|
||
// works with base64url alphabet | ||
assert.sameValue((new Uint8Array([199, 239])).toBase64({ alphabet: "base64url" }), "x-8="); | ||
assert.sameValue((new Uint8Array([199, 239])).toBase64({ alphabet: "base64url", omitPadding: false }), "x-8="); | ||
assert.sameValue((new Uint8Array([199, 239])).toBase64({ alphabet: "base64url", omitPadding: true }), "x-8"); | ||
assert.sameValue((new Uint8Array([255])).toBase64({ alphabet: "base64url", omitPadding: true }), "_w"); | ||
|
||
// performs ToBoolean on the argument | ||
assert.sameValue((new Uint8Array([255])).toBase64({ omitPadding: 0 }), "/w=="); | ||
assert.sameValue((new Uint8Array([255])).toBase64({ omitPadding: 1 }), "/w"); |