50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#include <iostream>
|
|
#include <filesystem>
|
|
#include "../binary_table.h"
|
|
|
|
void printAddressTable(bt::BinaryTable& table) {
|
|
// We can't access getAddressTable directly, so let's use a different approach
|
|
// Try to retrieve all known keys and see what happens
|
|
std::vector<std::string> keys = {"key1", "key2", "key3"};
|
|
|
|
for (const std::string& key : keys) {
|
|
try {
|
|
auto ref = table.getReference(key);
|
|
std::cout << " " << key << " -> address " << ref.getPointer().address()
|
|
<< " (type " << static_cast<int>(ref.getType()) << ")" << std::endl;
|
|
} catch (const std::exception& e) {
|
|
std::cout << " " << key << " -> ERROR: " << e.what() << std::endl;
|
|
}
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
using namespace bt;
|
|
|
|
const std::string filename = "debug_addr_table.bin";
|
|
if (std::filesystem::exists(filename)) {
|
|
std::filesystem::remove(filename);
|
|
}
|
|
|
|
BinaryTable table(filename);
|
|
table.initialize();
|
|
|
|
std::cout << "=== Testing Address Table Corruption ===\n" << std::endl;
|
|
|
|
std::cout << "Initial state (empty):" << std::endl;
|
|
printAddressTable(table);
|
|
|
|
std::cout << "\n1. After storing key1:" << std::endl;
|
|
table.set<int32_t>("key1", 100);
|
|
printAddressTable(table);
|
|
|
|
std::cout << "\n2. After storing key2:" << std::endl;
|
|
table.set<int32_t>("key2", 200);
|
|
printAddressTable(table);
|
|
|
|
std::cout << "\n3. After storing key3:" << std::endl;
|
|
table.set<int32_t>("key3", 300);
|
|
printAddressTable(table);
|
|
|
|
return 0;
|
|
} |