diff options
author | Michal Čihař <nijel@debian.org> | 2015-03-02 15:23:11 +0100 |
---|---|---|
committer | Michal Čihař <nijel@debian.org> | 2015-03-02 15:23:11 +0100 |
commit | d6bda2f410c01a5b4aab018955fb539f5f28aca1 (patch) | |
tree | fc15fbc5bdc7523f064d6c224ae91072a849b0ef /tests | |
parent | a288f916607f050221fab9e5164955797dc6b803 (diff) |
Imported Upstream version 1.35.0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/at-dispatch.c | 2 | ||||
-rw-r--r-- | tests/utf-8.c | 46 |
3 files changed, 52 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ab1f57..56f8e61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,6 +44,11 @@ add_executable(array-test array-test.c) target_link_libraries (array-test array) add_test(array "${GAMMU_TEST_PATH}/array-test${GAMMU_TEST_SUFFIX}") +# UTF-8 manipulation tests +add_executable(utf-8 utf-8.c) +target_link_libraries (utf-8 libGammu) +add_test(utf-8 "${GAMMU_TEST_PATH}/utf-8${GAMMU_TEST_SUFFIX}") + # SQL backend date parsing if (HAVE_MYSQL_MYSQL_H OR LIBDBI_FOUND OR HAVE_POSTGRESQL_LIBPQ_FE_H) if (LIBDBI_FOUND) diff --git a/tests/at-dispatch.c b/tests/at-dispatch.c index d307d95..76d6a86 100644 --- a/tests/at-dispatch.c +++ b/tests/at-dispatch.c @@ -72,7 +72,7 @@ int main(int argc UNUSED, char **argv UNUSED) s->Phone.Data.RequestID = ID_GetSignalQuality; s->Phone.Data.SignalQuality = &Signal; - do_test("AT+CSQ\r\nAT+CSQ\r\n+CME ERROR: 515", AT_Reply_CMEError, ERR_UNKNOWN); + do_test("AT+CSQ\r\nAT+CSQ\r\n+CME ERROR: 515", AT_Reply_CMEError, ERR_BUSY); s->Phone.Data.RequestID = ID_SetMemoryType; do_test("AT+CPMS=\"ME\"\rAT+CPMS=\"ME\"\r\r\n+CPMS: 2,300,2,300,2,300\r\n\r\n+CPMS: 2,300,2,300,2,300\r\n\r\nOK\r\n", AT_Reply_OK, ERR_NONE); diff --git a/tests/utf-8.c b/tests/utf-8.c new file mode 100644 index 0000000..e2e3c2f --- /dev/null +++ b/tests/utf-8.c @@ -0,0 +1,46 @@ +/** + * Simple test case for UTF-8 conversions. + */ + +#include "common.h" +#include <gammu.h> +#include <gammu-unicode.h> + +int main(int argc UNUSED, char **argv UNUSED) +{ + unsigned char out[20]; + + test_result(EncodeWithUTF8Alphabet(0x24, out) == 1); + test_result(out[0] == 0x24); + + test_result(EncodeWithUTF8Alphabet(0xa2, out) == 2); + test_result(out[0] == 0xc2); + test_result(out[1] == 0xa2); + + test_result(EncodeWithUTF8Alphabet(0x20ac, out) == 3); + test_result(out[0] == 0xe2); + test_result(out[1] == 0x82); + test_result(out[2] == 0xac); + + test_result(EncodeWithUTF8Alphabet(0x10348, out) == 4); + test_result(out[0] == 0xf0); + test_result(out[1] == 0x90); + test_result(out[2] == 0x8d); + test_result(out[3] == 0x88); + + test_result(EncodeWithUTF8Alphabet(0x1F44D, out) == 4); + test_result(out[0] == 0xf0); + test_result(out[1] == 0x9f); + test_result(out[2] == 0x91); + test_result(out[3] == 0x8d); + + test_result(EncodeUTF8(out, "\xD8\x3d\xDC\x4d\x00\x00")); + test_result(out[0] == 0xf0); + test_result(out[1] == 0x9f); + test_result(out[2] == 0x91); + test_result(out[3] == 0x8d); + test_result(out[4] == 0x00); + + return 0; +} + |