687e5bdbdcdd54ac5680a20d71b90b78df60924d.svn-base 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. if (!dojo._hasResource["dojox.encoding.tests.easy64"]) { // _hasResource
  2. // checks added by
  3. // build. Do not use
  4. // _hasResource
  5. // directly in your
  6. // code.
  7. dojo._hasResource["dojox.encoding.tests.easy64"] = true;
  8. dojo.provide("dojox.encoding.tests.easy64");
  9. dojo.require("dojox.encoding.easy64");
  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 dce = dojox.encoding.easy64;
  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.easy64", [
  31. function testEasyMsg1(t) {
  32. t.assertEqual(msg1, b2s(dce.decode(dce.encode(s2b(msg1)))));
  33. }, function testEasyMsg2(t) {
  34. t.assertEqual(msg2, b2s(dce.decode(dce.encode(s2b(msg2)))));
  35. }, function testEasyMsg3(t) {
  36. t.assertEqual(msg3, b2s(dce.decode(dce.encode(s2b(msg3)))));
  37. }, function testEasyMsg4(t) {
  38. t.assertEqual(msg4, b2s(dce.decode(dce.encode(s2b(msg4)))));
  39. }]);
  40. })();
  41. }