improved TCString support
This commit is contained in:
1
binding-tests/.gitignore
vendored
1
binding-tests/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
*.o
|
||||
doctest
|
||||
test-db
|
||||
|
||||
@@ -3,14 +3,16 @@ INC=-I ../lib
|
||||
LIB=-L ../target/debug
|
||||
RPATH=-Wl,-rpath,../target/debug
|
||||
|
||||
TESTS = replica.cpp uuid.cpp task.cpp
|
||||
TESTS = replica.cpp string.cpp uuid.cpp task.cpp
|
||||
|
||||
.PHONY: all test
|
||||
|
||||
all: test
|
||||
|
||||
test: doctest
|
||||
@rm -rf test-db
|
||||
@./doctest --no-version --no-intro
|
||||
@rm -rf test-db
|
||||
|
||||
%.o: %.cpp ../lib/taskchampion.h
|
||||
$(CXX) $(INC) -c $< -o $@
|
||||
|
||||
@@ -8,6 +8,12 @@ TEST_CASE("creating an in-memory TCReplica does not crash") {
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
TEST_CASE("creating an on-disk TCReplica does not crash") {
|
||||
TCReplica *rep = tc_replica_new(tc_string_new("test-db"));
|
||||
CHECK(tc_replica_error(rep) == NULL);
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
TEST_CASE("undo on an empty in-memory TCReplica does nothing") {
|
||||
TCReplica *rep = tc_replica_new(NULL);
|
||||
CHECK(tc_replica_error(rep) == NULL);
|
||||
|
||||
29
binding-tests/string.cpp
Normal file
29
binding-tests/string.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <string.h>
|
||||
#include "doctest.h"
|
||||
#include "taskchampion.h"
|
||||
|
||||
TEST_CASE("creating borrowed strings does not crash") {
|
||||
TCString *s = tc_string_new("abcdef");
|
||||
tc_string_free(s);
|
||||
}
|
||||
|
||||
TEST_CASE("creating cloned strings does not crash") {
|
||||
char *abcdef = strdup("abcdef");
|
||||
TCString *s = tc_string_clone(abcdef);
|
||||
free(abcdef);
|
||||
CHECK(strcmp(tc_string_content(s), "abcdef") == 0);
|
||||
tc_string_free(s);
|
||||
}
|
||||
|
||||
TEST_CASE("strings echo back their content") {
|
||||
TCString *s = tc_string_new("abcdef");
|
||||
CHECK(strcmp(tc_string_content(s), "abcdef") == 0);
|
||||
tc_string_free(s);
|
||||
}
|
||||
|
||||
TEST_CASE("tc_string_content returns NULL for strings containing embedded NULs") {
|
||||
TCString *s = tc_string_clone_with_len("ab\0de", 5);
|
||||
REQUIRE(s != NULL);
|
||||
CHECK(tc_string_content(s) == NULL);
|
||||
tc_string_free(s);
|
||||
}
|
||||
@@ -23,13 +23,3 @@ TEST_CASE("creating a Task does not crash") {
|
||||
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
TEST_CASE("undo on an empty in-memory TCReplica does nothing") {
|
||||
TCReplica *rep = tc_replica_new(NULL);
|
||||
CHECK(tc_replica_error(rep) == NULL);
|
||||
int rv = tc_replica_undo(rep);
|
||||
CHECK(rv == 0);
|
||||
CHECK(tc_replica_error(rep) == NULL);
|
||||
tc_replica_free(rep);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user