os/ossrv/glib/tsrc/BC/src/unichar_test.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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:
sl@0
    20
*
sl@0
    21
*/
sl@0
    22
sl@0
    23
sl@0
    24
sl@0
    25
#undef G_DISABLE_ASSERT
sl@0
    26
#undef G_LOG_DOMAIN
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 <stdlib.h>
sl@0
    32
#include <glib/gprintf.h>
sl@0
    33
sl@0
    34
#ifdef SYMBIAN
sl@0
    35
#include "mrt2_glib2_test.h"
sl@0
    36
#endif /*SYMBIAN*/
sl@0
    37
sl@0
    38
sl@0
    39
sl@0
    40
gboolean res;
sl@0
    41
sl@0
    42
void g_unichar_digit_value_test()
sl@0
    43
{
sl@0
    44
	gunichar str='a';
sl@0
    45
	gunichar dig='7';
sl@0
    46
	   int i;
sl@0
    47
    i=g_unichar_digit_value(str);
sl@0
    48
    if(i!=-1)
sl@0
    49
	{
sl@0
    50
		g_printf("g_unichar_digit_value failed,str ='a' \n");
sl@0
    51
		g_assert(FALSE && "g_unichar_digit_value failed str ='a'\n");
sl@0
    52
	}
sl@0
    53
    
sl@0
    54
    i=g_unichar_digit_value(dig);
sl@0
    55
    if(i!=7 || i==-1)
sl@0
    56
	{
sl@0
    57
		g_print("g_unichar_digit_value failed,str ='7' \n");
sl@0
    58
		g_assert(FALSE && "g_unichar_digit_value failed str ='7'\n");
sl@0
    59
	}
sl@0
    60
 
sl@0
    61
}
sl@0
    62
sl@0
    63
void g_unichar_isalnum_test()
sl@0
    64
{
sl@0
    65
	gunichar str='8';
sl@0
    66
   	res=g_unichar_isalnum(str);
sl@0
    67
    if(res!=TRUE)
sl@0
    68
	{
sl@0
    69
		g_print("g_unichar_isalnum failed,str ='8' \n");
sl@0
    70
		g_assert(FALSE && "g_unichar_isalnum failed\n");
sl@0
    71
	}
sl@0
    72
 
sl@0
    73
}
sl@0
    74
sl@0
    75
void g_unichar_iscntrl_test()
sl@0
    76
{
sl@0
    77
	gunichar str ='\n';
sl@0
    78
	res=g_unichar_iscntrl(str);
sl@0
    79
	if(res!=TRUE)
sl@0
    80
	{
sl@0
    81
		g_print("g_unichar_iscntrl failed,str ='\n' \n");
sl@0
    82
		g_assert(FALSE && "g_unichar_iscntrl failed\n");
sl@0
    83
	}
sl@0
    84
	//g_assert(res==TRUE);
sl@0
    85
	str='a';
sl@0
    86
	res=g_unichar_iscntrl(str);
sl@0
    87
	if(res==TRUE)
sl@0
    88
	{
sl@0
    89
		g_print("g_unichar_iscntrl failed , str ='a'\n");
sl@0
    90
		g_assert(FALSE && "g_unichar_iscntrl failed\n");
sl@0
    91
	}
sl@0
    92
	//g_assert(g_unichar_iscntrl(str)==FALSE);
sl@0
    93
}
sl@0
    94
sl@0
    95
sl@0
    96
sl@0
    97
void g_unichar_isdigit_test()
sl@0
    98
{
sl@0
    99
	gunichar str ='6';
sl@0
   100
	res=g_unichar_isdigit(str);
sl@0
   101
	if(res!=TRUE)
sl@0
   102
	{
sl@0
   103
		g_print("g_unichar_isdigit failed,str ='\n' \n");
sl@0
   104
		g_assert(FALSE && "g_unichar_isdigit failed\n");
sl@0
   105
	}
sl@0
   106
	//g_assert(res==TRUE);
sl@0
   107
	str='a';
sl@0
   108
	res=g_unichar_isdigit(str);
sl@0
   109
	if(res==TRUE)
sl@0
   110
	{
sl@0
   111
		g_print("g_unichar_iscntrl failed , str ='a'\n");
sl@0
   112
		g_assert(FALSE && "g_unichar_iscntrl failed\n");
sl@0
   113
	}
sl@0
   114
	//g_assert(g_unichar_iscntrl(str)==FALSE);
sl@0
   115
}
sl@0
   116
sl@0
   117
sl@0
   118
void g_unichar_islower_test()
sl@0
   119
{
sl@0
   120
	gunichar str ='a';
sl@0
   121
	res=g_unichar_islower(str);
sl@0
   122
	if(res!=TRUE)
sl@0
   123
	{
sl@0
   124
		g_print("g_unichar_islower failed,str ='\n' \n");
sl@0
   125
		g_assert(FALSE && "g_unichar_islower failed\n");
sl@0
   126
	}
sl@0
   127
	//g_assert(res==TRUE);
sl@0
   128
	str='A';
sl@0
   129
	res=g_unichar_islower(str);
sl@0
   130
	if(res==TRUE)
sl@0
   131
	{
sl@0
   132
		g_print("g_unichar_islower failed , str ='a'\n");
sl@0
   133
		g_assert(FALSE && "g_unichar_islower failed\n");
sl@0
   134
	}
sl@0
   135
}
sl@0
   136
sl@0
   137
void g_unichar_ispunct_test()
sl@0
   138
{
sl@0
   139
	gunichar str ='!';
sl@0
   140
	res=g_unichar_ispunct(str);
sl@0
   141
	if(res!=TRUE)
sl@0
   142
	{
sl@0
   143
		g_print("g_unichar_ispunct failed,str ='\n' \n");
sl@0
   144
		g_assert(FALSE && "g_unichar_ispunct failed\n");
sl@0
   145
	}
sl@0
   146
	//g_assert(res==TRUE);
sl@0
   147
	str='A';
sl@0
   148
	res=g_unichar_ispunct(str);
sl@0
   149
	if(res==TRUE)
sl@0
   150
	{
sl@0
   151
		g_print("g_unichar_ispunct failed , str ='a'\n");
sl@0
   152
		g_assert(FALSE && "g_unichar_ispunct failed\n");
sl@0
   153
	}
sl@0
   154
}
sl@0
   155
sl@0
   156
sl@0
   157
void g_unichar_isupper_test()
sl@0
   158
{
sl@0
   159
	gunichar str ='A';
sl@0
   160
	res=g_unichar_isupper(str);
sl@0
   161
	if(res!=TRUE)
sl@0
   162
	{
sl@0
   163
		g_print("g_unichar_isupper failed '\n' \n");
sl@0
   164
		g_assert(FALSE && "g_unichar_isupper failed\n");
sl@0
   165
	}
sl@0
   166
	//g_assert(res==TRUE);
sl@0
   167
	str='a';
sl@0
   168
	res=g_unichar_isupper(str);
sl@0
   169
	if(res==TRUE)
sl@0
   170
	{
sl@0
   171
		g_print("g_unichar_isupper failed \n");
sl@0
   172
		g_assert(FALSE && "g_unichar_isupper failed\n");
sl@0
   173
	}
sl@0
   174
}
sl@0
   175
sl@0
   176
void g_unichar_isxdigit_test()
sl@0
   177
{
sl@0
   178
	gunichar str ='e';
sl@0
   179
	res=g_unichar_isxdigit(str);
sl@0
   180
	if(res!=TRUE)
sl@0
   181
	{
sl@0
   182
		g_print("g_unichar_isxdigit failed '\n' \n");
sl@0
   183
		g_assert(FALSE && "g_unichar_isxdigit failed\n");
sl@0
   184
	}
sl@0
   185
	//g_assert(res==TRUE);
sl@0
   186
	str='k';
sl@0
   187
	res=g_unichar_isxdigit(str);
sl@0
   188
	if(res==TRUE)
sl@0
   189
	{
sl@0
   190
		g_print("g_unichar_isxdigit failed \n");
sl@0
   191
		g_assert(FALSE && "g_unichar_isxdigit failed\n");
sl@0
   192
	}
sl@0
   193
}
sl@0
   194
sl@0
   195
void g_unichar_xdigit_value_test()
sl@0
   196
{
sl@0
   197
	int i;
sl@0
   198
	gunichar str ='e';
sl@0
   199
    i=g_unichar_xdigit_value(str);
sl@0
   200
	if(i!=14 || i==-1)
sl@0
   201
	{
sl@0
   202
		g_print("g_unichar_xdigit_value failed  \n");
sl@0
   203
		g_assert(FALSE && "g_unichar_xdigit_value failed\n");
sl@0
   204
	}
sl@0
   205
	
sl@0
   206
	str='4';
sl@0
   207
	i=g_unichar_xdigit_value(str);
sl@0
   208
	if(i!=4 || i==-1)
sl@0
   209
	{
sl@0
   210
		g_print("g_unichar_xdigit_value failed  \n");
sl@0
   211
		g_assert(FALSE && "g_unichar_xdigit_value failed\n");
sl@0
   212
	}
sl@0
   213
	
sl@0
   214
	
sl@0
   215
	//g_assert(res==TRUE);
sl@0
   216
	str='k';
sl@0
   217
	i=g_unichar_xdigit_value(str);
sl@0
   218
	if(i!=-1)
sl@0
   219
	{
sl@0
   220
		g_print("g_unichar_xdigit_value failed \n");
sl@0
   221
		g_assert(FALSE && "g_unichar_xdigit_value failed\n");
sl@0
   222
	}
sl@0
   223
}
sl@0
   224
sl@0
   225
sl@0
   226
void g_unichar_isgraph_test()
sl@0
   227
{
sl@0
   228
	gunichar str ='e';
sl@0
   229
    res=g_unichar_isgraph(str);
sl@0
   230
	if(res!=TRUE)
sl@0
   231
	{
sl@0
   232
		g_print("g_unichar_isgraph failed '\n' \n");
sl@0
   233
		g_assert(FALSE && "g_unichar_isgraph failed\n");
sl@0
   234
	}
sl@0
   235
	//g_assert(res==TRUE);
sl@0
   236
	str=' ';
sl@0
   237
	res=g_unichar_isgraph(str);
sl@0
   238
	if(res==TRUE)
sl@0
   239
	{
sl@0
   240
		g_print("g_unichar_isgraph failed \n");
sl@0
   241
		g_assert(FALSE && "g_unichar_isgraph failed\n");
sl@0
   242
	}
sl@0
   243
}
sl@0
   244
sl@0
   245
void g_unichar_isspace_test()
sl@0
   246
{
sl@0
   247
	gunichar str ='\t';
sl@0
   248
    res=g_unichar_isspace(str);
sl@0
   249
	if(res!=TRUE)
sl@0
   250
	{
sl@0
   251
		g_print("g_unichar_isspace failed '\n' \n");
sl@0
   252
		g_assert(FALSE && "g_unichar_isspace failed\n");
sl@0
   253
	}
sl@0
   254
	//g_assert(res==TRUE);
sl@0
   255
	str='5';
sl@0
   256
	res=g_unichar_isspace(str);
sl@0
   257
	if(res==TRUE)
sl@0
   258
	{
sl@0
   259
		g_print("g_unichar_isspace failed \n");
sl@0
   260
		g_assert(FALSE && "g_unichar_isspace failed\n");
sl@0
   261
	}
sl@0
   262
}
sl@0
   263
sl@0
   264
void g_unichar_isprint_test()
sl@0
   265
{
sl@0
   266
	gunichar str1=' ';
sl@0
   267
	gboolean res1;
sl@0
   268
	gunichar str2='a';
sl@0
   269
	res=g_unichar_isprint(str1);
sl@0
   270
	res1=g_unichar_isprint(str2);
sl@0
   271
	if(res!=TRUE || res1!=TRUE)
sl@0
   272
	{
sl@0
   273
		g_print("g_unichar_isprint failed\n");
sl@0
   274
		g_assert(FALSE && "g_unichar_isprint failed\n");
sl@0
   275
	}
sl@0
   276
	str1='\t';
sl@0
   277
	res=g_unichar_isprint(str1);
sl@0
   278
	if (res==TRUE)
sl@0
   279
	{
sl@0
   280
	    g_print("g_unichar_isprint failed\n");
sl@0
   281
		g_assert(FALSE && "g_unichar_isprint failed\n");
sl@0
   282
		
sl@0
   283
	}
sl@0
   284
sl@0
   285
}
sl@0
   286
sl@0
   287
sl@0
   288
int main (int   argc,
sl@0
   289
      char *argv[])
sl@0
   290
{
sl@0
   291
	#ifdef SYMBIAN
sl@0
   292
	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
   293
	#endif /*SYMBIAN*/
sl@0
   294
	
sl@0
   295
	g_unichar_digit_value_test();
sl@0
   296
	g_unichar_isalnum_test();
sl@0
   297
	g_unichar_iscntrl_test();
sl@0
   298
	g_unichar_islower_test();
sl@0
   299
	g_unichar_isupper_test();
sl@0
   300
	g_unichar_isxdigit_test();	
sl@0
   301
	g_unichar_xdigit_value_test();
sl@0
   302
	g_unichar_isgraph_test();
sl@0
   303
	g_unichar_ispunct_test();
sl@0
   304
	g_unichar_isspace_test();
sl@0
   305
	g_unichar_isdigit_test();
sl@0
   306
	g_unichar_isprint_test();
sl@0
   307
sl@0
   308
sl@0
   309
	#ifdef SYMBIAN
sl@0
   310
  	testResultXml("unichar_test");
sl@0
   311
  	#endif /* EMULATOR */
sl@0
   312
	
sl@0
   313
	return 0;
sl@0
   314
}