|
|
@@ -184,6 +184,27 @@ void test_get_from_nonexistent_collection_returns_nullopt() {
|
|
|
check(!g.has_value(), "get on nonexistent collection returns nullopt");
|
|
|
}
|
|
|
|
|
|
+// =========================================================================
|
|
|
+// Stage 4 Task 4.1 — exists() bound-check (no materialisation needed).
|
|
|
+// Default impl is get().has_value(); LmdbDocumentStore inherits it.
|
|
|
+// =========================================================================
|
|
|
+
|
|
|
+void test_exists_present_returns_true() {
|
|
|
+ TmpEnv t("exists-true");
|
|
|
+ LmdbDocumentStore store(t.env);
|
|
|
+ store.put("c", "k", make_doc("k", "c", nlohmann::json{{"v", 1}}));
|
|
|
+ check(store.exists("c", "k"), "exists() returns true for present doc");
|
|
|
+}
|
|
|
+
|
|
|
+void test_exists_absent_returns_false() {
|
|
|
+ TmpEnv t("exists-false");
|
|
|
+ LmdbDocumentStore store(t.env);
|
|
|
+ store.put("c", "k", make_doc("k", "c", nlohmann::json{{"v", 1}}));
|
|
|
+ check(!store.exists("c", "missing"), "exists() returns false for absent id");
|
|
|
+ check(!store.exists("no-such-coll", "k"),
|
|
|
+ "exists() returns false for absent collection");
|
|
|
+}
|
|
|
+
|
|
|
void test_del_missing_returns_false() {
|
|
|
TmpEnv t("del-missing");
|
|
|
LmdbDocumentStore store(t.env);
|
|
|
@@ -704,6 +725,8 @@ int main() {
|
|
|
test_put_overwrite_replaces();
|
|
|
test_get_missing_returns_nullopt();
|
|
|
test_get_from_nonexistent_collection_returns_nullopt();
|
|
|
+ test_exists_present_returns_true();
|
|
|
+ test_exists_absent_returns_false();
|
|
|
test_del_missing_returns_false();
|
|
|
test_del_then_get_returns_nullopt();
|
|
|
test_del_returns_true_for_existing();
|