summaryrefslogtreecommitdiff
path: root/src/target/test.c
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2018-07-12 11:51:00 +0300
committerOxore <oxore@protonmail.com>2018-07-12 11:51:00 +0300
commitd3fddd7d28f314a6738f2a0ba4d9f58024b01984 (patch)
tree7345455bdc6f051289ffa9854fcad2001a55a223 /src/target/test.c
parent9a9711945c2add826e5887aabe2330bee9042b4b (diff)
Introduce testing with munit, refactor
Split unicode routines from text. Testing: add munit submodule, move translation units with main functions to separate folder, make corresponding changes in Makefile. Make simple test for unicode handling routine. Remove _vimrc_local. test.c: optimize includes. Add test run to .travis.yml.
Diffstat (limited to 'src/target/test.c')
-rw-r--r--src/target/test.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/target/test.c b/src/target/test.c
new file mode 100644
index 0000000..60439a5
--- /dev/null
+++ b/src/target/test.c
@@ -0,0 +1,57 @@
+#include "munit.h"
+
+#include "unicode.h"
+
+struct u_pair {
+ char *utf8;
+ wchar_t *utf32;
+};
+
+struct u_pair *text_fixture;
+
+static void *test_text_setup(const MunitParameter params[], void *user_data) {
+ (void) params;
+ (void) user_data;
+
+ return text_fixture;
+}
+
+static MunitResult test_text(const MunitParameter params[], void *fixture) {
+ (void) params;
+ struct u_pair *f = fixture;
+
+ munit_assert_ulong(utf8_strlen(f[0].utf8), ==, strlen(f[0].utf8));
+
+ return MUNIT_OK;
+}
+
+static MunitTest test_suite_tests[] = {
+ {
+ "/example/parameters",
+ test_text,
+ test_text_setup,
+ NULL,
+ MUNIT_TEST_OPTION_NONE,
+ NULL
+ },
+ {NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL}
+};
+
+static const MunitSuite test_suite = {
+ "unit",
+ test_suite_tests,
+ NULL,
+ 1,
+ MUNIT_SUITE_OPTION_NONE
+};
+
+int main(int argc, char **argv) {
+ text_fixture = (struct u_pair []){
+ {
+ .utf8 = "Single byte ascii symbols string",
+ .utf32 = L"Single byte ascii symbols string"
+ }
+ };
+
+ return munit_suite_main(&test_suite, NULL, argc, argv);
+}