behavior_scope_test.cpp 1.6 KB

123456789101112131415161718192021222324252627282930
  1. #include <array>
  2. #include <cassert>
  3. #include "../Sunrise/src/server/activity/activity_sdk_behavior_scope.h"
  4. namespace scope = sunrise::server::activity::behavior_scope;
  5. namespace f = sunrise::state::activity_sdk::format;
  6. int main() {
  7. std::array<f::State, 4> states{};
  8. std::array<f::Bubble, 2> bubbles{};
  9. states[0].sliceSetIndex = 64; // Opening seed remains published.
  10. states[1].bubbleIndex = 1; // Light's End, region zero.
  11. states[2] = states[1]; states[2].stateOrdinal = 1; // Ending cinematic.
  12. states[3] = states[1]; states[3].scenarioIndex = 1;
  13. std::array<f::Occurrence, 5> rows{};
  14. rows[0].objectIndex = 7; // Shared object at opening.
  15. rows[1] = rows[0]; rows[1].stateIndex = 1; rows[1].bubbleIndex = 1;
  16. rows[2] = rows[1]; rows[2].objectIndex = 9; // Reactor-only alarm.
  17. rows[3] = rows[2]; rows[3].stateIndex = 2; // Cinematic-state occurrence.
  18. rows[4] = rows[2]; rows[4].scenarioIndex = 1; rows[4].stateIndex = 3;
  19. assert(scope::select(rows,states,bubbles,0,9,0,0).row == 2);
  20. assert(scope::select(rows,states,bubbles,0,7,0,0).row == 1);
  21. assert(scope::select(rows,states,bubbles,0,7,0,64).row == 0);
  22. assert(scope::select(rows,states,bubbles,0,9,0,1).row == 3);
  23. assert(scope::select(rows,states,bubbles,0,9,0,40).row == f::kAbsentIndex);
  24. assert(!scope::live_state(states,bubbles,0,1,64));
  25. assert(!scope::live_state(states,bubbles,0,3,0));
  26. assert(!scope::live_state(states,bubbles,0,99,0));
  27. assert(!scope::live_state(states,bubbles,0,1,-1));
  28. states[2].stateOrdinal = 0; // Conflicting authored rows must refuse.
  29. assert(scope::select(rows,states,bubbles,0,9,0,0).ambiguous);
  30. }