Changeset 15745 in josm for trunk/test/unit
- Timestamp:
- 2020-01-22T00:30:33+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/AddressesTest.java
r15043 r15745 58 58 @Test 59 59 public void testHouseNumberWithoutStreet() { 60 assertNull(doTestHouseNumberWithoutStreet( 61 "", null, null)); 62 assertNotNull(doTestHouseNumberWithoutStreet( 63 "addr:housenumber=1", null, null)); 64 assertNull(doTestHouseNumberWithoutStreet( 65 "addr:housenumber=1 addr:street=Foo", null, null)); 66 assertNull(doTestHouseNumberWithoutStreet( 67 "addr:housenumber=1 addr:place=Foo", null, null)); 68 assertNull(doTestHouseNumberWithoutStreet( 69 "addr:housenumber=1 addr:neighbourhood=Foo", null, null)); 70 assertNotNull(doTestHouseNumberWithoutStreet( 71 "addr:housenumber=1", null, "type=enforcement")); 72 assertNull(doTestHouseNumberWithoutStreet( 73 "addr:housenumber=1", null, "type=associatedStreet")); 74 assertNotNull(doTestHouseNumberWithoutStreet( 75 "addr:housenumber=1", "building=yes", null)); 76 assertNull(doTestHouseNumberWithoutStreet( 77 "addr:housenumber=1", "addr:interpolation=odd addr:street=Foo", null)); 60 assertNull(doTestHouseNumberWithoutStreet("", null, null)); 61 assertNotNull(doTestHouseNumberWithoutStreet("addr:housenumber=1", null, null)); 62 assertNull(doTestHouseNumberWithoutStreet("addr:housenumber=1 addr:street=Foo", null, null)); 63 assertNull(doTestHouseNumberWithoutStreet("addr:housenumber=1 addr:place=Foo", null, null)); 64 assertNull(doTestHouseNumberWithoutStreet("addr:housenumber=1 addr:neighbourhood=Foo", null, null)); 65 assertNotNull(doTestHouseNumberWithoutStreet("addr:housenumber=1", null, "type=enforcement")); 66 assertNull(doTestHouseNumberWithoutStreet("addr:housenumber=1", null, "type=associatedStreet")); 67 assertNotNull(doTestHouseNumberWithoutStreet("addr:housenumber=1", "building=yes", null)); 68 assertNull( 69 doTestHouseNumberWithoutStreet("addr:housenumber=1", "addr:interpolation=odd addr:street=Foo", null)); 78 70 } 79 71 80 private static void doTestDuplicateHouseNumber( 81 S tring tags1, LatLon ll1, String tags2, LatLon ll2, Severity expected) {72 private static void doTestDuplicateHouseNumber(String tags1, LatLon ll1, String tags2, LatLon ll2, 73 Severity expected) { 82 74 DataSet ds = new DataSet(); 83 Node n1 = TestUtils.newNode(tags1); n1.setCoor(ll1); ds.addPrimitive(n1); 84 Node n2 = TestUtils.newNode(tags2); n2.setCoor(ll2); ds.addPrimitive(n2); 75 Node n1 = TestUtils.newNode(tags1); 76 n1.setCoor(ll1); 77 ds.addPrimitive(n1); 78 Node n2 = TestUtils.newNode(tags2); 79 n2.setCoor(ll2); 80 ds.addPrimitive(n2); 85 81 List<TestError> errors = new Addresses().checkForDuplicate(n2); 86 82 assertEquals(expected != null ? 1 : 0, errors.size()); … … 108 104 doTestDuplicateHouseNumber(num1, ZERO, num2, ZERO, null); 109 105 // Info for same address in different cities, warning if same city 110 doTestDuplicateHouseNumber(num1+city1, ZERO, num1+city2, ZERO, Severity.OTHER); 111 doTestDuplicateHouseNumber(num1+city1, ZERO, num1+city1, ZERO, Severity.WARNING); 112 // Info for same address in same city but different suburbs, warning if same suburb 113 doTestDuplicateHouseNumber(num1+city1+suburb1, ZERO, num1+city1+suburb2, ZERO, Severity.OTHER); 114 doTestDuplicateHouseNumber(num1+city1+suburb1, ZERO, num1+city1+suburb1, ZERO, Severity.WARNING); 106 doTestDuplicateHouseNumber(num1 + city1, ZERO, num1 + city2, ZERO, Severity.OTHER); 107 doTestDuplicateHouseNumber(num1 + city1, ZERO, num1 + city1, ZERO, Severity.WARNING); 108 // Info for same address in same city but different suburbs, warning if same 109 // suburb 110 doTestDuplicateHouseNumber(num1 + city1 + suburb1, ZERO, num1 + city1 + suburb2, ZERO, Severity.OTHER); 111 doTestDuplicateHouseNumber(num1 + city1 + suburb1, ZERO, num1 + city1 + suburb1, ZERO, Severity.WARNING); 112 } 113 114 /** 115 * Unit test of {@link Addresses#expandHouseNumber} 116 */ 117 @Test 118 public void testMultiAddressDuplicates() { 119 String num1 = "addr:housenumber=1,3 addr:street=Foo"; 120 String num2 = "addr:housenumber=1 addr:street=Foo"; 121 String num3 = "addr:housenumber=3 addr:street=Foo"; 122 String num4 = "addr:housenumber=4 addr:street=Foo"; 123 124 doTestDuplicateHouseNumber(num1, ZERO, num2, ZERO, Severity.WARNING); 125 doTestDuplicateHouseNumber(num1, ZERO, num3, ZERO, Severity.WARNING); 126 doTestDuplicateHouseNumber(num1, ZERO, num4, ZERO, null); 127 128 num1 = num1.replace(",", ";"); 129 130 doTestDuplicateHouseNumber(num1, ZERO, num2, ZERO, Severity.WARNING); 131 doTestDuplicateHouseNumber(num1, ZERO, num3, ZERO, Severity.WARNING); 132 doTestDuplicateHouseNumber(num1, ZERO, num4, ZERO, null); 115 133 } 116 134 }
Note:
See TracChangeset
for help on using the changeset viewer.