1/*
2 * Copyright 2012 AndroidPlot.com
3 *
4 *    Licensed under the Apache License, Version 2.0 (the "License");
5 *    you may not use this file except in compliance with the License.
6 *    You may obtain a copy of the License at
7 *
8 *        http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *    Unless required by applicable law or agreed to in writing, software
11 *    distributed under the License is distributed on an "AS IS" BASIS,
12 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *    See the License for the specific language governing permissions and
14 *    limitations under the License.
15 */
16
17package com.androidplot;
18
19import org.junit.After;
20import org.junit.Before;
21import org.junit.Test;
22import static org.junit.Assert.assertEquals;
23import static org.junit.Assert.assertFalse;
24import static org.junit.Assert.assertTrue;
25
26public class LineRegionTest {
27    @Before
28    public void setUp() throws Exception {
29
30    }
31
32    @After
33    public void tearDown() throws Exception {
34
35    }
36
37    @Test
38    public void testConstructor() throws Exception {
39        LineRegion lr = new LineRegion(0d, 0d);
40        assertEquals(0d, lr.getMinVal());
41        assertEquals(0d, lr.getMaxVal());
42
43        lr = new LineRegion(1.5d, -2d);
44        assertEquals(-2d, lr.getMinVal());
45        assertEquals(1.5d, lr.getMaxVal());
46
47        lr = new LineRegion(10d, 20d);
48        assertEquals(10d, lr.getMinVal());
49        assertEquals(20d, lr.getMaxVal());
50    }
51
52
53    @Test
54    public void testContains() throws Exception {
55
56    }
57
58    @Test
59    public void testIntersects() throws Exception {
60        LineRegion line1 = new LineRegion(1, 10);
61        LineRegion line2 = new LineRegion(11, 20);
62        assertFalse(line1.intersects(line2));
63
64        line1.setMaxVal(15);
65        assertTrue(line1.intersects(line2));
66
67        //l1end = 30;
68        line1.setMaxVal(30);
69        assertTrue(line1.intersects(line2));
70
71        //l1start = 21;
72        line1.setMinVal(21);
73        assertFalse(line1.intersects(line2));
74    }
75
76    @Test
77    public void testLength() throws Exception {
78        LineRegion lr = new LineRegion(0, 10);
79        assertEquals(10d, lr.length().doubleValue(), 0);
80
81        lr = new LineRegion(-5, 5);
82        assertEquals(10d, lr.length().doubleValue(), 0);
83    }
84}
85