Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:43

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 #include <JANA/Topology/JEventQueue.h>
0006 
0007 #include "catch.hpp"
0008 
0009 
0010 TEST_CASE("JEventQueueTests_Basic") {
0011 
0012     JEventQueue sut(2,1);
0013 
0014     JEvent event1;
0015     event1.SetEventNumber(1);
0016 
0017     JEvent event2;
0018     event2.SetEventNumber(2);
0019 
0020     JEvent event3;
0021     event3.SetEventNumber(3);
0022 
0023     REQUIRE(sut.GetCapacity() == 2);
0024     REQUIRE(sut.GetSize(0) == 0);
0025 
0026     sut.Push(&event1, 0);
0027     REQUIRE(sut.GetSize(0) == 1);
0028 
0029     JEvent* e = sut.Pop(0);
0030     REQUIRE(sut.GetSize(0) == 0);
0031 
0032     e = sut.Pop(0);
0033     REQUIRE(e == nullptr);
0034 
0035     sut.Push(&event3, 0);
0036     sut.Push(&event2, 0);
0037     REQUIRE(sut.GetSize(0) == 2);
0038 
0039     e = sut.Pop(0);
0040     REQUIRE(e->GetEventNumber() == 3);
0041     REQUIRE(sut.GetSize(0) == 1);
0042 
0043     sut.Push(&event1, 0);
0044     REQUIRE_THROWS(sut.Push(&event1, 0));
0045 }
0046 
0047 
0048 
0049