Fix Unicode tests.
This commit is contained in:
parent
3137f54178
commit
8e08a72eda
@ -43,20 +43,22 @@
|
||||
void test_guac_unicode() {
|
||||
|
||||
/* 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]));
|
||||
CU_ASSERT_EQUAL(1, guac_utf8_charsize(UTF8_1b[0]));
|
||||
CU_ASSERT_EQUAL(2, guac_utf8_charsize(UTF8_2b[0]));
|
||||
CU_ASSERT_EQUAL(3, guac_utf8_charsize(UTF8_3b[0]));
|
||||
CU_ASSERT_EQUAL(4, guac_utf8_charsize(UTF8_4b[0]));
|
||||
|
||||
/* 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));
|
||||
CU_ASSERT_EQUAL(0, guac_utf8_strlen(""));
|
||||
CU_ASSERT_EQUAL(1, guac_utf8_strlen(UTF8_4b));
|
||||
CU_ASSERT_EQUAL(2, guac_utf8_strlen(UTF8_4b UTF8_1b));
|
||||
CU_ASSERT_EQUAL(2, guac_utf8_strlen(UTF8_2b UTF8_3b));
|
||||
CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_1b UTF8_3b UTF8_4b));
|
||||
CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_2b UTF8_1b UTF8_3b));
|
||||
CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_4b UTF8_2b UTF8_1b));
|
||||
CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_3b UTF8_4b UTF8_2b));
|
||||
CU_ASSERT_EQUAL(5, guac_utf8_strlen("hello"));
|
||||
CU_ASSERT_EQUAL(9, guac_utf8_strlen("guacamole"));
|
||||
|
||||
/*int guac_utf8_write(int codepoint, char* utf8, int length);
|
||||
int guac_utf8_read(const char* utf8, int length, int* codepoint);*/
|
||||
|
@ -40,11 +40,10 @@
|
||||
|
||||
/* 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 */
|
||||
#define UTF8_1b "g" /* One byte */
|
||||
#define UTF8_2b "\xc4\xa3" /* Two bytes */
|
||||
#define UTF8_3b "\xe7\x8a\xac" /* Three bytes */
|
||||
#define UTF8_4b "\xf0\x90\x84\xa3" /* Four bytes */
|
||||
|
||||
int register_util_suite();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user