Skip to content

Commit

Permalink
Add tests for invalid and uncommon filter literal values
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 authored Aug 2, 2024
1 parent c252118 commit f4067cd
Showing 1 changed file with 132 additions and 5 deletions.
137 changes: 132 additions & 5 deletions tests/filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,14 @@
},
{
"name": "equals number, zero and negative zero",
"selector" : "$[[email protected]==0]",
"document" : [{"a": -0, "d": "e"}, {"a":0.1, "d": "f"}, {"a":"0", "d": "g"}],
"result": [
{"a": -0, "d": "e"}
]
},
{
"name": "equals number, negative zero and zero",
"selector" : "$[[email protected]==-0]",
"document" : [{"a": 0, "d": "e"}, {"a":0.1, "d": "f"}, {"a":"0", "d": "g"}],
"result": [
Expand All @@ -813,6 +821,14 @@
{"a": 100, "d": "e"}
]
},
{
"name": "equals number, exponent upper e",
"selector" : "$[[email protected]==1E2]",
"document" : [{"a": 100, "d": "e"}, {"a":100.1, "d": "f"}, {"a":"100", "d": "g"}],
"result": [
{"a": 100, "d": "e"}
]
},
{
"name": "equals number, positive exponent",
"selector" : "$[[email protected]==1e+2]",
Expand All @@ -829,6 +845,22 @@
{"a": 0.01, "d": "e"}
]
},
{
"name": "equals number, exponent leading 0",
"selector" : "$[[email protected]==1e-02]",
"document" : [{"a": 0.01, "d": "e"}, {"a":0.02, "d": "f"}, {"a":"0.01", "d": "g"}],
"result": [
{"a": 0.01, "d": "e"}
]
},
{
"name": "equals number, exponent 00",
"selector" : "$[[email protected]==1e+00]",
"document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "g"}],
"result": [
{"a": 1, "d": "e"}
]
},
{
"name": "equals number, decimal fraction",
"selector" : "$[[email protected]==1.1]",
Expand All @@ -837,11 +869,6 @@
{"a": 1.1, "d": "e"}
]
},
{
"name": "equals number, decimal fraction, no fractional digit",
"selector" : "$[[email protected]==1.]",
"invalid_selector": true
},
{
"name": "equals number, decimal fraction, exponent",
"selector" : "$[[email protected]==1.1e2]",
Expand All @@ -866,6 +893,91 @@
{"a": 0.011, "d": "e"}
]
},
{
"name": "equals number, invalid plus",
"selector" : "$[[email protected]==+1]",
"invalid_selector": true
},
{
"name": "equals number, invalid minus space",
"selector" : "$[[email protected]==- 1]",
"invalid_selector": true
},
{
"name": "equals number, invalid double minus",
"selector" : "$[[email protected]==--1]",
"invalid_selector": true
},
{
"name": "equals number, invalid no int digit",
"selector" : "$[[email protected]==.1]",
"invalid_selector": true
},
{
"name": "equals number, invalid minus no int digit",
"selector" : "$[[email protected]==-.1]",
"invalid_selector": true
},
{
"name": "equals number, invalid 00",
"selector" : "$[[email protected]==00]",
"invalid_selector": true
},
{
"name": "equals number, invalid leading 0",
"selector" : "$[[email protected]==01]",
"invalid_selector": true
},
{
"name": "equals number, invalid no fractional digit",
"selector" : "$[[email protected]==1.]",
"invalid_selector": true
},
{
"name": "equals number, invalid middle minus",
"selector" : "$[[email protected]==1.-1]",
"invalid_selector": true
},
{
"name": "equals number, invalid no fractional digit e",
"selector" : "$[[email protected]==1.e1]",
"invalid_selector": true
},
{
"name": "equals number, invalid no e digit",
"selector" : "$[[email protected]==1e]",
"invalid_selector": true
},
{
"name": "equals number, invalid no e digit minus",
"selector" : "$[[email protected]==1e-]",
"invalid_selector": true
},
{
"name": "equals number, invalid double e",
"selector" : "$[[email protected]==1eE1]",
"invalid_selector": true
},
{
"name": "equals number, invalid e digit double minus",
"selector" : "$[[email protected]==1e--1]",
"invalid_selector": true
},
{
"name": "equals number, invalid e digit plus minus",
"selector" : "$[[email protected]==1e+-1]",
"invalid_selector": true
},
{
"name": "equals number, invalid e decimal",
"selector" : "$[[email protected]==1e2.3]",
"invalid_selector": true
},
{
"name": "equals number, invalid multi e",
"selector" : "$[[email protected]==1e2e3]",
"invalid_selector": true
},
{
"name": "equals, special nothing",
"selector" : "$.values[?length(@.a) == value($..c)]",
Expand Down Expand Up @@ -1037,6 +1149,21 @@
"name": "or, left hand literal must be compared",
"selector" : "$[?false || true == false]",
"invalid_selector": true
},
{
"name": "true, incorrectly capitalized",
"selector" : "$[?@==True]",
"invalid_selector": true
},
{
"name": "false, incorrectly capitalized",
"selector" : "$[?@==False]",
"invalid_selector": true
},
{
"name": "null, incorrectly capitalized",
"selector" : "$[?@==Null]",
"invalid_selector": true
}
]
}

0 comments on commit f4067cd

Please sign in to comment.