1 package org.opencv.test.core; 2 3 import org.opencv.core.Range; 4 import org.opencv.test.OpenCVTestCase; 5 6 public class RangeTest extends OpenCVTestCase { 7 8 Range r1; 9 Range r2; 10 Range range; 11 12 @Override setUp()13 protected void setUp() throws Exception { 14 super.setUp(); 15 16 range = new Range(); 17 r1 = new Range(1, 11); 18 r2 = new Range(1, 1); 19 } 20 testAll()21 public void testAll() { 22 range = Range.all(); 23 assertEquals(Integer.MIN_VALUE, range.start); 24 assertEquals(Integer.MAX_VALUE, range.end); 25 } 26 testClone()27 public void testClone() { 28 Range dstRange = new Range(); 29 dstRange = r1.clone(); 30 assertEquals(r1, dstRange); 31 } 32 testEmpty()33 public void testEmpty() { 34 boolean flag; 35 36 flag = r1.empty(); 37 assertFalse(flag); 38 39 flag = r2.empty(); 40 assertTrue(flag); 41 } 42 testEqualsObject()43 public void testEqualsObject() { 44 assertFalse(r2.equals(r1)); 45 46 range = r1.clone(); 47 assertTrue(r1.equals(range)); 48 } 49 testHashCode()50 public void testHashCode() { 51 assertEquals(r1.hashCode(), r1.hashCode()); 52 } 53 testIntersection()54 public void testIntersection() { 55 range = r1.intersection(r2); 56 assertEquals(r2, range); 57 } 58 testRange()59 public void testRange() { 60 range = new Range(); 61 62 assertNotNull(range); 63 assertEquals(0, range.start); 64 assertEquals(0, range.end); 65 } 66 testRangeDoubleArray()67 public void testRangeDoubleArray() { 68 double[] vals = { 2, 4 }; 69 Range r = new Range(vals); 70 71 assertTrue(2 == r.start); 72 assertTrue(4 == r.end); 73 } 74 testRangeIntInt()75 public void testRangeIntInt() { 76 r1 = new Range(12, 13); 77 78 assertNotNull(r1); 79 assertEquals(12, r1.start); 80 assertEquals(13, r1.end); 81 } 82 testSet()83 public void testSet() { 84 double[] vals1 = {}; 85 r1.set(vals1); 86 assertEquals(0, r1.start); 87 assertEquals(0, r1.end); 88 89 double[] vals2 = { 6, 10 }; 90 r2.set(vals2); 91 assertEquals(6, r2.start); 92 assertEquals(10, r2.end); 93 } 94 testShift()95 public void testShift() { 96 int delta = 1; 97 range = range.shift(delta); 98 assertEquals(r2, range); 99 } 100 testSize()101 public void testSize() { 102 assertEquals(10, r1.size()); 103 104 assertEquals(0, r2.size()); 105 } 106 testToString()107 public void testToString() { 108 String actual = r1.toString(); 109 String expected = "[1, 11)"; 110 assertEquals(expected, actual); 111 } 112 113 } 114