Changeset 13541 in josm for trunk/test
- Timestamp:
- 2018-03-18T23:36:36+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
r10758 r13541 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.junit.Assert.assertEquals; 3 5 4 6 import java.util.Collections; … … 6 8 import java.util.Map; 7 9 8 import org.junit.Assert;9 10 import org.junit.Rule; 10 11 import org.junit.Test; … … 32 33 s = "\"2 3 4\""; 33 34 s1 = "2 3 4"; 34 Assert.assertEquals(s1, TextTagParser.unescape(s));35 assertEquals(s1, TextTagParser.unescape(s)); 35 36 36 37 s = "\"2 \\\"3\\\" 4\""; 37 38 s1 = "2 \"3\" 4"; 38 Assert.assertEquals(s1, TextTagParser.unescape(s));39 assertEquals(s1, TextTagParser.unescape(s)); 39 40 40 41 s = "\"2 3 ===4===\""; 41 42 s1 = "2 3 ===4==="; 42 Assert.assertEquals(s1, TextTagParser.unescape(s));43 assertEquals(s1, TextTagParser.unescape(s)); 43 44 44 45 s = "\"2 3 \\\\\\\\===4===\""; 45 46 s1 = "2 3 \\\\===4==="; 46 Assert.assertEquals(s1, TextTagParser.unescape(s));47 assertEquals(s1, TextTagParser.unescape(s)); 47 48 } 48 49 … … 57 58 } }; 58 59 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 59 Assert.assertEquals(correctTags, tags);60 assertEquals(correctTags, tags); 60 61 } 61 62 … … 71 72 } }; 72 73 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 73 Assert.assertEquals(correctTags, tags);74 assertEquals(correctTags, tags); 74 75 } 75 76 … … 84 85 correctTags = new HashMap<String, String>() { { put("a", "1"); put("b", "2 3 4"); } }; 85 86 tags = TextTagParser.readTagsFromText(txt); 86 Assert.assertEquals(correctTags, tags);87 assertEquals(correctTags, tags); 87 88 88 89 txt = "\"a\" : \"1 1 1\", \"b2\" :\"2 \\\"3 qwe\\\" 4\""; 89 90 correctTags = new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4"); } }; 90 91 tags = TextTagParser.readTagsFromText(txt); 91 Assert.assertEquals(correctTags, tags);92 assertEquals(correctTags, tags); 92 93 93 94 txt = " \"aыыы\" : \"val\\\"\\\"\\\"ue1\""; 94 95 correctTags = new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1"); } }; 95 96 tags = TextTagParser.readTagsFromText(txt); 96 Assert.assertEquals(correctTags, tags);97 assertEquals(correctTags, tags); 97 98 } 98 99 … … 107 108 } }; 108 109 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 109 Assert.assertEquals(correctTags, tags);110 assertEquals(correctTags, tags); 110 111 } 111 112 … … 117 118 String txt = "a=2 b=3 4"; 118 119 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 119 Assert.assertEquals(Collections.EMPTY_MAP, tags);120 assertEquals(Collections.EMPTY_MAP, tags); 120 121 } 121 122 … … 125 126 @Test 126 127 public void testTab() { 127 Assert.assertEquals(TextTagParser.readTagsFromText("shop\tjewelry"), Collections.singletonMap("shop", "jewelry")); 128 Assert.assertEquals(TextTagParser.readTagsFromText("!shop\tjewelry"), Collections.singletonMap("shop", "jewelry")); 129 Assert.assertEquals(TextTagParser.readTagsFromText("!!!shop\tjewelry"), Collections.singletonMap("shop", "jewelry")); 130 Assert.assertEquals(TextTagParser.readTagsFromText("shop\t\t\tjewelry"), Collections.singletonMap("shop", "jewelry")); 128 assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("shop\tjewelry")); 129 assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("!shop\tjewelry")); 130 assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("!!!shop\tjewelry")); 131 assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("shop\t\t\tjewelry")); 132 } 133 134 /** 135 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/16104">#16104</a> 136 */ 137 @Test 138 public void testTicket16104() { 139 Map<String, String> expected = new HashMap<>(); 140 expected.put("boundary", "national_park"); 141 expected.put("name", "Raet nasjonalpark"); 142 expected.put("naturbase:iid", "VV00003273"); 143 expected.put("naturbase:verneform", "NP"); 144 expected.put("operator", "Raet Nasjonalparkstyre"); 145 expected.put("protect_class", "2"); 146 expected.put("related_law", "https://lovdata.no/forskrift/2016-12-16-1632"); 147 expected.put("short_name", "Raet"); 148 expected.put("start_date", "2016-12-16"); 149 expected.put("type", "boundary"); 150 expected.put("url", "http://faktaark.naturbase.no/?id=VV00003273"); 151 assertEquals(expected, TextTagParser.readTagsFromText( 152 "boundary=national_park\n" + 153 "name=Raet nasjonalpark\n" + 154 "naturbase:iid=VV00003273\n" + 155 "naturbase:verneform=NP\n" + 156 "operator=Raet Nasjonalparkstyre\n" + 157 "protect_class=2\n" + 158 "related_law=https://lovdata.no/forskrift/2016-12-16-1632\n" + 159 "short_name=Raet\n" + 160 "start_date=2016-12-16\n" + 161 "type=boundary\n" + 162 "url=http://faktaark.naturbase.no/?id=VV00003273")); 131 163 } 132 164 }
Note:
See TracChangeset
for help on using the changeset viewer.