1
2 package org.drools.reteoo.impl;
3
4 import junit.framework.TestCase;
5
6 public class PriorityQueueTest extends TestCase
7 {
8 public PriorityQueueTest(String name)
9 {
10 super( name );
11 }
12
13 public void setUp()
14 {
15 }
16
17 public void tearDown()
18 {
19 }
20
21 public void testSequential()
22 {
23 PriorityQueue q = new PriorityQueue();
24
25 q.add( "one",
26 1 );
27
28 q.add( "two",
29 2 );
30
31 q.add( "three",
32 3 );
33
34 assertEquals( "one",
35 q.removeFirst() );
36
37 assertEquals( "two",
38 q.removeFirst() );
39
40 assertEquals( "three",
41 q.removeFirst() );
42 }
43
44 public void testReverse()
45 {
46 PriorityQueue q = new PriorityQueue();
47
48 q.add( "three",
49 3 );
50
51 q.add( "two",
52 2 );
53
54 q.add( "one",
55 1 );
56
57 assertEquals( "one",
58 q.removeFirst() );
59
60 assertEquals( "two",
61 q.removeFirst() );
62
63 assertEquals( "three",
64 q.removeFirst() );
65 }
66
67 public void testDuplicates()
68 {
69 PriorityQueue q = new PriorityQueue();
70
71 q.add( "one",
72 1 );
73
74 q.add( "two",
75 1 );
76
77 q.add( "three",
78 1 );
79
80 assertEquals( "one",
81 q.removeFirst() );
82
83 assertEquals( "two",
84 q.removeFirst() );
85
86 assertEquals( "three",
87 q.removeFirst() );
88 }
89 }
This page was automatically generated by Maven