public
Description: Fleegix.js provides an extremely lightweight, cross-browser set of JavaScript tools for building dynamic Web-app UIs.
Homepage: http://js.fleegix.org
Clone URL: git://github.com/mde/fleegix-js-javascript-toolkit.git
commit  c3f3468fc6b198035bce0632458bf15bfc9cc3cb
tree    00859ada505979fb6cabc55f6f553c59f09b1866
parent  f7c2afcdd3d62944d3c7b60501135cb429d298ee
100644 48 lines (45 sloc) 2.571 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fleegixMain.test_fleegixString = new function () {
  this.test_escapeXML = function () {
    var str, res, exp;
    // Test each char
    str = '\'"&<>';
    res = fleegix.string.escapeXML(str);
    exp = '&#39;&quot;&amp;&lt;&gt;';
    jum.assertEquals(exp, res);
  };
  this.test_escapeXMLGlobal = function () {
    var str, res, exp;
    // Test for global replace
    str = '\'\'""&&<<>>';
    res = fleegix.string.escapeXML(str);
    exp = '&#39;&#39;&quot;&quot;&amp;&amp;&lt;&lt;&gt;&gt;';
    jum.assertEquals(exp, res);
  };
  this.test_unescapeXML = function () {
    var str, res, exp;
    // Test each char
    str = '&#39;&quot;&amp;&lt;&gt;';
    res = fleegix.string.unescapeXML(str);
    exp = '\'"&<>';
    jum.assertEquals(exp, res);
  };
  this.test_unescapeXMLGlobal = function () {
    var str, res, exp;
    // Test for global replace
    str = '&#39;&#39;&quot;&quot;&amp;&amp;&lt;&lt;&gt;&gt;';
    res = fleegix.string.unescapeXML(str);
    exp = '\'\'""&&<<>>';
    jum.assertEquals(exp, res);
  };
  this.test_fuglyStringRoundTrip = function () {
    var res, exp;
    var fugly = '555_characters_abcdefg hijklmnopqrstuvwxyz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&*()-=+[]{};\':",.<>/?|_cha racters_abcdefghi jklmnopqrstuvwxyz1234567890ABCDEF GHIJKLMNOP QRSTUVWXYZabcdefg hijklmnopqrstuvwx yz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&*()-=+[]{}tuvwxyz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&*()-=+[]{};\':",.<>/?|_cha racters_abcdefghi vwxyz1234567890ABCDEF GHIJKLMNOP QRSTUVWX∆∂ø∑´Z!@#$%^&*()-=+[]{};\':",.<>/?abcdefg hijklmnopqrstuvwxyz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&*()-=+[]{}|Thisisthefinal45charactersinthistexttests_END';
    var fuglyEsc = '555_characters_abcdefg hijklmnopqrstuvwxyz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&amp;*()-=+[]{};&#39;:&quot;,.&lt;&gt;/?|_cha racters_abcdefghi jklmnopqrstuvwxyz1234567890ABCDEF GHIJKLMNOP QRSTUVWXYZabcdefg hijklmnopqrstuvwx yz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&amp;*()-=+[]{}tuvwxyz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&amp;*()-=+[]{};&#39;:&quot;,.&lt;&gt;/?|_cha racters_abcdefghi vwxyz1234567890ABCDEF GHIJKLMNOP QRSTUVWX∆∂ø∑´Z!@#$%^&amp;*()-=+[]{};&#39;:&quot;,.&lt;&gt;/?abcdefg hijklmnopqrstuvwxyz1234567890GHIJKL MNOPQR¢£§£STUVWXYZ!@ #$%^&amp;*()-=+[]{}|Thisisthefinal45charactersinthistexttests_END';
    res = fleegix.string.escapeXML(fugly);
    exp = fuglyEsc;
    jum.assertEquals(exp, res);
    res = fleegix.string.unescapeXML(fuglyEsc);
    exp = fugly;
    jum.assertEquals(exp, res);
  };
};