diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-24 21:26:53 +0200 | 
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-24 21:26:53 +0200 | 
| commit | df247efec654e512242e4f4f1b0212034f9e01fe (patch) | |
| tree | 25c02e16957f3aa613af30c140fd8e8a3d52fda6 /app/wlib/mswlib/unittest | |
| parent | d0b6a8a4ec298024f14f704f9e40a6f9d324ccf3 (diff) | |
| parent | a5ade52caa489cf0a713e0f02b764000d203140e (diff) | |
Merge branch 'release/debian/1%5.2.0Beta2.1-1' into masterdebian/1%5.2.0Beta2.1-1
Diffstat (limited to 'app/wlib/mswlib/unittest')
| -rw-r--r-- | app/wlib/mswlib/unittest/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | app/wlib/mswlib/unittest/utf8test.c | 65 | 
2 files changed, 76 insertions, 0 deletions
| diff --git a/app/wlib/mswlib/unittest/CMakeLists.txt b/app/wlib/mswlib/unittest/CMakeLists.txt new file mode 100644 index 0000000..b91c1ff --- /dev/null +++ b/app/wlib/mswlib/unittest/CMakeLists.txt @@ -0,0 +1,11 @@ +# build unit tests for the xtrkcad Windows library + +add_executable(utf8test +  		utf8test.c +		../utf8conv.c +		) + +target_link_libraries(utf8test +  		 ${LIBS}) + +add_test(UTF8ConversionTest utf8test) diff --git a/app/wlib/mswlib/unittest/utf8test.c b/app/wlib/mswlib/unittest/utf8test.c new file mode 100644 index 0000000..5b00371 --- /dev/null +++ b/app/wlib/mswlib/unittest/utf8test.c @@ -0,0 +1,65 @@ +/** \file utf8test.c +* Unit tests for utf 8 conversion routines on Windows +*/ + +#include <setjmp.h> +#include <stdbool.h> +#include <string.h> + +#include <cmocka.h> + +#include <wlib.h> + +#define SIMPLEASCIITEXT "The quick brown fox jumps over the lazy dog." +#define UMLAUTTEXT "äöüÄÖÜß" + +static void +ASCIIText(void **state) +{ +	char output[100]; +	char result[100]; +	bool success; +	(void)state; + +	success = wSystemToUTF8(SIMPLEASCIITEXT, output, 100); +	assert_true((void *)success); + +	success = wUTF8ToSystem(output, result, 100); +	assert_true((void *)success); + +	assert_false(strcmp(SIMPLEASCIITEXT, result)); +} + +static void +Umlauts(void **state) +{ +	char output[100]; +	char result[100]; +	bool success; +	(void)state; + +	success = wIsUTF8(UMLAUTTEXT); +	assert_false((void *)success); + +	success = wSystemToUTF8(UMLAUTTEXT, output, 100); +	assert_true((void *)success); + +	success = wIsUTF8(output); +	assert_true((void *)success); + +	success = wUTF8ToSystem(output, result, 100); +	assert_true((void *)success); + +	assert_false(strcmp(UMLAUTTEXT, result)); +} + + +int main(void) +{ +    const struct CMUnitTest tests[] = { +		cmocka_unit_test(ASCIIText), +		cmocka_unit_test(Umlauts), +    }; + +    return cmocka_run_group_tests(tests, NULL, NULL); +}
\ No newline at end of file | 
