Skip to content

Commit bd7f935

Browse files
Copilotkhvn26
andcommitted
Add 12 IN operator edge cases for int/float type matching
Co-authored-by: khvn26 <[email protected]>
1 parent 380415b commit bd7f935

12 files changed

+536
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// Given: A segment with IN condition using comma-delimited floats
3+
// When: An evaluation context with an identity that has a float trait matching one of the comma-delimited float values
4+
// Then: The context should be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "float_comma_delim_user",
13+
"key": "key_float_comma_delim_user",
14+
"traits": {
15+
"score": 2.5
16+
}
17+
},
18+
"segments": {
19+
"34": {
20+
"key": "34",
21+
"name": "segment_float_comma_delimited",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "score",
29+
"value": "1.5,2.5,3.5,4.5"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
},
37+
"result": {
38+
"flags": {},
39+
"segments": [
40+
{
41+
"name": "segment_float_comma_delimited"
42+
}
43+
]
44+
}
45+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Given: A segment with IN condition using comma-delimited integers
3+
// When: An evaluation context with an identity that has a float trait that does not match any of the comma-delimited integer values
4+
// Then: The context should not be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "float_comma_delim_int_user",
13+
"key": "key_float_comma_delim_int_user",
14+
"traits": {
15+
"score": 2.5
16+
}
17+
},
18+
"segments": {
19+
"36": {
20+
"key": "36",
21+
"name": "segment_float_comma_delimited_int_mismatch",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "score",
29+
"value": "1,2,3,4"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
},
37+
"result": {
38+
"flags": {},
39+
"segments": []
40+
}
41+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
// Given: A segment with IN condition using an array of floats
3+
// When: An evaluation context with an identity that has a float trait matching one of the array values
4+
// Then: The context should be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "float_array_user",
13+
"key": "key_float_array_user",
14+
"traits": {
15+
"score": 2.5
16+
}
17+
},
18+
"segments": {
19+
"30": {
20+
"key": "30",
21+
"name": "segment_float_array",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "score",
29+
"value": [
30+
1.5,
31+
2.5,
32+
3.5,
33+
4.5
34+
]
35+
}
36+
]
37+
}
38+
]
39+
}
40+
}
41+
},
42+
"result": {
43+
"flags": {},
44+
"segments": [
45+
{
46+
"name": "segment_float_array"
47+
}
48+
]
49+
}
50+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
// Given: A segment with IN condition using an array of integers
3+
// When: An evaluation context with an identity that has a float trait that does not match any of the integer array values
4+
// Then: The context should not be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "float_int_array_user",
13+
"key": "key_float_int_array_user",
14+
"traits": {
15+
"score": 2.5
16+
}
17+
},
18+
"segments": {
19+
"32": {
20+
"key": "32",
21+
"name": "segment_float_int_array_mismatch",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "score",
29+
"value": [
30+
1,
31+
2,
32+
3,
33+
4
34+
]
35+
}
36+
]
37+
}
38+
]
39+
}
40+
}
41+
},
42+
"result": {
43+
"flags": {},
44+
"segments": []
45+
}
46+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// Given: A segment with IN condition using JSON-encoded array of floats
3+
// When: An evaluation context with an identity that has a float trait matching one of the JSON-encoded float values
4+
// Then: The context should be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "float_json_array_user",
13+
"key": "key_float_json_array_user",
14+
"traits": {
15+
"score": 2.5
16+
}
17+
},
18+
"segments": {
19+
"38": {
20+
"key": "38",
21+
"name": "segment_float_json_encoded",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "score",
29+
"value": "[1.5,2.5,3.5,4.5]"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
},
37+
"result": {
38+
"flags": {},
39+
"segments": [
40+
{
41+
"name": "segment_float_json_encoded"
42+
}
43+
]
44+
}
45+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Given: A segment with IN condition using JSON-encoded array of integers
3+
// When: An evaluation context with an identity that has a float trait that does not match any of the JSON-encoded integer values
4+
// Then: The context should not be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "float_json_int_array_user",
13+
"key": "key_float_json_int_array_user",
14+
"traits": {
15+
"score": 2.5
16+
}
17+
},
18+
"segments": {
19+
"40": {
20+
"key": "40",
21+
"name": "segment_float_json_encoded_int_mismatch",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "score",
29+
"value": "[1,2,3,4]"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
},
37+
"result": {
38+
"flags": {},
39+
"segments": []
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Given: A segment with IN condition using comma-delimited floats
3+
// When: An evaluation context with an identity that has an integer trait that does not match any of the comma-delimited float values
4+
// Then: The context should not be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "int_comma_delim_float_user",
13+
"key": "key_int_comma_delim_float_user",
14+
"traits": {
15+
"level": 2
16+
}
17+
},
18+
"segments": {
19+
"37": {
20+
"key": "37",
21+
"name": "segment_int_comma_delimited_float_mismatch",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "level",
29+
"value": "1.5,2.5,3.5,4.5"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
},
37+
"result": {
38+
"flags": {},
39+
"segments": []
40+
}
41+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// Given: A segment with IN condition using comma-delimited integers
3+
// When: An evaluation context with an identity that has an integer trait matching one of the comma-delimited integer values
4+
// Then: The context should be considered part of the segment
5+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
6+
"context": {
7+
"environment": {
8+
"key": "key",
9+
"name": "Environment"
10+
},
11+
"identity": {
12+
"identifier": "int_comma_delim_user",
13+
"key": "key_int_comma_delim_user",
14+
"traits": {
15+
"level": 2
16+
}
17+
},
18+
"segments": {
19+
"35": {
20+
"key": "35",
21+
"name": "segment_int_comma_delimited",
22+
"rules": [
23+
{
24+
"type": "ALL",
25+
"conditions": [
26+
{
27+
"operator": "IN",
28+
"property": "level",
29+
"value": "1,2,3,4"
30+
}
31+
]
32+
}
33+
]
34+
}
35+
}
36+
},
37+
"result": {
38+
"flags": {},
39+
"segments": [
40+
{
41+
"name": "segment_int_comma_delimited"
42+
}
43+
]
44+
}
45+
}

0 commit comments

Comments
 (0)