2026-10-25 02:02:31 +02:00
|
|
|
// Store smoke test (record CRUD, search, spill). The full parity suite is
|
|
|
|
|
// tests/foundation_parity.py; this one has no python dependency.
|
2026-10-24 06:42:23 +02:00
|
|
|
#include <cstdio>
|
2026-10-25 02:02:31 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include "../src/store/spill.h"
|
|
|
|
|
#include "../src/store/store.h"
|
2026-10-24 06:42:23 +02:00
|
|
|
int main() {
|
|
|
|
|
using namespace detz::store;
|
2026-10-25 02:02:31 +02:00
|
|
|
auto st = Store::Open(":memory:");
|
|
|
|
|
std::string id = st->add_record("note", "hello", "the quick brown fox jumps", {"animals"});
|
|
|
|
|
auto r = st->get_record(id);
|
|
|
|
|
if (!r || r->get_string("title") != "hello") { std::puts("get_record failed"); return 1; }
|
|
|
|
|
if (st->search_records("fox").size() != 1) { std::puts("search_records failed"); return 1; }
|
|
|
|
|
if (st->fts_search("fox").empty()) { std::puts("fts_search failed"); return 1; }
|
|
|
|
|
if (!st->delete_record(id) || st->get_record(id)) { std::puts("delete_record failed"); return 1; }
|
|
|
|
|
std::string big(7000, 'x');
|
|
|
|
|
std::string view = Spill::spill_or_truncate(st.get(), "note", "big", big);
|
|
|
|
|
if (view.find("chars spilled to mem:") == std::string::npos) { std::puts("spill failed"); return 1; }
|
|
|
|
|
if (Spill::truncate("abc") != "abc") { std::puts("truncate failed"); return 1; }
|
|
|
|
|
std::puts("store OK");
|
2026-10-24 06:42:23 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|