File indexing completed on 2025-01-18 10:17:43
0001
0002
0003
0004
0005 #include <JANA/Services/JEventGroupTracker.h>
0006
0007 #include "catch.hpp"
0008
0009 TEST_CASE("JEventGroupTests") {
0010
0011 JEventGroupManager manager;
0012
0013 SECTION("Happy path") {
0014 auto sut = manager.GetEventGroup(22);
0015 REQUIRE(sut->IsGroupFinished() == true);
0016 sut->StartEvent();
0017 REQUIRE(sut->IsGroupFinished() == false);
0018 sut->StartEvent();
0019 REQUIRE(sut->IsGroupFinished() == false);
0020 sut->StartEvent();
0021 REQUIRE(sut->IsGroupFinished() == false);
0022 sut->CloseGroup();
0023 REQUIRE(sut->IsGroupFinished() == false);
0024 sut->FinishEvent();
0025 REQUIRE(sut->IsGroupFinished() == false);
0026 sut->FinishEvent();
0027 REQUIRE(sut->IsGroupFinished() == false);
0028 sut->FinishEvent();
0029 REQUIRE(sut->IsGroupFinished() == true);
0030 }
0031
0032 SECTION("Groups are initially closed until an event is started") {
0033 auto sut = manager.GetEventGroup(22);
0034 REQUIRE(sut->IsGroupFinished() == true);
0035 sut->StartEvent();
0036 REQUIRE(sut->IsGroupFinished() == false);
0037 sut->CloseGroup();
0038 sut->FinishEvent();
0039 REQUIRE(sut->IsGroupFinished() == true);
0040 }
0041
0042 SECTION("Pointer equality <=> group id equality") {
0043 auto group1 = manager.GetEventGroup(22);
0044 auto group2 = manager.GetEventGroup(22);
0045 REQUIRE(group1 == group2);
0046 auto group3 = manager.GetEventGroup(23);
0047 REQUIRE(group1 != group3);
0048 }
0049
0050 SECTION("Reusing groups works the way you'd expect") {
0051 auto sut = manager.GetEventGroup(22);
0052 REQUIRE(sut->IsGroupFinished() == true);
0053 sut->StartEvent();
0054 REQUIRE(sut->IsGroupFinished() == false);
0055 sut->FinishEvent();
0056 sut->CloseGroup();
0057 REQUIRE(sut->IsGroupFinished() == true);
0058 sut->StartEvent();
0059 REQUIRE(sut->IsGroupFinished() == false);
0060 sut->FinishEvent();
0061 sut->CloseGroup();
0062 REQUIRE(sut->IsGroupFinished() == true);
0063 }
0064
0065 }