source: tmcsimulator/trunk/test/tmcsim/highwaymodel/TrafficEventTest.java @ 422

Revision 422, 2.3 KB checked in by jdalbey, 7 years ago (diff)

Remove ATMS functionality. Reworked and simplified the Highway model to use only VDS data from PeMS. Updated all unit tests.

Line 
1
2package tmcsim.highwaymodel;
3
4import tmcsim.highwaymodel.TrafficEvent;
5import java.text.ParseException;
6import java.util.PriorityQueue;
7import junit.framework.TestCase;
8
9/**
10 *
11 * @author jdalbey
12 */
13public class TrafficEventTest extends TestCase
14{
15   
16    public TrafficEventTest(String testName)
17    {
18        super(testName);
19    }
20   
21    @Override
22    protected void setUp() throws Exception
23    {
24        super.setUp();
25    }
26   
27    @Override
28    protected void tearDown() throws Exception
29    {
30        super.tearDown();
31    }
32
33    /**
34     * Test of compareTo method, of class TrafficEvent.
35     */
36    public void testCompareTo() throws ParseException
37    {
38        System.out.println("compareTo");
39        TrafficEvent alpha = new TrafficEvent("181 00:01:30 405 S 0.6 11.0 G");
40        TrafficEvent beta  = new TrafficEvent("181 00:12:30 405 S 0.6 11.0 G");
41        TrafficEvent charly  = new TrafficEvent("181 00:22:00 5 S 0.6 11.0 G");
42        assertEquals(-1, alpha.compareTo(beta));
43        assertEquals(1, charly.compareTo(beta));
44        assertEquals(0, beta.compareTo(beta));
45    }
46    public void testCompare2() throws ParseException
47    {
48        System.out.println("compareTo");
49        TrafficEvent alpha = new TrafficEvent(" 187   00:00:07  55      S         6.88     0.2      Y");
50        TrafficEvent beta  = new TrafficEvent(" 187   00:01:37  55      S         6.88     0.2      R");
51        TrafficEvent charly  = new TrafficEvent("191   02:49:02  73      S         27.20    0.8      G");
52        assertEquals(-1, alpha.compareTo(beta));
53        assertEquals(1, charly.compareTo(beta));
54        assertEquals(0, beta.compareTo(beta));
55    }
56    public void testQueue() throws ParseException
57    {
58        System.out.println("compareTo");
59        TrafficEvent alpha = new TrafficEvent(" 187   00:00:07  55      S         6.88     0.2      Y");
60        TrafficEvent beta  = new TrafficEvent(" 187   00:01:37  55      S         6.88     0.2      R");
61        TrafficEvent charly  = new TrafficEvent("191   02:49:02  73      S         27.20    0.8      G");
62        PriorityQueue<TrafficEvent> q = new PriorityQueue<TrafficEvent>();
63        q.add(charly);
64        q.add(beta);
65        q.add(alpha);
66        assertEquals(alpha, q.poll());
67        assertEquals(beta, q.poll());
68        assertEquals(charly, q.poll());
69    }
70   
71}
Note: See TracBrowser for help on using the repository browser.