test bindings in an integration-tests crate

This commit is contained in:
Dustin J. Mitchell
2022-01-25 01:27:24 +00:00
parent 56a805151d
commit c006cbe8e5
29 changed files with 4389 additions and 7123 deletions

View 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();
}