14 // |
14 // |
15 |
15 |
16 #undef G_DISABLE_ASSERT |
16 #undef G_DISABLE_ASSERT |
17 #undef G_LOG_DOMAIN |
17 #undef G_LOG_DOMAIN |
18 |
18 |
|
19 #include <sys/stat.h> |
19 #include <glib.h> |
20 #include <glib.h> |
20 #include <errno.h> |
21 #include <errno.h> |
21 #define LOG_FILE "c:\\logs\\utf8_string_log.txt" |
22 #include <glib/gprintf.h> |
22 #include "std_log_result.h" |
23 #ifdef __SYMBIAN32__ |
23 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
24 #include "mrt2_glib2_test.h" |
24 |
25 #endif /*__SYMBIAN32__*/ |
25 void create_xml(int result) |
|
26 { |
|
27 if(result) |
|
28 assert_failed = 1; |
|
29 |
|
30 testResultXml("utf8_string_log"); |
|
31 close_log_file(); |
|
32 } |
|
33 |
26 |
34 int main (int argc, char *argv[]) |
27 int main (int argc, char *argv[]) |
35 { |
28 { |
36 gchar *src = "TestString"; |
29 gchar *src = "TestString"; |
37 gchar dest[20]; |
30 gchar dest[20]; |
38 gchar *p; |
31 gchar *p; |
|
32 #ifdef __SYMBIAN32__ |
|
33 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); |
|
34 g_set_print_handler(mrtPrintHandler); |
|
35 #endif /*__SYMBIAN32__*/ |
39 |
36 |
|
37 g_print("Test utf8-string Start"); |
40 p = g_utf8_strncpy(dest, src, strlen(src)); |
38 p = g_utf8_strncpy(dest, src, strlen(src)); |
41 |
39 |
42 if(p == dest) |
40 if(p == dest) |
43 { |
41 { |
44 if(strcmp(dest, src)) |
42 if(strcmp(dest, src)) |
45 { |
43 { |
46 std_log(LOG_FILENAME_LINE,"g_utf8_strncpy didnt work as expected"); |
44 g_print("g_utf8_strncpy didnt work as expected"); |
47 assert_failed = 1; |
45 assert_failed = 1; |
48 } |
46 } |
49 } |
47 } |
50 else |
48 else |
51 { |
49 { |
52 std_log(LOG_FILENAME_LINE,"g_utf8_strncpy's return value is invalid"); |
50 g_print("g_utf8_strncpy's return value is invalid"); |
53 assert_failed = 1; |
51 assert_failed = 1; |
54 } |
52 } |
55 |
53 |
56 p = NULL; |
54 p = NULL; |
57 p = g_utf8_strrchr(src, strlen(src), 't'); |
55 p = g_utf8_strrchr(src, strlen(src), 't'); |
58 if(strcmp(p, "tring")) |
56 if(strcmp(p, "tring")) |
59 { |
57 { |
60 std_log(LOG_FILENAME_LINE,"g_utf8_strrchr didnt work as expected"); |
58 g_print("g_utf8_strrchr didnt work as expected"); |
61 assert_failed = 1; |
59 assert_failed = 1; |
62 } |
60 } |
63 |
61 |
64 if(assert_failed) |
62 if(assert_failed) |
65 std_log(LOG_FILENAME_LINE,"Test Failed"); |
63 g_print("Test utf8-string Failed"); |
66 else |
64 else |
67 std_log(LOG_FILENAME_LINE,"Test Successful"); |
65 g_print("Test utf8-string Successful"); |
68 |
66 |
69 create_xml(0); |
67 #if __SYMBIAN32__ |
|
68 testResultXml("utf8-string"); |
|
69 #endif /* EMULATOR */ |
70 |
70 |
71 return 0; |
71 return 0; |
72 } |
72 } |