Files
tai/taicpp/tests/store_test.cpp
T
2026-10-24 06:42:23 +02:00

26 lines
907 B
C++

#include "../src/store/store.h"
#include <cassert>
#include <cstdio>
int main() {
using namespace detz::store;
Store st(":memory:");
assert(st.ok() && st.schema_version() == 1);
int64_t id = st.add_record("note", "hello", "the quick brown fox jumps");
auto r = st.get_record(id);
assert(r && r->title == "hello");
assert(st.update_record(id, "hello2", "the quick brown fox jumps high"));
auto hits = st.search("fox");
assert(!hits.empty());
assert(st.delete_record(id));
assert(!st.get_record(id));
Store st2(":memory:");
std::string big(5000, 'x');
std::string v = spill_or_truncate(&st2, "note", "big", big);
assert(v.find("spilled to") != std::string::npos);
assert(truncate_text("abc", 4000) == "abc");
DebugLog dl; dl.info("a"); dl.warn("b"); dl.error("c");
assert(dl.lines().size() == 3);
std::puts("M3 OK");
return 0;
}