test bindings in an integration-tests crate
This commit is contained in:
39
integration-tests/src/bindings_tests/replica.c
Normal file
39
integration-tests/src/bindings_tests/replica.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "taskchampion.h"
|
||||
|
||||
// creating an in-memory replica does not crash
|
||||
static void test_replica_creation(void) {
|
||||
TCReplica *rep = tc_replica_new_in_memory();
|
||||
TEST_ASSERT_NOT_NULL(rep);
|
||||
TEST_ASSERT_NULL(tc_replica_error(rep));
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
// creating an on-disk replica does not crash
|
||||
static void test_replica_creation_disk(void) {
|
||||
TCReplica *rep = tc_replica_new_on_disk(tc_string_new("test-db"), NULL);
|
||||
TEST_ASSERT_NOT_NULL(rep);
|
||||
TEST_ASSERT_NULL(tc_replica_error(rep));
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
// undo on an empty in-memory TCReplica does nothing
|
||||
static void test_replica_undo_empty(void) {
|
||||
TCReplica *rep = tc_replica_new_in_memory();
|
||||
TEST_ASSERT_NULL(tc_replica_error(rep));
|
||||
int rv = tc_replica_undo(rep);
|
||||
TEST_ASSERT_EQUAL(0, rv);
|
||||
TEST_ASSERT_NULL(tc_replica_error(rep));
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
int replica_tests(void) {
|
||||
UNITY_BEGIN();
|
||||
// each test case above should be named here, in order.
|
||||
RUN_TEST(test_replica_creation);
|
||||
RUN_TEST(test_replica_creation_disk);
|
||||
RUN_TEST(test_replica_undo_empty);
|
||||
return UNITY_END();
|
||||
}
|
||||
Reference in New Issue
Block a user