21 #include "gtest/gtest.h"
30 TEST(TestRegistry, valid_get_set)
35 r.
set(
"test1", std::string(
"a_string"));
37 ASSERT_EQ(42, r.
get<
int>(
"test"));
38 ASSERT_EQ(-42, r.
get<
int>(
"test0"));
39 ASSERT_EQ(
"a_string", r.
get<std::string>(
"test1"));
42 TEST(TestRegistry, invalid_get_set)
47 r.
set(
"test1",
"a_string");
52 TEST(TestRegistry, expiration)
57 r.
set(1, 3, expire_at);
58 r.
set(2, 6, expire_at);
59 r.
set(3, 9, expire_at);
62 ASSERT_EQ(3, r.
get<
int>(1));
64 ASSERT_EQ(6, r.
get<
int>(2));
66 ASSERT_EQ(9, r.
get<
int>(3));
68 std::this_thread::sleep_for(std::chrono::milliseconds(3001));
75 TEST(TestRegistry, auto_expiration)
80 r.
set(1, 3, expire_at);
81 r.
set(2, 6, expire_at);
82 r.
set(3, 9, expire_at);
84 ASSERT_EQ(3, r.
get<
int>(1));
85 ASSERT_EQ(6, r.
get<
int>(2));
86 ASSERT_EQ(9, r.
get<
int>(3));
88 std::this_thread::sleep_for(std::chrono::milliseconds(3001));
91 ASSERT_NO_THROW(r.
get<
int>(1));
92 ASSERT_NO_THROW(r.
get<
int>(2));
93 ASSERT_NO_THROW(r.
get<
int>(3));