瀏覽代碼

Pass triple tests (no iterator testing yet).

Stefano Cossu 4 年之前
父節點
當前提交
17e3d18717
共有 2 個文件被更改,包括 11 次插入9 次删除
  1. 1 3
      src/store_mdb.c
  2. 10 6
      test/test_store_mdb.c

+ 1 - 3
src/store_mdb.c

@@ -1130,9 +1130,7 @@ lookup_3bound(struct MDBStore *store, struct MDBIterator *it, size_t *ct)
         rc = LSUP_NORESULT;
     } else {
         it->iter_op_fn = it_next_3bound;
-        *it->spok[0] = it->luk[0];
-        *it->spok[1] = it->luk[1];
-        *it->spok[2] = it->luk[2];
+        it->spok = &it->luk;
         rc = LSUP_OK;
     }
 

+ 10 - 6
test/test_store_mdb.c

@@ -63,7 +63,7 @@ static int test_triple_store()
         {ser_trp[4].s, ser_trp[4].p, NULL, NULL},
         {NULL, ser_trp[7].p, ser_trp[7].o, NULL},
         {ser_trp[5].s, NULL, ser_trp[5].o, NULL},
-        {ser_trp[6].s, NULL, ser_trp[5].o, ser_trp[2].s},
+        {ser_trp[5].s, NULL, ser_trp[5].o, ser_trp[2].s},
 
         {ser_trp[4].s, ser_trp[4].p, ser_trp[4].o, NULL},
         {ser_trp[4].s, ser_trp[4].p, ser_trp[6].o, NULL},
@@ -72,7 +72,7 @@ static int test_triple_store()
     size_t results[12] = {
         8,
         5, 1, 1, 0, 1,
-        2, 1, 2, 1,
+        2, 1, 2, 2,
         1, 0,
     };
 
@@ -82,10 +82,12 @@ static int test_triple_store()
 
         TRACE("Testing triple lookup #%d.\n", i);
         int rc = LSUP_store_lookup(store, lut[i], &it, &ct);
-        if (ct > 0) EXPECT_INT_EQ(rc, LSUP_OK);
-        else if (ct == 0) EXPECT_INT_EQ(rc, LSUP_NORESULT);
+        if (results[i] > 0) EXPECT_INT_EQ(rc, LSUP_OK);
+        else EXPECT_INT_EQ(rc, LSUP_NORESULT);
 
         EXPECT_INT_EQ(ct, results[i]);
+
+        LSUP_store_it_free(it);
     }
 
     for (int i = 0; i < NUM_TRP; i++) {
@@ -269,10 +271,12 @@ static int test_quad_store()
         printf("}\n");
 
         int rc = LSUP_store_lookup(store, lut[i], &it, &ct);
-        if (ct > 0) EXPECT_INT_EQ(rc, LSUP_OK);
-        else if (ct == 0) EXPECT_INT_EQ(rc, LSUP_NORESULT);
+        if (results[i] > 0) EXPECT_INT_EQ(rc, LSUP_OK);
+        else EXPECT_INT_EQ(rc, LSUP_NORESULT);
 
         EXPECT_INT_EQ(ct, results[i]);
+
+        LSUP_store_it_free(it);
     }
 
     for (int i = 0; i < NUM_TRP; i++) {