basic test for tolower function.

This commit is contained in:
Enno Rehling 2014-10-19 06:42:40 +02:00
parent f4f9e74e90
commit eb1d73e2c2
3 changed files with 25 additions and 0 deletions

View File

@ -35,6 +35,7 @@ int RunAllTests(void)
ADD_TESTS(suite, bsdstring); ADD_TESTS(suite, bsdstring);
ADD_TESTS(suite, functions); ADD_TESTS(suite, functions);
ADD_TESTS(suite, umlaut); ADD_TESTS(suite, umlaut);
ADD_TESTS(suite, unicode);
ADD_TESTS(suite, strings); ADD_TESTS(suite, strings);
/* kernel */ /* kernel */
ADD_TESTS(suite, unit); ADD_TESTS(suite, unit);

View File

@ -7,6 +7,7 @@ strings.test.c
bsdstring.test.c bsdstring.test.c
functions.test.c functions.test.c
umlaut.test.c umlaut.test.c
unicode.test.c
) )
SET(_FILES SET(_FILES

23
src/util/unicode.test.c Normal file
View File

@ -0,0 +1,23 @@
#include <CuTest.h>
#include "unicode.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
static void test_unicode_tolower(CuTest * tc)
{
char buffer[32];
CuAssertIntEquals(tc, 0, unicode_utf8_tolower(buffer, sizeof(buffer), "HeLlO W0Rld"));
CuAssertStrEquals(tc, "hello w0rld", buffer);
memset(buffer, 0, sizeof(buffer));
buffer[5]='X';
CuAssertIntEquals(tc, ENOMEM, unicode_utf8_tolower(buffer, 5, "HeLlO W0Rld"));
CuAssertStrEquals(tc, "helloX", buffer);
}
CuSuite *get_unicode_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_unicode_tolower);
return suite;
}