Try and catch more edge cases where setIndex would be invalid.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
8f9f2b2b8d
commit
13df99a6cc
|
@ -25,6 +25,9 @@ namespace CreatureLib::Battling {
|
|||
_index++;
|
||||
while (HasNext()) {
|
||||
if (_scripts[_index].HasValue()) {
|
||||
if (_scripts[_index].IsSet()) {
|
||||
_setIndex = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
_index++;
|
||||
|
|
|
@ -132,24 +132,30 @@ TEST_CASE("Script Aggregator properly iterates multiple script sets.") {
|
|||
BattleScript* script1 = new TestScript("test");
|
||||
BattleScript* script2 = new TestScript("test2");
|
||||
BattleScript* script3 = new TestScript("test3");
|
||||
BattleScript* script4 = new TestScript("test4");
|
||||
auto ran = 0;
|
||||
auto set1 = ScriptSet();
|
||||
set1.Add(script2);
|
||||
set1.Add(script3);
|
||||
auto set2 = ScriptSet();
|
||||
set2.Add(script1);
|
||||
set2.Add(script4);
|
||||
auto vec = ArbUt::List<ScriptWrapper>{
|
||||
ScriptWrapper::FromSet(&set1),
|
||||
ScriptWrapper::FromSet(&set2),
|
||||
};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
auto ran = 0;
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNextNotNull();
|
||||
next.value().As<TestScript>()->TestMethod(ran);
|
||||
}
|
||||
CHECK(ran == 4);
|
||||
CHECK(ran == 3);
|
||||
|
||||
aggr.Reset();
|
||||
ran = 0;
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNextNotNull();
|
||||
next.value().As<TestScript>()->TestMethod(ran);
|
||||
}
|
||||
CHECK(ran == 3);
|
||||
}
|
||||
|
||||
TEST_CASE("Script Aggregator properly iterates when empty.") {
|
||||
|
|
Loading…
Reference in New Issue