diff --git a/Event/EventContainers/CMakeLists.txt b/Event/EventContainers/CMakeLists.txt index c65a935b9a0890f2d58a3d8f3a7ef5bca1786840..a78bf3a7d82bbadd6dda1d024159c9ea2ce25e62 100644 --- a/Event/EventContainers/CMakeLists.txt +++ b/Event/EventContainers/CMakeLists.txt @@ -34,3 +34,8 @@ atlas_add_test( IDStressTest SOURCES test/IDC_Realistic_Test.cxx LINK_LIBRARIES Identifier AthenaKernel GaudiKernel EventContainers EXTRA_PATTERNS "elapsed|^no lock time|^deleted|^countHit|^lock time" ) +atlas_add_test( IDCValueTest SOURCES test/IDCValueTest.cxx + INCLUDE_DIRS src test EventContainers + LINK_LIBRARIES Identifier AthenaKernel GaudiKernel EventContainers + EXTRA_PATTERNS "" + ) \ No newline at end of file diff --git a/Event/EventContainers/share/IDCValueTest.ref b/Event/EventContainers/share/IDCValueTest.ref new file mode 100644 index 0000000000000000000000000000000000000000..1a2c5e2c1a5a6ea943180b9523fa1816f9169236 --- /dev/null +++ b/Event/EventContainers/share/IDCValueTest.ref @@ -0,0 +1,2 @@ +Threw exception correctly +Completed - no errors diff --git a/Event/EventContainers/test/IDCValueTest.cxx b/Event/EventContainers/test/IDCValueTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c7b908d8f0c1df946cedfa873d1cabcb3c95e847 --- /dev/null +++ b/Event/EventContainers/test/IDCValueTest.cxx @@ -0,0 +1,44 @@ + +#include "EventContainers/IdentifiableValueContainer.h" + +#include <cstdlib> +#include <iostream> +#include <limits> + +typedef IdentifiableValueCache<int, std::numeric_limits<int>::min()> int100cache; +typedef IdentifiableValueContainer<int, std::numeric_limits<int>::min()> int100container; + +int main(){ + auto *cache = new int100cache(100); + auto *container = new int100container(cache); + auto *container2 = new int100container(cache); + static_assert(cache->emptyValue() == std::numeric_limits<int>::min()); + if(container->maxSize()!= 100) std::abort(); + if(!container->setOrDrop(50, 29)) std::abort(); + if(!container->setOrDrop(51, -29)) std::abort(); + if(!container->setOrDrop(52, -9)) std::abort(); + if(container->setOrDrop(52, 10) == true) std::abort(); //check if repeated setting passes + if(container->retrieve(52) != -9) std::abort(); + + if(container->present(50)==false || container->present(51)==false || container->present(52)==false) std::abort(); + if(container2->tryAddFromCache(50) == false) std::abort(); + if(container2->getAll().size()!= 1) std::abort(); + if(container->getAll().size()!= 3) std::abort(); + if(container2->retrieve(50) != 29) std::abort(); + if(container2->present(51) == true) std::abort(); + if(container2->retrieve(51) != container2->emptyValue()) std::abort(); + bool except =false; + try{ + container->setOrDrop(150, -29); + }catch(const std::out_of_range& ex) + { + except = true; + std::cout << "Threw exception correctly" << std::endl; + } + if(except == false) std::abort(); + delete container2; + delete container; + delete cache; + std::cout << "Completed - no errors" << std::endl; + return 0; +} \ No newline at end of file