Add unicode.h to distribution. Add actual tests for old Unicode functions.

This commit is contained in:
Michael Jumper 2013-08-05 15:05:52 -07:00
parent ec22bb9010
commit 3137f54178
4 changed files with 32 additions and 4 deletions

View File

@ -50,12 +50,12 @@ libguacinc_HEADERS = \
guacamole/protocol.h \ guacamole/protocol.h \
guacamole/socket.h \ guacamole/socket.h \
guacamole/stream.h \ guacamole/stream.h \
guacamole/timestamp.h guacamole/timestamp.h \
guacamole/unicode.h
noinst_HEADERS = \ noinst_HEADERS = \
client-handlers.h \ client-handlers.h \
palette.h \ palette.h
unicode.h
libguac_la_SOURCES = \ libguac_la_SOURCES = \
client.c \ client.c \

View File

@ -37,9 +37,29 @@
#include <CUnit/Basic.h> #include <CUnit/Basic.h>
#include <guacamole/unicode.h>
#include "util_suite.h" #include "util_suite.h"
void test_guac_unicode() { 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);*/
} }

View File

@ -38,6 +38,14 @@
#ifndef _GUAC_TEST_UTIL_SUITE_H #ifndef _GUAC_TEST_UTIL_SUITE_H
#define _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(); int register_util_suite();
void test_guac_pool(); void test_guac_pool();