#pragma once #include #include #include #include #include #include #include class ClientFixture : public ::testing::Test { public: static inline std::unique_ptr client; static void SetUpTestCase() { std::string server_addr = SERVICE_ADDRESS; std::cout << "\n\n ----------------------------------------------------- \n\n"; std::cout << " Using server address : " << server_addr << "\n"; std::cout << "\n ----------------------------------------------------- \n\n\n"; client = liboffkv::open(server_addr, "/unitTests"); } static void TearDownTestCase() {} void SetUp() {} void TearDown() {} class KeyHolder { private: std::string key_; void destroy_() { if (!key_.empty()) try { client->erase(key_); } catch (...) {} } public: explicit KeyHolder(std::string key) : key_(std::move(key)) { try { client->erase(key_); } catch (...) {} } KeyHolder(const KeyHolder&) = delete; KeyHolder(KeyHolder&& that) : key_(that.key_) { that.key_ = ""; } KeyHolder& operator=(const KeyHolder&) = delete; KeyHolder& operator=(KeyHolder&& that) { destroy_(); key_ = that.key_; that.key_ = ""; return *this; } ~KeyHolder() { destroy_(); } }; template static std::array hold_keys(Keys&& ... keys) { return {KeyHolder(std::move(keys))...}; } };