forked from brix/crypto-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib-typedarrays-test.js
57 lines (45 loc) · 2.2 KB
/
lib-typedarrays-test.js
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
YUI.add('lib-wordarray-test', function (Y) {
var C = CryptoJS;
if (typeof ArrayBuffer != 'undefined') {
Y.Test.Runner.add(new Y.Test.Case({
name: 'TypedArrays',
setUp: function () {
this.data = {};
this.data.buffer = new ArrayBuffer(8);
var uint8View = new Uint8Array(this.data.buffer);
uint8View[0] = 0x01;
uint8View[1] = 0x23;
uint8View[2] = 0x45;
uint8View[3] = 0x67;
uint8View[4] = 0x89;
uint8View[5] = 0xab;
uint8View[6] = 0xcd;
uint8View[7] = 0xef;
},
testInt8Array: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int8Array(this.data.buffer)).toString());
},
testUint8Array: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8Array(this.data.buffer)).toString());
},
testUint8ClampedArray: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8ClampedArray(this.data.buffer)).toString());
},
testInt16Array: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int16Array(this.data.buffer)).toString());
},
testUint16Array: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint16Array(this.data.buffer)).toString());
},
testInt32Array: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int32Array(this.data.buffer)).toString());
},
testUint32Array: function () {
Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint32Array(this.data.buffer)).toString());
},
testPartialView: function () {
Y.Assert.areEqual('456789ab', C.lib.WordArray.create(new Int16Array(this.data.buffer, 2, 2)).toString());
}
}));
}
}, '$Rev$');