Changeset 9930 in josm for trunk/test
- Timestamp:
- 2016-03-05T16:25:52+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r9701 r9930 4 4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertThat;7 6 import static org.junit.Assert.assertTrue; 8 7 9 import org.hamcrest.CoreMatchers;10 8 import org.junit.Before; 11 9 import org.junit.Test; … … 97 95 assertTrue(c.match(newPrimitive("name", "hello-foo-xy"))); 98 96 assertFalse(c.match(newPrimitive("name", "X"))); 97 assertEquals("foo", c.toString()); 99 98 } 100 99 … … 110 109 assertFalse(c.match(newPrimitive("fooX", "bar"))); 111 110 assertFalse(c.match(newPrimitive("foo", "barX"))); 111 assertEquals("foo=bar", c.toString()); 112 112 } 113 113 … … 186 186 @Test 187 187 public void testNthParseNegative() throws ParseError { 188 assert That(SearchCompiler.compile("nth:-1").toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}"));188 assertEquals("Nth{nth=-1, modulo=false}", SearchCompiler.compile("nth:-1").toString()); 189 189 } 190 190 … … 408 408 assertFalse(search.match(n1)); 409 409 } 410 411 /** 412 * Tests the implementation of the Boolean logic. 413 * @throws ParseError if an error has been encountered while compiling 414 */ 415 @Test 416 public void testBooleanLogic() throws ParseError { 417 final SearchCompiler.Match c1 = SearchCompiler.compile("foo AND bar AND baz"); 418 assertTrue(c1.match(newPrimitive("foobar", "baz"))); 419 assertEquals("foo && bar && baz", c1.toString()); 420 final SearchCompiler.Match c2 = SearchCompiler.compile("foo AND (bar OR baz)"); 421 assertTrue(c2.match(newPrimitive("foobar", "yes"))); 422 assertTrue(c2.match(newPrimitive("foobaz", "yes"))); 423 assertEquals("foo && (bar || baz)", c2.toString()); 424 final SearchCompiler.Match c3 = SearchCompiler.compile("foo OR (bar baz)"); 425 assertEquals("foo || (bar && baz)", c3.toString()); 426 final SearchCompiler.Match c4 = SearchCompiler.compile("foo1 OR (bar1 bar2 baz1 XOR baz2) OR foo2"); 427 assertEquals("foo1 || (bar1 && bar2 && (baz1 ^ baz2)) || foo2", c4.toString()); 428 } 410 429 }
Note:
See TracChangeset
for help on using the changeset viewer.