28 #include <momemta/Pool.h> 30 TEST_CASE(
"memory pool",
"[pool]") {
31 std::unique_ptr<Pool> pool(
new Pool());
33 SECTION(
"Put and get") {
36 auto ptr = pool->put<
double>(tag);
41 auto read = pool->get<
double>(tag);
42 REQUIRE(*read == Approx(12.5));
45 SECTION(
"Get should allocate memory") {
48 auto value = pool->get<
double>(tag);
51 auto ptr = pool->put<
double>(tag);
54 REQUIRE(*value == Approx(12.5));
57 SECTION(
"Put is allowed only once") {
60 auto value = pool->put<
double>(tag);
66 SECTION(
"Indexed InputTag") {
68 InputTag indexed_tag(
"module",
"parameter", 1);
70 auto ptr = pool->put<std::vector<double>>(tag);
76 auto value = pool->get<
double>(indexed_tag);
77 REQUIRE(*value == Approx(1));
80 SECTION(
"Get should allocate a vector for indexed InputTag") {
81 InputTag tag(
"module",
"parameter", 1);
83 auto value = pool->get<
double>(tag);
85 auto ptr = pool->put<std::vector<double>>(tag);
89 REQUIRE(*value == Approx(1));