summaryrefslogtreecommitdiffstats
path: root/test/codec_arraybuffer_test.js
diff options
context:
space:
mode:
authorNils Kenneweg <nk@ovt.me>2014-09-26 18:14:50 +0200
committerNils Kenneweg <nk@ovt.me>2014-09-26 18:14:50 +0200
commit221c6edd91b06660694f377d9b63d5a6f507437e (patch)
treec9698d17beb941f483b9668f0ac104b5eb9ba642 /test/codec_arraybuffer_test.js
parent37eb69607aad0079c6479f5d4d2842d93d3a5f11 (diff)
downloadsjcl-221c6edd91b06660694f377d9b63d5a6f507437e.zip
sjcl-221c6edd91b06660694f377d9b63d5a6f507437e.tar.gz
sjcl-221c6edd91b06660694f377d9b63d5a6f507437e.tar.bz2
make tests work in nodejs.
Diffstat (limited to 'test/codec_arraybuffer_test.js')
-rw-r--r--test/codec_arraybuffer_test.js33
1 files changed, 14 insertions, 19 deletions
diff --git a/test/codec_arraybuffer_test.js b/test/codec_arraybuffer_test.js
index f2d0950..3bec743 100644
--- a/test/codec_arraybuffer_test.js
+++ b/test/codec_arraybuffer_test.js
@@ -1,23 +1,21 @@
//Run using phantomjs, since rhino doesn't support array buffers, and node has an issue with create dataviews with a bytelength of 0
-sjcl = require("../sjcl.js")
-
-console.log("Running ArrayBuffer Codec tests")
-var start_time = +(new Date())
+console.log("Running ArrayBuffer Codec tests");
+var start_time = +(new Date());
//This ccm implementation is only defined for IV Lengths of 8 bytes
-var test_bytes = []
+var test_bytes = [];
var zeropad_hex = function(number){
- var hex = number.toString(16)
+ var hex = number.toString(16);
while ( hex.length%2 != 0 ){
hex = "0"+hex;
}
- return hex
-}
+ return hex;
+};
for (var i = 0; i <= 0xffff; i++){
- test_bytes.push(zeropad_hex(i))
+ test_bytes.push(zeropad_hex(i));
}
@@ -25,17 +23,14 @@ test_bytes.map(function(test_byte, index){
var bitArray = sjcl.codec.hex.toBits(test_byte),
arrayBuffer = sjcl.codec.arrayBuffer.fromBits(bitArray, false),
roundTripArrayBuffer = sjcl.codec.arrayBuffer.toBits(arrayBuffer),
- roundTripHex = sjcl.codec.hex.fromBits(roundTripArrayBuffer)
+ roundTripHex = sjcl.codec.hex.fromBits(roundTripArrayBuffer);
if (roundTripHex !== test_byte){
- console.error("Failed test, expected ",roundTripHex,"to be",test_byte)
- console.error("Failed at: "+i)
- phantom.exit(1)
+ console.error("Failed test, expected ",roundTripHex,"to be",test_byte);
+ console.error("Failed at: "+i);
+ phantom.exit(1);
}
-})
-
-var total_time = parseInt(+(new Date())-start_time)
-console.log(" + passed all",test_bytes.length,"tests. ("+ total_time, "ms)")
-
-phantom.exit()
+});
+var total_time = parseInt(+(new Date())-start_time);
+console.log(" + passed all",test_bytes.length,"tests. ("+ total_time, "ms)"); \ No newline at end of file