diff --git a/src/libguac/Makefile.am b/src/libguac/Makefile.am index a6724eb1..c50c6643 100644 --- a/src/libguac/Makefile.am +++ b/src/libguac/Makefile.am @@ -50,12 +50,12 @@ libguacinc_HEADERS = \ guacamole/protocol.h \ guacamole/socket.h \ guacamole/stream.h \ - guacamole/timestamp.h + guacamole/timestamp.h \ + guacamole/unicode.h noinst_HEADERS = \ client-handlers.h \ - palette.h \ - unicode.h + palette.h libguac_la_SOURCES = \ client.c \ diff --git a/src/libguac/unicode.h b/src/libguac/guacamole/unicode.h similarity index 100% rename from src/libguac/unicode.h rename to src/libguac/guacamole/unicode.h diff --git a/tests/util/guac_unicode.c b/tests/util/guac_unicode.c index bcf655cf..592fcb72 100644 --- a/tests/util/guac_unicode.c +++ b/tests/util/guac_unicode.c @@ -37,9 +37,29 @@ #include +#include #include "util_suite.h" void test_guac_unicode() { - /* STUB */ + + /* Test character length */ + CU_ASSERT_EQUAL(1, guac_utf8_charsize(UTF8_1[1])); + CU_ASSERT_EQUAL(2, guac_utf8_charsize(UTF8_2[1])); + CU_ASSERT_EQUAL(3, guac_utf8_charsize(UTF8_3[1])); + CU_ASSERT_EQUAL(4, guac_utf8_charsize(UTF8_4[1])); + + /* Test string length */ + CU_ASSERT_EQUAL(0, guac_utf8_strlen("")); + CU_ASSERT_EQUAL(4, guac_utf8_strlen(UTF8_4)); + CU_ASSERT_EQUAL(5, guac_utf8_strlen(UTF8_1 UTF8_3 UTF8_1)); + CU_ASSERT_EQUAL(5, guac_utf8_strlen("hello")); + CU_ASSERT_EQUAL(6, guac_utf8_strlen(UTF8_2 UTF8_1 UTF8_3)); + CU_ASSERT_EQUAL(8, guac_utf8_strlen(UTF8_8)); + CU_ASSERT_EQUAL(9, guac_utf8_strlen("guacamole")); + CU_ASSERT_EQUAL(11, guac_utf8_strlen(UTF8_2 UTF8_1 UTF8_8)); + + /*int guac_utf8_write(int codepoint, char* utf8, int length); + int guac_utf8_read(const char* utf8, int length, int* codepoint);*/ + } diff --git a/tests/util/util_suite.h b/tests/util/util_suite.h index 07d50564..301032db 100644 --- a/tests/util/util_suite.h +++ b/tests/util/util_suite.h @@ -38,6 +38,14 @@ #ifndef _GUAC_TEST_UTIL_SUITE_H #define _GUAC_TEST_UTIL_SUITE_H +/* Unicode (UTF-8) strings */ + +#define UTF8_1 "\xe7\x8a\xac" /* One character */ +#define UTF8_2 UTF8_1 "\xf0\x90\xac\x80" /* Two characters */ +#define UTF8_3 UTF8_2 "z" /* Three characters */ +#define UTF8_4 UTF8_3 "\xc3\xa1" /* Four characters */ +#define UTF8_8 UTF8_4 UTF8_4 /* Eight characters */ + int register_util_suite(); void test_guac_pool();