sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General Public sl@0: * License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place - Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: #include sl@0: #include sl@0: #include "glib.h" sl@0: #include sl@0: #include sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: sl@0: sl@0: gboolean res; sl@0: sl@0: void g_unichar_digit_value_test() sl@0: { sl@0: gunichar str='a'; sl@0: gunichar dig='7'; sl@0: int i; sl@0: i=g_unichar_digit_value(str); sl@0: if(i!=-1) sl@0: { sl@0: g_printf("g_unichar_digit_value failed,str ='a' \n"); sl@0: g_assert(FALSE && "g_unichar_digit_value failed str ='a'\n"); sl@0: } sl@0: sl@0: i=g_unichar_digit_value(dig); sl@0: if(i!=7 || i==-1) sl@0: { sl@0: g_print("g_unichar_digit_value failed,str ='7' \n"); sl@0: g_assert(FALSE && "g_unichar_digit_value failed str ='7'\n"); sl@0: } sl@0: sl@0: } sl@0: sl@0: void g_unichar_isalnum_test() sl@0: { sl@0: gunichar str='8'; sl@0: res=g_unichar_isalnum(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_isalnum failed,str ='8' \n"); sl@0: g_assert(FALSE && "g_unichar_isalnum failed\n"); sl@0: } sl@0: sl@0: } sl@0: sl@0: void g_unichar_iscntrl_test() sl@0: { sl@0: gunichar str ='\n'; sl@0: res=g_unichar_iscntrl(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_iscntrl failed,str ='\n' \n"); sl@0: g_assert(FALSE && "g_unichar_iscntrl failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='a'; sl@0: res=g_unichar_iscntrl(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_iscntrl failed , str ='a'\n"); sl@0: g_assert(FALSE && "g_unichar_iscntrl failed\n"); sl@0: } sl@0: //g_assert(g_unichar_iscntrl(str)==FALSE); sl@0: } sl@0: sl@0: sl@0: sl@0: void g_unichar_isdigit_test() sl@0: { sl@0: gunichar str ='6'; sl@0: res=g_unichar_isdigit(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_isdigit failed,str ='\n' \n"); sl@0: g_assert(FALSE && "g_unichar_isdigit failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='a'; sl@0: res=g_unichar_isdigit(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_iscntrl failed , str ='a'\n"); sl@0: g_assert(FALSE && "g_unichar_iscntrl failed\n"); sl@0: } sl@0: //g_assert(g_unichar_iscntrl(str)==FALSE); sl@0: } sl@0: sl@0: sl@0: void g_unichar_islower_test() sl@0: { sl@0: gunichar str ='a'; sl@0: res=g_unichar_islower(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_islower failed,str ='\n' \n"); sl@0: g_assert(FALSE && "g_unichar_islower failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='A'; sl@0: res=g_unichar_islower(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_islower failed , str ='a'\n"); sl@0: g_assert(FALSE && "g_unichar_islower failed\n"); sl@0: } sl@0: } sl@0: sl@0: void g_unichar_ispunct_test() sl@0: { sl@0: gunichar str ='!'; sl@0: res=g_unichar_ispunct(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_ispunct failed,str ='\n' \n"); sl@0: g_assert(FALSE && "g_unichar_ispunct failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='A'; sl@0: res=g_unichar_ispunct(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_ispunct failed , str ='a'\n"); sl@0: g_assert(FALSE && "g_unichar_ispunct failed\n"); sl@0: } sl@0: } sl@0: sl@0: sl@0: void g_unichar_isupper_test() sl@0: { sl@0: gunichar str ='A'; sl@0: res=g_unichar_isupper(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_isupper failed '\n' \n"); sl@0: g_assert(FALSE && "g_unichar_isupper failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='a'; sl@0: res=g_unichar_isupper(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_isupper failed \n"); sl@0: g_assert(FALSE && "g_unichar_isupper failed\n"); sl@0: } sl@0: } sl@0: sl@0: void g_unichar_isxdigit_test() sl@0: { sl@0: gunichar str ='e'; sl@0: res=g_unichar_isxdigit(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_isxdigit failed '\n' \n"); sl@0: g_assert(FALSE && "g_unichar_isxdigit failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='k'; sl@0: res=g_unichar_isxdigit(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_isxdigit failed \n"); sl@0: g_assert(FALSE && "g_unichar_isxdigit failed\n"); sl@0: } sl@0: } sl@0: sl@0: void g_unichar_xdigit_value_test() sl@0: { sl@0: int i; sl@0: gunichar str ='e'; sl@0: i=g_unichar_xdigit_value(str); sl@0: if(i!=14 || i==-1) sl@0: { sl@0: g_print("g_unichar_xdigit_value failed \n"); sl@0: g_assert(FALSE && "g_unichar_xdigit_value failed\n"); sl@0: } sl@0: sl@0: str='4'; sl@0: i=g_unichar_xdigit_value(str); sl@0: if(i!=4 || i==-1) sl@0: { sl@0: g_print("g_unichar_xdigit_value failed \n"); sl@0: g_assert(FALSE && "g_unichar_xdigit_value failed\n"); sl@0: } sl@0: sl@0: sl@0: //g_assert(res==TRUE); sl@0: str='k'; sl@0: i=g_unichar_xdigit_value(str); sl@0: if(i!=-1) sl@0: { sl@0: g_print("g_unichar_xdigit_value failed \n"); sl@0: g_assert(FALSE && "g_unichar_xdigit_value failed\n"); sl@0: } sl@0: } sl@0: sl@0: sl@0: void g_unichar_isgraph_test() sl@0: { sl@0: gunichar str ='e'; sl@0: res=g_unichar_isgraph(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_isgraph failed '\n' \n"); sl@0: g_assert(FALSE && "g_unichar_isgraph failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str=' '; sl@0: res=g_unichar_isgraph(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_isgraph failed \n"); sl@0: g_assert(FALSE && "g_unichar_isgraph failed\n"); sl@0: } sl@0: } sl@0: sl@0: void g_unichar_isspace_test() sl@0: { sl@0: gunichar str ='\t'; sl@0: res=g_unichar_isspace(str); sl@0: if(res!=TRUE) sl@0: { sl@0: g_print("g_unichar_isspace failed '\n' \n"); sl@0: g_assert(FALSE && "g_unichar_isspace failed\n"); sl@0: } sl@0: //g_assert(res==TRUE); sl@0: str='5'; sl@0: res=g_unichar_isspace(str); sl@0: if(res==TRUE) sl@0: { sl@0: g_print("g_unichar_isspace failed \n"); sl@0: g_assert(FALSE && "g_unichar_isspace failed\n"); sl@0: } sl@0: } sl@0: sl@0: void g_unichar_isprint_test() sl@0: { sl@0: gunichar str1=' '; sl@0: gboolean res1; sl@0: gunichar str2='a'; sl@0: res=g_unichar_isprint(str1); sl@0: res1=g_unichar_isprint(str2); sl@0: if(res!=TRUE || res1!=TRUE) sl@0: { sl@0: g_print("g_unichar_isprint failed\n"); sl@0: g_assert(FALSE && "g_unichar_isprint failed\n"); sl@0: } sl@0: str1='\t'; sl@0: res=g_unichar_isprint(str1); sl@0: if (res==TRUE) sl@0: { sl@0: g_print("g_unichar_isprint failed\n"); sl@0: g_assert(FALSE && "g_unichar_isprint failed\n"); sl@0: sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: int main (int argc, sl@0: char *argv[]) sl@0: { sl@0: #ifdef SYMBIAN sl@0: 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: #endif /*SYMBIAN*/ sl@0: sl@0: g_unichar_digit_value_test(); sl@0: g_unichar_isalnum_test(); sl@0: g_unichar_iscntrl_test(); sl@0: g_unichar_islower_test(); sl@0: g_unichar_isupper_test(); sl@0: g_unichar_isxdigit_test(); sl@0: g_unichar_xdigit_value_test(); sl@0: g_unichar_isgraph_test(); sl@0: g_unichar_ispunct_test(); sl@0: g_unichar_isspace_test(); sl@0: g_unichar_isdigit_test(); sl@0: g_unichar_isprint_test(); sl@0: sl@0: sl@0: #ifdef SYMBIAN sl@0: testResultXml("unichar_test"); sl@0: #endif /* EMULATOR */ sl@0: sl@0: return 0; sl@0: }