Commit | Line | Data |
---|---|---|
1f506a43 FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.event; | |
14 | ||
28b94d61 | 15 | import junit.framework.TestCase; |
1f506a43 FC |
16 | |
17 | /** | |
18 | * <b><u>TmfTimeRangeTest</u></b> | |
19 | * <p> | |
28b94d61 | 20 | * TODO: Implement me. Please. |
1f506a43 | 21 | */ |
28b94d61 FC |
22 | public class TmfTimeRangeTest extends TestCase { |
23 | ||
24 | // ======================================================================== | |
25 | // Housekeeping | |
26 | // ======================================================================== | |
27 | ||
28 | public TmfTimeRangeTest(String name) { | |
29 | super(name); | |
30 | } | |
31 | ||
32 | @Override | |
33 | protected void setUp() throws Exception { | |
34 | super.setUp(); | |
35 | } | |
36 | ||
37 | @Override | |
38 | protected void tearDown() throws Exception { | |
39 | super.tearDown(); | |
40 | } | |
41 | ||
42 | // ======================================================================== | |
43 | // Constructors | |
44 | // ======================================================================== | |
45 | ||
46 | public void testConstructor() throws Exception { | |
47 | TmfTimestamp ts1 = new TmfTimestamp(12345); | |
48 | TmfTimestamp ts2 = new TmfTimestamp(12350); | |
49 | TmfTimeRange range = new TmfTimeRange(ts1, ts2); | |
50 | assertEquals("startTime", ts1, range.getStartTime()); | |
51 | assertEquals("endTime", ts2, range.getEndTime()); | |
52 | } | |
53 | ||
54 | public void testOpenRange1() throws Exception { | |
55 | TmfTimestamp ts2 = new TmfTimestamp(12350); | |
56 | TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, ts2); | |
57 | assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime()); | |
58 | assertEquals("endTime", ts2, range.getEndTime()); | |
59 | } | |
60 | ||
61 | public void testOpenRange2() throws Exception { | |
62 | TmfTimestamp ts1 = new TmfTimestamp(12345); | |
63 | TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BigCrunch); | |
64 | assertEquals("startTime", ts1, range.getStartTime()); | |
65 | assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime()); | |
66 | } | |
67 | ||
68 | public void testOpenRange3() throws Exception { | |
69 | TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch); | |
70 | assertEquals("startTime", TmfTimestamp.BigBang, range.getStartTime()); | |
71 | assertEquals("endTime", TmfTimestamp.BigCrunch, range.getEndTime()); | |
72 | } | |
73 | ||
74 | // ======================================================================== | |
75 | // contains | |
76 | // ======================================================================== | |
77 | ||
78 | public void testContains() throws Exception { | |
79 | TmfTimestamp ts1 = new TmfTimestamp(12345); | |
80 | TmfTimestamp ts2 = new TmfTimestamp(12350); | |
81 | TmfTimeRange range = new TmfTimeRange(ts1, ts2); | |
82 | ||
83 | assertTrue("contains (lower bound)", range.contains(new TmfTimestamp(12345))); | |
84 | assertTrue("contains (higher bound)", range.contains(new TmfTimestamp(12350))); | |
85 | assertTrue("contains (within bounds)", range.contains(new TmfTimestamp(12346))); | |
86 | ||
87 | assertFalse("contains (low value)", range.contains(new TmfTimestamp(12340))); | |
88 | assertFalse("contains (high value)", range.contains(new TmfTimestamp(12351))); | |
89 | } | |
90 | ||
91 | // ======================================================================== | |
92 | // toString | |
93 | // ======================================================================== | |
94 | ||
95 | public void testToString() throws Exception { | |
96 | TmfTimestamp ts1 = new TmfTimestamp(12345); | |
97 | TmfTimestamp ts2 = new TmfTimestamp(12350); | |
98 | TmfTimeRange range = new TmfTimeRange(ts1, ts2); | |
1f506a43 | 99 | |
28b94d61 FC |
100 | String expected = "[TmfTimeRange(" + ts1.toString() + ":" + ts2.toString() + ")]"; |
101 | assertEquals("toString", expected, range.toString()); | |
102 | } | |
103 | ||
1f506a43 | 104 | } |