Skip to content
Snippets Groups Projects
Verified Commit e17f5e33 authored by Adam Edward Barton's avatar Adam Edward Barton :speech_balloon:
Browse files

Add test program for IDCValue

parent a47a862c
No related branches found
No related tags found
No related merge requests found
...@@ -34,3 +34,8 @@ atlas_add_test( IDStressTest SOURCES test/IDC_Realistic_Test.cxx ...@@ -34,3 +34,8 @@ atlas_add_test( IDStressTest SOURCES test/IDC_Realistic_Test.cxx
LINK_LIBRARIES Identifier AthenaKernel GaudiKernel EventContainers LINK_LIBRARIES Identifier AthenaKernel GaudiKernel EventContainers
EXTRA_PATTERNS "elapsed|^no lock time|^deleted|^countHit|^lock time" 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
Threw exception correctly
Completed - no errors
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment