-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
bbba311
commit dc8807e
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
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,43 @@ | ||
namespace B64Tests { | ||
export function run(): boolean { | ||
let allPassed: boolean = true | ||
|
||
let bytes: Uint8Array = new Uint8Array(5) | ||
bytes.setFromArray([1, 2, 3, 4, 5,]) | ||
let b64: string = Base64.encodeBuffer(bytes.buffer) | ||
if (b64 != 'AQIDBAU=') { | ||
game.splash("Base64 test 1a failed.") | ||
allPassed = false | ||
} | ||
let bytesOut: Uint8Array = Base64.decodeBuffer(b64) | ||
if (!areEquivalent2(bytesOut, bytes)) { | ||
game.splash("Base64 test 1b failed.") | ||
allPassed = false | ||
} | ||
|
||
b64 = 'foocat==' | ||
let b64Standard: string = Base64.encodeBuffer(Base64.decodeBuffer(b64).buffer) | ||
if (b64Standard != 'foocag==') { | ||
game.splash("Base64 test 2 failed.") | ||
allPassed = false | ||
} | ||
|
||
try { | ||
Base64.decodeBuffer('abc') | ||
game.splash("Base64 test 3a failed.") | ||
allPassed = false | ||
} catch { | ||
|
||
} | ||
|
||
try { | ||
Base64.decodeBuffer('123%') | ||
game.splash("Base64 test 3b failed.") | ||
allPassed = false | ||
} catch { | ||
|
||
} | ||
|
||
return allPassed | ||
} | ||
} |
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
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