From 26476d2bd113da46c08bb99cb298f923267be88f Mon Sep 17 00:00:00 2001 From: "Jesper K. Pedersen" Date: Wed, 15 May 2013 10:46:54 +0200 Subject: make it possible to compare arrays from the C++ side Change-Id: I3cb0ae4c3648a4c61e5e2bbe1cca442814ee5161 Reviewed-by: Nicolas Arnaud-Cormos --- tests/test.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/test.js b/tests/test.js index 5202f5c..960c5d8 100644 --- a/tests/test.js +++ b/tests/test.js @@ -1,6 +1,7 @@ var TEST_JS_LOADED // Purposfully left undefined - this is to avoid the global variables being loaded more than once if (TEST_JS_LOADED == undefined) { TEST_JS_LOADED = true + // Set to true to print out every single comparison var verbose = false @@ -25,21 +26,40 @@ if (TEST_JS_LOADED == undefined) { } } - function compare(act, exp, message) { + function logCompare(act,exp,message) { if ( verbose ) { if ( message != undefined ) console.log("comparing(" + message + ") " + act + " with " + exp) else console.log("comparing " + act + " with " + exp) } - if (act != exp) { - if ( message != undefined ) - error("Compare failed (" + message +"): actual=" + act + " expected=" + exp) - else - error("Compare failed: actual=" + act + " expected=" + exp) + } + + function failCompare(act,exp,message) { + if ( message != undefined ) + error("Compare failed (" + message +"): actual=" + act + " expected=" + exp) + else + error("Compare failed: actual=" + act + " expected=" + exp) + } + + function compareArrays(act, exp, message) { + logCompare(act,exp,message) + if (act.length != exp.length) + failCompare(act,exp,message) + for (var i=0; i