| 1 | dojo.provide("dojox.collections.tests.ArrayList"); |
| 2 | dojo.require("dojox.collections.ArrayList"); |
| 3 | |
| 4 | tests.register("dojox.collections.tests.ArrayList", [ |
| 5 | function testCtor(t){ |
| 6 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 7 | t.assertEqual(4, al.count); |
| 8 | }, |
| 9 | function testAdd(t){ |
| 10 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 11 | al.add("carp"); |
| 12 | t.assertEqual("foo,bar,test,bull,carp", al.toString()); |
| 13 | al.addRange(["oof","rab"]); |
| 14 | t.assertEqual("foo,bar,test,bull,carp,oof,rab", al.toString()); |
| 15 | }, |
| 16 | function testClear(t){ |
| 17 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 18 | al.clear(); |
| 19 | t.assertEqual(0, al.count); |
| 20 | }, |
| 21 | function testClone(t){ |
| 22 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 23 | var cloned=al.clone(); |
| 24 | t.assertEqual(al.toString(), cloned.toString()); |
| 25 | }, |
| 26 | function testContains(t){ |
| 27 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 28 | t.assertTrue(al.contains("bar")); |
| 29 | t.assertFalse(al.contains("faz")); |
| 30 | }, |
| 31 | function testGetIterator(t){ |
| 32 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 33 | var itr=al.getIterator(); |
| 34 | while(!itr.atEnd()){ |
| 35 | itr.get(); |
| 36 | } |
| 37 | t.assertEqual("bull", itr.element); |
| 38 | }, |
| 39 | function testIndexOf(t){ |
| 40 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 41 | t.assertEqual(1, al.indexOf("bar")); |
| 42 | }, |
| 43 | function testInsert(t){ |
| 44 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 45 | al.insert(2, "baz"); |
| 46 | t.assertEqual(2, al.indexOf("baz")); |
| 47 | }, |
| 48 | function testItem(t){ |
| 49 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 50 | t.assertEqual("test", al.item(2)); |
| 51 | }, |
| 52 | function testRemove(t){ |
| 53 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 54 | al.remove("bar"); |
| 55 | t.assertEqual("foo,test,bull", al.toString()); |
| 56 | t.assertEqual(3, al.count); |
| 57 | }, |
| 58 | function testRemoveAt(t){ |
| 59 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 60 | al.removeAt(3); |
| 61 | t.assertEqual("foo,bar,test", al.toString()); |
| 62 | t.assertEqual(3, al.count); |
| 63 | }, |
| 64 | function testReverse(t){ |
| 65 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 66 | al.reverse(); |
| 67 | t.assertEqual("bull,test,bar,foo", al.toString()); |
| 68 | }, |
| 69 | function testSort(t){ |
| 70 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 71 | al.sort(); |
| 72 | t.assertEqual("bar,bull,foo,test", al.toString()); |
| 73 | }, |
| 74 | function testToArray(t){ |
| 75 | var al=new dojox.collections.ArrayList(["foo","bar","test","bull"]); |
| 76 | var a=al.toArray(); |
| 77 | t.assertEqual(a.join(","), al.toString()); |
| 78 | } |
| 79 | ]); |