From 2c9d62de49d6eb26e8c760d83b14ccb9a8d8cb71 Mon Sep 17 00:00:00 2001 From: Madhu K Date: Thu, 13 Jul 2000 22:43:29 +0000 Subject: [PATCH] ICU-447 Additional tests for extended code coverage X-SVN-Rev: 1870 --- icu4c/source/test/cintltst/Makefile.in | 3 +- icu4c/source/test/cintltst/cintltst.dsp | 4 ++ icu4c/source/test/cintltst/cstrtest.c | 90 +++++++++++++++++++++++++ icu4c/source/test/cintltst/cutiltst.c | 2 + 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 icu4c/source/test/cintltst/cstrtest.c diff --git a/icu4c/source/test/cintltst/Makefile.in b/icu4c/source/test/cintltst/Makefile.in index 084968ce55..3755d625a3 100644 --- a/icu4c/source/test/cintltst/Makefile.in +++ b/icu4c/source/test/cintltst/Makefile.in @@ -68,7 +68,8 @@ cdattst.o cdetst.o cdtdptst.o cdtrgtst.o cestst.o cfintst.o cformtst.o \ cfrtst.o cg7coll.o chashtst.o cintltst.o citertst.o cjaptst.o cloctst.o cmsgtst.o \ cnmdptst.o cnormtst.o cnumtst.o cregrtst.o crestst.o creststn.o cturtst.o \ cucdtst.o cutiltst.o encoll.o nucnvtst.o susctest.o nccbtst.o \ -cbiditst.o cbididat.o eurocreg.o udatatst.o utf16tst.o utransts.o ncnvfbts.o ncnvtst.o putiltst.o +cbiditst.o cbididat.o eurocreg.o udatatst.o utf16tst.o utransts.o \ +ncnvfbts.o ncnvtst.o putiltst.o cstrtest.o DEPS = $(OBJECTS:.o=.d) diff --git a/icu4c/source/test/cintltst/cintltst.dsp b/icu4c/source/test/cintltst/cintltst.dsp index 604fdae839..53c4295033 100644 --- a/icu4c/source/test/cintltst/cintltst.dsp +++ b/icu4c/source/test/cintltst/cintltst.dsp @@ -224,6 +224,10 @@ SOURCE=.\creststn.c # End Source File # Begin Source File +SOURCE=.\cstrtest.c +# End Source File +# Begin Source File + SOURCE=.\cturtst.c # End Source File # Begin Source File diff --git a/icu4c/source/test/cintltst/cstrtest.c b/icu4c/source/test/cintltst/cstrtest.c new file mode 100644 index 0000000000..21c014ac7b --- /dev/null +++ b/icu4c/source/test/cintltst/cstrtest.c @@ -0,0 +1,90 @@ +/* +********************************************************************** +* Copyright (C) 1998-2000, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File cstrtest.c +* +* Modification History: +* +* Date Name Description +* 07/13/2000 Madhu created +******************************************************************************* +*/ + + +#include "cstring.h" +#include "cintltst.h" + +static void TestAPI(void); + +void addCStringTest(TestNode** root) { + + addTest(root, &TestAPI, "tsutil/cstrtest/TestAPI"); + +} + +void TestAPI(void) +{ + + int32_t intValue=0; + char src[30]="HELLO THERE"; + const char *temp; + + log_verbose("Testing the API in cstring\n"); + T_CString_toLowerCase(src); + if(uprv_strcmp(src, "hello there") != 0){ + log_err("FAIL: *** T_CString_toLowerCase() failed. Expected: \"hello there\", Got: \"%s\"\n", src); + } + T_CString_toUpperCase(src); + if(uprv_strcmp(src, "HELLO THERE") != 0){ + log_err("FAIL: *** T_CString_toUpperCase() failed. Expected: \"HELLO THERE\", Got: \"%s\"\n", src); + } + + intValue=T_CString_stringToInteger("34556", 10); + if(intValue != 34556){ + log_err("FAIL: ****T_CString_stringToInteger(\"34556\", 10) failed. Expected: 34556, Got: %d\n", intValue); + } + intValue=T_CString_stringToInteger("100", 16); + if(intValue != 256){ + log_err("FAIL: ****T_CString_stringToInteger(\"100\", 16) failed. Expected: 256, Got: %d\n", intValue); + } + T_CString_integerToString(src, 34556, 10); + if(uprv_strcmp(src, "34556") != 0){ + log_err("FAIL: ****integerToString(src, 34566, 10); failed. Expected: \"34556\", Got: %s\n", src); + } + T_CString_integerToString(src, 256, 16); + if(uprv_strcmp(src, "100") != 0){ + log_err("FAIL: ****integerToString(src, 256, 16); failed. Expected: \"100\", Got: %s\n", src); + } + + uprv_strcpy(src, "this is lower case"); + if(T_CString_stricmp(src, "THIS is lower CASE") != 0){ + log_err("FAIL: *****T_CString_stricmp() failed."); + } + if((intValue=T_CString_stricmp(NULL, "first string is null") )!= -1){ + log_err("FAIL: T_CString_stricmp() where the first string is null failed. Expected: -1, returned %d\n", intValue); + } + if((intValue=T_CString_stricmp("second string is null", NULL)) != 1){ + log_err("FAIL: T_CString_stricmp() where the second string is null failed. Expected: 1, returned %d\n", intValue); + } + if((intValue=T_CString_stricmp(NULL, NULL)) != 0){ + log_err("FAIL: T_CString_stricmp(NULL, NULL) failed. Expected: 0, returned %d\n", intValue);; + } + if((intValue=T_CString_stricmp("", "")) != 0){ + log_err("FAIL: T_CString_stricmp(\"\", \"\") failed. Expected: 0, returned %d\n", intValue);; + } + if((intValue=T_CString_stricmp("", "abc")) != -1){ + log_err("FAIL: T_CString_stricmp(\"\", \"abc\") failed. Expected: -1, returned %d\n", intValue); + } + if((intValue=T_CString_stricmp("abc", "")) != 1){ + log_err("FAIL: T_CString_stricmp(\"abc\", \"\") failed. Expected: 1, returned %d\n", intValue); + } + + temp=uprv_strdup("strdup"); + if(uprv_strcmp(temp, "strdup") !=0 ){ + log_err("FAIL: uprv_strdup() failed. Expected: \"strdup\", Got: %s\n", temp); + } + +} \ No newline at end of file diff --git a/icu4c/source/test/cintltst/cutiltst.c b/icu4c/source/test/cintltst/cutiltst.c index 1ee782f125..f2655647ad 100644 --- a/icu4c/source/test/cintltst/cutiltst.c +++ b/icu4c/source/test/cintltst/cutiltst.c @@ -20,6 +20,7 @@ void addResourceBundleTest(TestNode**); void addNEWResourceBundleTest(TestNode**); void addSCSUTest(TestNode** root); void addHashtableTest(TestNode** root); +void addCStringTest(TestNode** root); void addUtility(TestNode** root) { @@ -29,5 +30,6 @@ void addUtility(TestNode** root) addNEWResourceBundleTest(root); addSCSUTest(root); addHashtableTest(root); + addCStringTest(root); }