clean of string stream added (we still need <script> objects clean)
[xynt.git] / web / test-commons.php
1 <html>
2 <head>
3 <script type="text/javascript" src="xynt/xynt-commons.js"></script>
4 <script type="text/javascript" src="xynt/xynt-console.js"></script>
5      <script type="text/javascript"><!--
6
7 function test_item(ins, nms, vls, out)
8 {
9     this.in  = ins;
10     this.nm  = nms;
11     this.vl  = vls;
12     this.out = out;
13 }
14
15 test_item.prototype = {
16 in: null,
17 nm: null,
18 vl: null,
19 out: null
20 };
21  
22     window.onload = function () 
23     {
24         var i, test_items;
25
26         test_items = new Array( new test_item("http://www.pippo.com", "assoli", "new_value", "http://www.pippo.com?assoli=new_value"),
27                                 new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
28                                         "assoli", "new_value",
29                                               "http://www.example.com/pippo/pluto.php?asso=1&assoli=new_value&assolino=3"),
30                                 new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
31                                               "bossoli", "new_value",
32                                               "http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3&bossoli=new_value"),
33
34                                 new test_item("http://www.pippo.com", "assoli", "new_value_&_with_ampersand", "http://www.pippo.com?assoli=new_value_%26_with_ampersand"),
35                                 new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
36                                         "assoli", "new_value_&_with_ampersand",
37                                               "http://www.example.com/pippo/pluto.php?asso=1&assoli=new_value_%26_with_ampersand&assolino=3"),
38                                 new test_item("http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3",
39                                               "bossoli", "new_value_&_with_ampersand",
40                                               "http://www.example.com/pippo/pluto.php?asso=1&assoli=2&assolino=3&bossoli=new_value_%26_with_ampersand"),
41                                 new test_item("http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5", "st", "-1", "http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5&st=-1"),
42                                 new test_item("http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5&st=-1", "st", "15", "http://dodo.birds.lan/xynt/test-hs-rd.php?sess=51583d21b104d28eac58b59f310499e5&st=15")
43                  
44                                 );
45
46         for (i = 0 ; i < test_items.length ; i++) {
47             $('cont').innerHTML += i+"<br>";
48             $('cont').innerHTML += "original: "+test_items[i].in+"<br>";
49             $('cont').innerHTML += "name: ["+ test_items[i].nm + "]  value: ["+test_items[i].vl+"]<br>";
50             ret = url_append_arg(test_items[i].in, test_items[i].nm, test_items[i].vl);
51             $('cont').innerHTML += "result: "+ret+"<br>";
52             if (ret != test_items[i].out) {
53                 break;
54             }
55             $('cont').innerHTML += "<hr>";
56         }
57
58         if (i < test_items.length) {
59             $('cont').innerHTML += "<b>ERROR AT: "+i+"</b><br>";
60         }
61         else {
62             $('cont').innerHTML += "<b>TEST SUCCESS</b><br>";
63         }
64     }
65        
66 //-->
67         </script>
68      </head>
69      <body>
70      <div id="cont"></div>
71      </body>
72      </html>
73