12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "test.h"
- #include "store_mdb.h"
- #include "assets.h"
- static void rmdb() {
- remove("/tmp/testdb/data.mdb");
- remove("/tmp/testdb/lock.mdb");
- remove("/tmp/testdb");
- }
- static int test_triple_store()
- {
- char *path = "/tmp/testdb";
- EXPECT_PASS(LSUP_store_setup(&path));
- atexit(rmdb);
- LSUP_MDBStore *store;
- store = LSUP_store_new(path, NULL); // triple store.
- ASSERT(store != NULL, "Error initializing store!");
- LSUP_Triple *trp = create_triples();
- LSUP_SerTerm sterms[NUM_TRP][3];
- LSUP_SerTriple ser_trp[NUM_TRP];
- for (int i = 0; i < NUM_TRP; i++) {
- ser_trp[i].s = sterms[i];
- ser_trp[i].p = sterms[i] + 1;
- ser_trp[i].o = sterms[i] + 2;
- for (int j = 0; j < 3; j++) {
- LSUP_term_serialize(
- LSUP_triple_term_by_pos(trp + i, j),
- LSUP_ser_triple_term_by_pos(ser_trp + i, j));
- }
- }
- EXPECT_PASS(LSUP_store_add(store, NULL, ser_trp, NUM_TRP));
- for (int i = 0; i < NUM_TRP; i++) {
- LSUP_buffer_done(ser_trp[i].s);
- LSUP_buffer_done(ser_trp[i].p);
- LSUP_buffer_done(ser_trp[i].o);
- }
- LSUP_store_free(store);
- free_triples(trp);
- return 0;
- }
- static int test_quad_store()
- {
- return 0;
- }
- int store_mdb_test()
- {
- RUN(test_triple_store);
- RUN(test_quad_store);
- return 0;
- }
|