sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* This library is free software; you can redistribute it and/or
|
sl@0
|
5 |
* modify it under the terms of the GNU Lesser General Public
|
sl@0
|
6 |
* License as published by the Free Software Foundation; either
|
sl@0
|
7 |
* version 2 of the License, or (at your option) any later version.
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* This library is distributed in the hope that it will be useful,
|
sl@0
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
sl@0
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
sl@0
|
12 |
* Lesser General Public License for more details.
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* You should have received a copy of the GNU Lesser General Public
|
sl@0
|
15 |
* License along with this library; if not, write to the
|
sl@0
|
16 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
sl@0
|
17 |
* Boston, MA 02111-1307, USA.
|
sl@0
|
18 |
*
|
sl@0
|
19 |
* Description: ?Description
|
sl@0
|
20 |
*
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
#undef G_DISABLE_ASSERT
|
sl@0
|
25 |
#undef G_LOG_DOMAIN
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <stdio.h>
|
sl@0
|
29 |
#include <string.h>
|
sl@0
|
30 |
#include <glib.h>
|
sl@0
|
31 |
#include <fcntl.h>
|
sl@0
|
32 |
#include <goption.h>
|
sl@0
|
33 |
#include <stdlib.h>
|
sl@0
|
34 |
|
sl@0
|
35 |
#ifdef SYMBIAN
|
sl@0
|
36 |
#include "mrt2_glib2_test.h"
|
sl@0
|
37 |
#endif /*SYMBIAN*/
|
sl@0
|
38 |
|
sl@0
|
39 |
#define C2P(c) ((gpointer) ((long) (c)))
|
sl@0
|
40 |
#define GINT_TO_POINTER(i) ((gpointer) (i))
|
sl@0
|
41 |
#define GPOINTER_TO_INT(p) ((gint) (p))
|
sl@0
|
42 |
#define TESTPASS 1
|
sl@0
|
43 |
#define TESTFAIL 0
|
sl@0
|
44 |
|
sl@0
|
45 |
//Test for tg_unichar_type
|
sl@0
|
46 |
void tg_unichar_type()
|
sl@0
|
47 |
{
|
sl@0
|
48 |
g_assert (g_unichar_type (0x41) == G_UNICODE_UPPERCASE_LETTER);
|
sl@0
|
49 |
g_assert (g_unichar_type (0x63) == G_UNICODE_LOWERCASE_LETTER);
|
sl@0
|
50 |
g_assert (g_unichar_type (0x30) == G_UNICODE_DECIMAL_NUMBER);
|
sl@0
|
51 |
g_assert (g_unichar_type (0x2d) == G_UNICODE_DASH_PUNCTUATION);
|
sl@0
|
52 |
g_assert (g_unichar_type (0x24) == G_UNICODE_CURRENCY_SYMBOL);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
//Test for tg_unichar_break_type
|
sl@0
|
56 |
void tg_unichar_break_type()
|
sl@0
|
57 |
{
|
sl@0
|
58 |
|
sl@0
|
59 |
g_assert (g_unichar_break_type (0x0d) == G_UNICODE_BREAK_CARRIAGE_RETURN);
|
sl@0
|
60 |
g_assert (g_unichar_break_type (0x0a) == G_UNICODE_BREAK_LINE_FEED);
|
sl@0
|
61 |
g_assert (g_unichar_break_type (0x20) == G_UNICODE_BREAK_SPACE);
|
sl@0
|
62 |
g_assert (g_unichar_break_type (0x2d) == G_UNICODE_BREAK_HYPHEN);
|
sl@0
|
63 |
g_assert (g_unichar_break_type (0x21) == G_UNICODE_BREAK_EXCLAMATION);
|
sl@0
|
64 |
g_assert (g_unichar_break_type (0x31) == G_UNICODE_BREAK_NUMERIC);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
//Test for g_unichar_get_mirror_char
|
sl@0
|
68 |
void tg_unichar_get_mirror_char()
|
sl@0
|
69 |
{
|
sl@0
|
70 |
gunichar* res = (gunichar*)malloc (sizeof (gunichar));
|
sl@0
|
71 |
g_assert (g_unichar_get_mirror_char (0x28,res));
|
sl@0
|
72 |
g_assert (g_unichar_get_mirror_char (0x5b,res));
|
sl@0
|
73 |
g_assert (g_unichar_get_mirror_char (0x3c,res));
|
sl@0
|
74 |
g_assert (!g_unichar_get_mirror_char (0x10,res));
|
sl@0
|
75 |
free (res);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
|
sl@0
|
79 |
//Test for g_unichar_isdefined
|
sl@0
|
80 |
void tg_unichar_isdefined()
|
sl@0
|
81 |
{
|
sl@0
|
82 |
g_assert (g_unichar_isdefined (0x5a)); //Valid
|
sl@0
|
83 |
g_assert (!g_unichar_isdefined (0xFFFF)); //Invalid
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
//Test for g_unichar_istitle
|
sl@0
|
87 |
void tg_unichar_istitle()
|
sl@0
|
88 |
{
|
sl@0
|
89 |
g_assert(g_unichar_istitle(0x01C5)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
|
sl@0
|
90 |
g_assert(g_unichar_istitle(0x01C8)); //LATIN CAPITAL LETTER L WITH SMALL LETTER J
|
sl@0
|
91 |
g_assert(g_unichar_istitle(0x01CB)); //LATIN CAPITAL LETTER N WITH SMALL LETTER J
|
sl@0
|
92 |
g_assert(g_unichar_istitle(0x01F2)); //LATIN CAPITAL LETTER D WITH SMALL LETTER Z
|
sl@0
|
93 |
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
//Test for g_unichar_iswide
|
sl@0
|
97 |
void tg_unichar_iswide()
|
sl@0
|
98 |
{
|
sl@0
|
99 |
char ip1 = 'a';
|
sl@0
|
100 |
wchar_t ip2 = 0x1101;
|
sl@0
|
101 |
g_assert(!g_unichar_iswide(ip1));
|
sl@0
|
102 |
g_assert(g_unichar_iswide(ip2));
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
//Test for g_unichar_totitle
|
sl@0
|
106 |
void tg_unichar_totitle()
|
sl@0
|
107 |
{
|
sl@0
|
108 |
g_assert(g_unichar_totitle('A')==65);
|
sl@0
|
109 |
g_assert(g_unichar_totitle('a')==65);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
void tg_unicode_canonical_ordering()
|
sl@0
|
113 |
{
|
sl@0
|
114 |
unsigned int ip[] =
|
sl@0
|
115 |
{
|
sl@0
|
116 |
0x24,0x28,0x69,0x2c,0x34,0x4a,0x5d
|
sl@0
|
117 |
};
|
sl@0
|
118 |
g_unicode_canonical_ordering (ip ,7);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
int main (int argc,char *argv[])
|
sl@0
|
122 |
{
|
sl@0
|
123 |
|
sl@0
|
124 |
#ifdef SYMBIAN
|
sl@0
|
125 |
|
sl@0
|
126 |
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);
|
sl@0
|
127 |
#endif /*SYMBIAN*/
|
sl@0
|
128 |
|
sl@0
|
129 |
tg_unichar_type();
|
sl@0
|
130 |
tg_unichar_break_type();
|
sl@0
|
131 |
tg_unichar_get_mirror_char();
|
sl@0
|
132 |
tg_unichar_isdefined();
|
sl@0
|
133 |
tg_unichar_istitle();
|
sl@0
|
134 |
tg_unichar_iswide();
|
sl@0
|
135 |
tg_unichar_totitle();
|
sl@0
|
136 |
tg_unicode_canonical_ordering();
|
sl@0
|
137 |
#ifdef SYMBIAN
|
sl@0
|
138 |
testResultXml("tunichar");
|
sl@0
|
139 |
#endif /* EMULATOR */
|
sl@0
|
140 |
return 0;
|
sl@0
|
141 |
} |