summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sord.c3
-rw-r--r--src/sord_test.c20
2 files changed, 22 insertions, 1 deletions
diff --git a/src/sord.c b/src/sord.c
index b9eb5e7..fa9c074 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -1131,7 +1131,8 @@ sord_remove(SordModel* sord, const SordQuad tup)
for (unsigned i = 0; i < NUM_ORDERS; ++i) {
if (sord->indices[i]) {
const int* const ordering = orderings[i];
- GSequenceIter* const cur = index_search(sord->indices[i], tup, ordering);
+ GSequenceIter* const cur = index_lower_bound(
+ sord->indices[i], tup, ordering);
if (!g_sequence_iter_is_end(cur)) {
if (!quad) {
quad = g_sequence_get(cur);
diff --git a/src/sord_test.c b/src/sord_test.c
index cb36ece..71d5453 100644
--- a/src/sord_test.c
+++ b/src/sord_test.c
@@ -334,6 +334,26 @@ main(int argc, char** argv)
sord_free(sord);
}
+ // Test removing
+ sord = sord_new(world, SORD_SPO, false);
+ SordQuad tup = { 0, 0, 0, 0};
+ tup[0] = uri(world, 1);
+ tup[1] = uri(world, 2);
+ tup[2] = sord_new_literal(world, 0, USTR("hello"), NULL);
+ tup[3] = 0;
+ sord_add(sord, tup);
+ sord_node_free(world, (SordNode*)tup[2]);
+ tup[2] = sord_new_literal(world, 0, USTR("hi"), NULL);
+ sord_add(sord, tup);
+ sord_remove(sord, tup);
+ if (sord_num_quads(sord) != 1) {
+ fprintf(stderr, "Removed failed (%zu quads, expected 1)\n",
+ sord_num_quads(sord));
+ goto fail;
+ }
+
+ sord_free(sord);
+
sord_world_free(world);
return EXIT_SUCCESS;