os/ossrv/glib/tsrc/BC/src/tunichar.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/glib/tsrc/BC/src/tunichar.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,141 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     1.6 +*
     1.7 +* This library is free software; you can redistribute it and/or
     1.8 +* modify it under the terms of the GNU Lesser General Public
     1.9 +* License as published by the Free Software Foundation; either
    1.10 +* version 2 of the License, or (at your option) any later version.
    1.11 +*
    1.12 +* This library is distributed in the hope that it will be useful,
    1.13 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.15 +* Lesser General Public License for more details.
    1.16 +*
    1.17 +* You should have received a copy of the GNU Lesser General Public
    1.18 +* License along with this library; if not, write to the
    1.19 +* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    1.20 +* Boston, MA 02111-1307, USA.
    1.21 +*
    1.22 +* Description:  ?Description
    1.23 +*
    1.24 +*/
    1.25 +
    1.26 +
    1.27 +#undef G_DISABLE_ASSERT
    1.28 +#undef G_LOG_DOMAIN
    1.29 +
    1.30 +
    1.31 +#include <stdio.h>
    1.32 +#include <string.h>
    1.33 +#include <glib.h>
    1.34 +#include <fcntl.h>
    1.35 +#include <goption.h>
    1.36 +#include <stdlib.h>
    1.37 +
    1.38 +#ifdef SYMBIAN
    1.39 +#include "mrt2_glib2_test.h"
    1.40 +#endif /*SYMBIAN*/
    1.41 +
    1.42 +#define	C2P(c)		((gpointer) ((long) (c)))
    1.43 +#define GINT_TO_POINTER(i)	((gpointer)  (i))
    1.44 +#define GPOINTER_TO_INT(p)	((gint)   (p))
    1.45 +#define TESTPASS	1
    1.46 +#define TESTFAIL	0
    1.47 +
    1.48 +//Test for tg_unichar_type
    1.49 +void tg_unichar_type()
    1.50 +{
    1.51 + 	g_assert (g_unichar_type (0x41) == G_UNICODE_UPPERCASE_LETTER);
    1.52 + 	g_assert (g_unichar_type (0x63) == G_UNICODE_LOWERCASE_LETTER);
    1.53 + 	g_assert (g_unichar_type (0x30) == G_UNICODE_DECIMAL_NUMBER);
    1.54 + 	g_assert (g_unichar_type (0x2d) == G_UNICODE_DASH_PUNCTUATION);
    1.55 + 	g_assert (g_unichar_type (0x24) == G_UNICODE_CURRENCY_SYMBOL);
    1.56 +}
    1.57 +
    1.58 +//Test for tg_unichar_break_type
    1.59 +void tg_unichar_break_type()
    1.60 +{
    1.61 +
    1.62 +	g_assert (g_unichar_break_type (0x0d) == G_UNICODE_BREAK_CARRIAGE_RETURN);
    1.63 +	g_assert (g_unichar_break_type (0x0a) == G_UNICODE_BREAK_LINE_FEED);
    1.64 +	g_assert (g_unichar_break_type (0x20) == G_UNICODE_BREAK_SPACE);
    1.65 +	g_assert (g_unichar_break_type (0x2d) == G_UNICODE_BREAK_HYPHEN);
    1.66 +	g_assert (g_unichar_break_type (0x21) == G_UNICODE_BREAK_EXCLAMATION);
    1.67 +	g_assert (g_unichar_break_type (0x31) == G_UNICODE_BREAK_NUMERIC);
    1.68 +}
    1.69 +
    1.70 +//Test for g_unichar_get_mirror_char
    1.71 +void tg_unichar_get_mirror_char()
    1.72 +{
    1.73 +	gunichar* res = (gunichar*)malloc (sizeof (gunichar));
    1.74 +	g_assert (g_unichar_get_mirror_char (0x28,res));
    1.75 +	g_assert (g_unichar_get_mirror_char (0x5b,res));
    1.76 +	g_assert (g_unichar_get_mirror_char (0x3c,res));
    1.77 +	g_assert (!g_unichar_get_mirror_char (0x10,res));
    1.78 + 	free (res);
    1.79 +}
    1.80 +
    1.81 +
    1.82 +//Test for g_unichar_isdefined
    1.83 +void tg_unichar_isdefined()
    1.84 +{
    1.85 +	g_assert (g_unichar_isdefined (0x5a)); //Valid
    1.86 +	g_assert (!g_unichar_isdefined (0xFFFF)); //Invalid
    1.87 +}
    1.88 +
    1.89 +//Test for g_unichar_istitle
    1.90 +void tg_unichar_istitle()
    1.91 +{
    1.92 +	g_assert(g_unichar_istitle(0x01C5));	//LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
    1.93 +	g_assert(g_unichar_istitle(0x01C8));	//LATIN CAPITAL LETTER L WITH SMALL LETTER J
    1.94 +	g_assert(g_unichar_istitle(0x01CB)); 	//LATIN CAPITAL LETTER N WITH SMALL LETTER J
    1.95 +	g_assert(g_unichar_istitle(0x01F2)); 	//LATIN CAPITAL LETTER D WITH SMALL LETTER Z
    1.96 +
    1.97 +}
    1.98 +
    1.99 +//Test for g_unichar_iswide
   1.100 +void tg_unichar_iswide()
   1.101 +{
   1.102 +	char ip1 = 'a';
   1.103 +	wchar_t ip2 = 0x1101;
   1.104 +	g_assert(!g_unichar_iswide(ip1));
   1.105 +	g_assert(g_unichar_iswide(ip2));
   1.106 +}
   1.107 +
   1.108 +//Test for g_unichar_totitle
   1.109 +void tg_unichar_totitle()
   1.110 +{
   1.111 +	g_assert(g_unichar_totitle('A')==65);
   1.112 +	g_assert(g_unichar_totitle('a')==65);
   1.113 +}
   1.114 +
   1.115 +void tg_unicode_canonical_ordering()
   1.116 +{
   1.117 +	unsigned int ip[] = 
   1.118 +	{
   1.119 +		0x24,0x28,0x69,0x2c,0x34,0x4a,0x5d
   1.120 +	};
   1.121 +	g_unicode_canonical_ordering (ip ,7);
   1.122 +}
   1.123 +
   1.124 +int main (int argc,char *argv[])
   1.125 +{
   1.126 +
   1.127 +	#ifdef SYMBIAN
   1.128 +
   1.129 + 	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);
   1.130 + 	#endif /*SYMBIAN*/
   1.131 + 	
   1.132 + 	tg_unichar_type();
   1.133 +	tg_unichar_break_type();
   1.134 +	tg_unichar_get_mirror_char();
   1.135 +	tg_unichar_isdefined();
   1.136 +	tg_unichar_istitle();
   1.137 +	tg_unichar_iswide();
   1.138 +	tg_unichar_totitle();
   1.139 + 	tg_unicode_canonical_ordering();
   1.140 + 	#ifdef SYMBIAN
   1.141 +  testResultXml("tunichar");
   1.142 +#endif /* EMULATOR */
   1.143 + 	return 0;
   1.144 +}
   1.145 \ No newline at end of file