1 | dojo.provide("dojox.collections.tests.Queue"); |
---|
2 | dojo.require("dojox.collections.Queue"); |
---|
3 | |
---|
4 | tests.register("dojox.collections.tests.Queue", [ |
---|
5 | function testCtor(t){ |
---|
6 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
7 | t.assertEqual(4, q.count); |
---|
8 | }, |
---|
9 | function testClear(t){ |
---|
10 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
11 | q.clear(); |
---|
12 | t.assertEqual(0, q.count); |
---|
13 | }, |
---|
14 | function testClone(t){ |
---|
15 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
16 | var cloned=q.clone(); |
---|
17 | t.assertEqual(q.count, cloned.count); |
---|
18 | t.assertEqual(q.toArray().join(), cloned.toArray().join()); |
---|
19 | }, |
---|
20 | function testContains(t){ |
---|
21 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
22 | t.assertTrue(q.contains("bar")); |
---|
23 | t.assertFalse(q.contains("faz")); |
---|
24 | }, |
---|
25 | function testGetIterator(t){ |
---|
26 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
27 | var itr=q.getIterator(); |
---|
28 | while(!itr.atEnd()){ itr.get(); } |
---|
29 | t.assertEqual("bull", itr.element); |
---|
30 | }, |
---|
31 | function testPeek(t){ |
---|
32 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
33 | t.assertEqual("foo", q.peek()); |
---|
34 | }, |
---|
35 | function testDequeue(t){ |
---|
36 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
37 | t.assertEqual("foo", q.dequeue()); |
---|
38 | t.assertEqual("bar,test,bull", q.toArray().join(",")); |
---|
39 | }, |
---|
40 | function testEnqueue(t){ |
---|
41 | var q=new dojox.collections.Queue(["foo","bar","test","bull"]); |
---|
42 | q.enqueue("bull"); |
---|
43 | t.assertEqual("bull", q.toArray().pop()); |
---|
44 | } |
---|
45 | ]); |
---|