aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/encoding/tests/bits.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
commit1c5685d68f1b73270fb814fe04cbb490eb90ba5f (patch)
tree3d3ada08a934b96fc31531f1327690d7edc6f766 /includes/js/dojox/encoding/tests/bits.js
parent104d59099e048688c4dbac37d72137006e396558 (diff)
downloadsemanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.gz
semanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.bz2
Minor fix: Remove DOJO library (60Mo) replaced by link to Google CDN (online DOJO library)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@159 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/encoding/tests/bits.js')
-rw-r--r--includes/js/dojox/encoding/tests/bits.js74
1 files changed, 0 insertions, 74 deletions
diff --git a/includes/js/dojox/encoding/tests/bits.js b/includes/js/dojox/encoding/tests/bits.js
deleted file mode 100644
index dc7ae66..0000000
--- a/includes/js/dojox/encoding/tests/bits.js
+++ /dev/null
@@ -1,74 +0,0 @@
-if(!dojo._hasResource["dojox.encoding.tests.bits"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["dojox.encoding.tests.bits"] = true;
-dojo.provide("dojox.encoding.tests.bits");
-dojo.require("dojox.encoding.bits");
-
-(function(){
- var msg1 = "The rain in Spain falls mainly on the plain.";
- var msg2 = "The rain in Spain falls mainly on the plain.1";
- var msg3 = "The rain in Spain falls mainly on the plain.ab";
- var msg4 = "The rain in Spain falls mainly on the plain.!@#";
- var dcb = dojox.encoding.bits;
-
- var s2b = function(s){
- var b = [];
- for(var i = 0; i < s.length; ++i){
- b.push(s.charCodeAt(i));
- }
- return b;
- };
-
- var b2s = function(b){
- var s = [];
- dojo.forEach(b, function(c){ s.push(String.fromCharCode(c)); });
- return s.join("");
- };
-
- var testOut = function(msg){
- var a = new dojox.encoding.bits.OutputStream();
- for(var i = 0; i < msg.length; ++i){
- var v = msg.charCodeAt(i);
- var j = Math.floor(Math.random() * 7) + 1;
- a.putBits(v >>> (8 - j), j);
- a.putBits(v, 8 - j);
- }
- return b2s(a.getBuffer());
- };
-
- var testIn = function(msg){
- var a = new dojox.encoding.bits.InputStream(s2b(msg), msg.length * 8);
- var r = [];
- for(var i = 0; i < msg.length; ++i){
- var j = Math.floor(Math.random() * 7) + 1;
- r.push((a.getBits(j) << (8 - j)) | a.getBits(8 - j));
- }
- return b2s(r);
- };
-
- var test = function(msg){
- var a = new dojox.encoding.bits.InputStream(s2b(msg), msg.length * 8);
- var o = new dojox.encoding.bits.OutputStream();
- while(a.getWidth() > 0){
- var w = Math.min(a.getWidth(), 3);
- o.putBits(a.getBits(w), w);
- }
- return b2s(o.getBuffer());
- };
-
- tests.register("dojox.encoding.tests.bits", [
- function testBitsOut1(t){ t.assertEqual(msg1, testOut(msg1)); },
- function testBitsOut2(t){ t.assertEqual(msg2, testOut(msg2)); },
- function testBitsOut3(t){ t.assertEqual(msg3, testOut(msg3)); },
- function testBitsOut4(t){ t.assertEqual(msg4, testOut(msg4)); },
- function testBitsIn1(t){ t.assertEqual(msg1, testIn(msg1)); },
- function testBitsIn2(t){ t.assertEqual(msg2, testIn(msg2)); },
- function testBitsIn3(t){ t.assertEqual(msg3, testIn(msg3)); },
- function testBitsIn4(t){ t.assertEqual(msg4, testIn(msg4)); },
- function testBits1(t){ t.assertEqual(msg1, test(msg1)); },
- function testBits2(t){ t.assertEqual(msg2, test(msg2)); },
- function testBits3(t){ t.assertEqual(msg3, test(msg3)); },
- function testBits4(t){ t.assertEqual(msg4, test(msg4)); }
- ]);
-})();
-
-}