Created
April 12, 2012 20:12
-
-
Save stephank/2370677 to your computer and use it in GitHub Desktop.
TypedArray#set copy test
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
// console runnable test case adapted from: | |
// https://github.com/stephank/node-arrays/blob/master/test/typed-array-copy.js | |
function assertEq(desc, a, b) { console.log(desc + ": " + a + " == " + b + " ? " + (a == b)); } | |
a = new Uint16Array(8); | |
b = new Uint8Array(a.buffer, 0, 2); | |
b[0] = 0x05; | |
b[1] = 0x05; | |
assertEq('Uint16 value', a[0], 0x0505); | |
a.set(b); | |
assertEq('First Uint16 element', a[0], 0x0005); | |
assertEq('Second Uint16 element', a[1], 0x0005); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment