Add tests for ranges and negative values in ability filters

Changed to use "-" instead of ".." as the separator by octalot,
but I believe newfrenchy83 prefers "..".
This commit is contained in:
newfrenchy83 2023-08-06 14:14:40 +02:00 committed by Steve Cotton
parent cc8dddea6e
commit 2a4a073da4
2 changed files with 83 additions and 1 deletions

View file

@ -10,6 +10,8 @@
# During Bob's turn, have Bob attack Alice.
##
#define FILTER_ABILITY_TEST
#arg DRAINS_VALUE
25#endarg
[event]
name=start
# Make sure the attacks hit
@ -29,7 +31,7 @@
apply_to=new_ability
[abilities]
[drains]
value=25
value={DRAINS_VALUE}
[filter]
[filter_location]
time_of_day=neutral
@ -110,6 +112,54 @@
[/event]
)}
{GENERIC_UNIT_TEST event_test_filter_ability_interval_number (
{FILTER_ABILITY_TEST}
[event]
name=attack
[filter]
[filter_ability]
tag_name=drains
value=10-30
[/filter_ability]
[/filter]
{ASSERT ({VARIABLE_CONDITIONAL side_number equals 1})}
{VARIABLE_OP triggers add 1}
[/event]
[event]
name=turn 2
{RETURN ({VARIABLE_CONDITIONAL triggers equals 1})}
[/event]
)}
# API(s) being tested: [event][filter][filter_ability]
##
# Actions:
# Use the common setup from FILTER_ABILITY_TEST.
# Add an event with a filter matching Alice's drains ability.
# Alice attacks Bob and then Bob attacks Alice, as defined in FILTER_ABILITY_TEST.
##
# Expected end state:
# The filtered event is triggered exactly once.
#####
{GENERIC_UNIT_TEST event_test_filter_ability_neg_value (
{FILTER_ABILITY_TEST DRAINS_VALUE=-25}
[event]
name=attack
[filter]
[filter_ability]
tag_name=drains
value=-25--10
[/filter_ability]
[/filter]
{ASSERT ({VARIABLE_CONDITIONAL side_number equals 1})}
{VARIABLE_OP triggers add 1}
[/event]
[event]
name=turn 2
{RETURN ({VARIABLE_CONDITIONAL triggers equals 1})}
[/event]
)}
#####
# API(s) being tested: [event][filter][filter_ability]
##
@ -139,6 +189,35 @@
[/event]
)}
#####
# API(s) being tested: [event][filter][filter_ability]
##
# Actions:
# Use the common setup from FILTER_ABILITY_TEST.
# Add an event with a filter for a drains ability, but a different value to Alice's ability.
# Alice attacks Bob and then Bob attacks Alice, as defined in FILTER_ABILITY_TEST.
##
# Expected end state:
# The filtered event is never triggered.
#####
{GENERIC_UNIT_TEST event_test_filter_ability_no_match_neg_prefix (
{FILTER_ABILITY_TEST}
[event]
name=attack
[filter]
[filter_ability]
tag_name=drains
value=-45-10
[/filter_ability]
[/filter]
{FAIL}
[/event]
[event]
name=turn 2
{SUCCEED}
[/event]
)}
#####
# API(s) being tested: [event][filter][filter_ability_active]
##

View file

@ -143,7 +143,10 @@
0 event_test_filter_side
0 event_test_filter_unit
0 event_test_filter_ability
0 event_test_filter_ability_interval_number
0 event_test_filter_ability_neg_value
0 event_test_filter_ability_no_match
0 event_test_filter_ability_no_match_neg_prefix
0 event_test_filter_ability_active
0 event_test_filter_ability_active_inactive
0 test_ability_id_active