Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Description: ?Description
24 #undef G_DISABLE_ASSERT
36 #include "mrt2_glib2_test.h"
41 void tg_utf8_prev_char()
46 gchar *g_utf8_prev_char_op;
49 fp = fopen ("c:\\utf8_hindi.txt","r");
50 while ( L'\n' != (ip[i] = fgetwc (fp)))
55 g_utf8_prev_char_op = g_utf8_prev_char (input);
56 g_assert ( g_utf8_prev_char_op[0] == 0x15);
59 void tg_utf8_offset_to_pointer()
64 gchar *g_utf8_offset_to_pointer_op;
67 fp = fopen ("c:\\utf8_hindi.txt","r");
68 while ( L'\n' != (ip[i] = fgetwc (fp)))
73 g_utf8_offset_to_pointer_op = g_utf8_offset_to_pointer (input ,6);
74 g_assert ( g_utf8_offset_to_pointer_op[0] == 0x24);
77 void tg_utf8_pointer_to_offset()
82 glong g_utf8_pointer_to_offset_op;
86 fp = fopen ("c:\\utf8_hindi.txt","r");
87 while ( L'\n' != (ip[i] = fgetwc (fp)))
93 g_utf8_pointer_to_offset_op = g_utf8_pointer_to_offset (input ,feed);
94 g_assert ( g_utf8_pointer_to_offset_op == 6);
97 void tg_utf8_strncpy()
105 0x15,0x24,0x1A,0x41,0x30
107 fp = fopen ("c:\\utf8_hindi.txt","r");
108 while ( L'\n' != (ip[i] = fgetwc (fp)))
112 g_utf8_strncpy (feed ,&ip[1] ,5);
116 g_assert (feed[i] == op[i]);
120 void tg_utf8_strrchr()
126 gchar *g_utf8_strrchr_op;
128 fp = fopen ("c:\\utf8_hindi.txt","r");
129 while ( L'\n' != (ip[i] = fgetwc (fp)))
134 g_utf8_strrchr_op = g_utf8_strrchr (input ,-1 , 0x1A);
135 g_assert (g_utf8_strrchr_op[1] == 0x41);
138 void tg_utf8_collate_key_for_filename()
140 gchar input[] = "ptr.txt";
141 gchar *g_utf8_collate_key_for_filename_op;
142 g_utf8_collate_key_for_filename_op = g_utf8_collate_key_for_filename (input ,6);
143 g_assert (g_utf8_collate_key_for_filename_op[0] == 'A');
146 void tg_filename_from_utf8()
152 gsize bytes_read = 0;
153 gsize bytes_written = 0;
154 gchar *g_filename_from_utf8_op;
157 0x15,0x24,0x1A,0x41,0x30
160 fp = fopen ("c:\\utf8_hindi.txt","r");
161 while ( L'\n' != (ip[i] = fgetwc (fp)))
166 g_filename_from_utf8_op = g_filename_from_utf8 (input ,5 ,&bytes_read ,&bytes_written ,NULL);
170 g_assert (g_filename_from_utf8_op[i] == op[i]);
175 void tg_filename_to_utf8()
181 gsize bytes_read = 0;
182 gsize bytes_written = 0;
183 gchar *g_filename_to_utf8_op;
186 0x15,0x24,0x1A,0x41,0x30
189 fp = fopen ("c:\\utf8_hindi.txt","r");
190 while ( L'\n' != (ip[i] = fgetwc (fp)))
195 g_filename_to_utf8_op = g_filename_to_utf8 (input ,5 ,&bytes_read ,&bytes_written ,NULL);
199 g_assert (g_filename_to_utf8_op[i] == op[i]);
203 int main (int argc,char *argv[])
208 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);
211 tg_utf8_prev_char ();
212 tg_utf8_offset_to_pointer();
213 tg_utf8_pointer_to_offset();
216 tg_utf8_collate_key_for_filename();
217 tg_filename_from_utf8();
218 tg_filename_to_utf8();
220 testResultXml("tutf8");
221 #endif /* EMULATOR */