diff --git a/tests/io.c b/tests/io.c index 165d496..25cf48d 100644 --- a/tests/io.c +++ b/tests/io.c @@ -35,16 +35,25 @@ int main() { simdb_close(db); - mode |= SIMDB_FLAG_WRITE; + mode = SIMDB_FLAG_WRITE | SIMDB_FLAG_LOCKNB; db = simdb_open(path, mode, &ret); assert(db != NULL); + /* also test locks */ + assert(simdb_open(path, mode, &ret) == NULL); + assert(ret == SIMDB_ERR_LOCK); + ret = simdb_records_count(db); assert(ret == 0); ret = simdb_write(db, 1, 2, rec); assert(ret == 2); /* success */ + assert(simdb_record_used(db, 0) == false); + assert(simdb_record_used(db, 1) == true); + assert(simdb_record_used(db, 2) == true); + assert(simdb_record_used(db, 3) == false); + ret = simdb_records_count(db); assert(ret == 2);