Files
SweepStore/cpp/debug/debug_simple.cpp

47 lines
1.4 KiB
C++

#include <iostream>
#include <filesystem>
#include "../binary_table.h"
int main() {
using namespace bt;
const std::string filename = "debug_simple.bin";
if (std::filesystem::exists(filename)) {
std::filesystem::remove(filename);
}
BinaryTable table(filename);
table.initialize();
std::cout << "1. Storing key1..." << std::endl;
table.set<int32_t>("key1", 100);
std::cout << "2. Reading key1..." << std::endl;
try {
int32_t val = table.get<int32_t>("key1");
std::cout << " ✅ key1 = " << val << std::endl;
} catch (const std::exception& e) {
std::cout << " ❌ key1 failed: " << e.what() << std::endl;
}
std::cout << "3. Storing key2..." << std::endl;
table.set<int32_t>("key2", 200);
std::cout << "4. Reading key2..." << std::endl;
try {
int32_t val = table.get<int32_t>("key2");
std::cout << " ✅ key2 = " << val << std::endl;
} catch (const std::exception& e) {
std::cout << " ❌ key2 failed: " << e.what() << std::endl;
}
std::cout << "5. Re-reading key1..." << std::endl;
try {
int32_t val = table.get<int32_t>("key1");
std::cout << " ✅ key1 = " << val << std::endl;
} catch (const std::exception& e) {
std::cout << " ❌ key1 failed: " << e.what() << std::endl;
}
return 0;
}