Browse Source

Added tests for EMPTY operator.

pull/183/merge
Kalle Stenflo 9 years ago
parent
commit
07390fcb16
  1. 25
      json-path/src/test/java/com/jayway/jsonpath/FilterTest.java

25
json-path/src/test/java/com/jayway/jsonpath/FilterTest.java

@ -370,7 +370,7 @@ public class FilterTest extends BaseTest {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// EMPTY // NOT EMPTY
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@Test @Test
@ -384,6 +384,29 @@ public class FilterTest extends BaseTest {
assertThat(filter(where("null-key").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false); assertThat(filter(where("null-key").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
} }
//----------------------------------------------------------------------------
//
// EMPTY
//
//----------------------------------------------------------------------------
@Test
public void empty_evals() {
assertThat(filter(where("string-key").empty(false)).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("string-key").empty(true)).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("string-key-empty").empty(true)).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("string-key-empty").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("int-arr").empty(false)).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("int-arr").empty(true)).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("arr-empty").empty(true)).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("arr-empty").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("null-key").empty(true)).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("null-key").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //

Loading…
Cancel
Save