ascii85.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. if (!dojo._hasResource["dojox.encoding.tests.ascii85"]) { // _hasResource
  2. // checks added by
  3. // build. Do not use
  4. // _hasResource
  5. // directly in your
  6. // code.
  7. dojo._hasResource["dojox.encoding.tests.ascii85"] = true;
  8. dojo.provide("dojox.encoding.tests.ascii85");
  9. dojo.require("dojox.encoding.ascii85");
  10. (function() {
  11. var msg1 = "The rain in Spain falls mainly on the plain.";
  12. var msg2 = "The rain in Spain falls mainly on the plain.1";
  13. var msg3 = "The rain in Spain falls mainly on the plain.ab";
  14. var msg4 = "The rain in Spain falls mainly on the plain.!@#";
  15. var dca = dojox.encoding.ascii85;
  16. var s2b = function(s) {
  17. var b = [];
  18. for (var i = 0; i < s.length; ++i) {
  19. b.push(s.charCodeAt(i));
  20. }
  21. return b;
  22. };
  23. var b2s = function(b) {
  24. var s = [];
  25. dojo.forEach(b, function(c) {
  26. s.push(String.fromCharCode(c));
  27. });
  28. return s.join("");
  29. };
  30. tests.register("dojox.encoding.tests.ascii85", [function testMsg1(t) {
  31. t.assertEqual(msg1, b2s(dca.decode(dca.encode(s2b(msg1)))));
  32. }, function testMsg2(t) {
  33. t.assertEqual(msg2, b2s(dca.decode(dca.encode(s2b(msg2)))));
  34. }, function testMsg3(t) {
  35. t.assertEqual(msg3, b2s(dca.decode(dca.encode(s2b(msg3)))));
  36. }, function testMsg4(t) {
  37. t.assertEqual(msg4, b2s(dca.decode(dca.encode(s2b(msg4)))));
  38. }]);
  39. })();
  40. }