1 package hudson.model; 2 3 import junit.framework.TestCase; 4 import hudson.model.Fingerprint.RangeSet; 5 6 9 public class FingerprintTest extends TestCase { 10 public void test() { 11 RangeSet rs = new RangeSet(); 12 assertFalse(rs.includes(0)); 13 assertFalse(rs.includes(3)); 14 assertFalse(rs.includes(5)); 15 16 rs.add(3); 17 assertFalse(rs.includes(2)); 18 assertTrue(rs.includes(3)); 19 assertFalse(rs.includes(4)); 20 assertEquals("[3,4)",rs.toString()); 21 22 rs.add(4); 23 assertFalse(rs.includes(2)); 24 assertTrue(rs.includes(3)); 25 assertTrue(rs.includes(4)); 26 assertFalse(rs.includes(5)); 27 assertEquals("[3,5)",rs.toString()); 28 29 rs.add(10); 30 assertEquals("[3,5),[10,11)",rs.toString()); 31 32 rs.add(9); 33 assertEquals("[3,5),[9,11)",rs.toString()); 34 35 rs.add(6); 36 assertEquals("[3,5),[6,7),[9,11)",rs.toString()); 37 38 rs.add(5); 39 assertEquals("[3,7),[9,11)",rs.toString()); 40 } 41 42 public void testMerge() { 43 RangeSet x = new RangeSet(); 44 x.add(1); 45 x.add(2); 46 x.add(3); 47 x.add(5); 48 x.add(6); 49 assertEquals("[1,4),[5,7)",x.toString()); 50 51 RangeSet y = new RangeSet(); 52 y.add(3); 53 y.add(4); 54 y.add(5); 55 assertEquals("[3,6)",y.toString()); 56 57 x.add(y); 58 assertEquals("[1,7)",x.toString()); 59 } 60 61 public void testMerge2() { 62 RangeSet x = new RangeSet(); 63 x.add(1); 64 x.add(2); 65 x.add(5); 66 x.add(6); 67 assertEquals("[1,3),[5,7)",x.toString()); 68 69 RangeSet y = new RangeSet(); 70 y.add(3); 71 y.add(4); 72 assertEquals("[3,5)",y.toString()); 73 74 x.add(y); 75 assertEquals("[1,7)",x.toString()); 76 } 77 78 public void testMerge3() { 79 RangeSet x = new RangeSet(); 80 x.add(1); 81 x.add(5); 82 assertEquals("[1,2),[5,6)",x.toString()); 83 84 RangeSet y = new RangeSet(); 85 y.add(3); 86 y.add(5); 87 y.add(7); 88 assertEquals("[3,4),[5,6),[7,8)",y.toString()); 89 90 x.add(y); 91 assertEquals("[1,2),[3,4),[5,6),[7,8)",x.toString()); 92 } 93 } 94 | Popular Tags |