ICU-489 added tests for new types
X-SVN-Rev: 1796
This commit is contained in:
parent
55cc3f3d3f
commit
ce3dd236b4
@ -164,6 +164,7 @@ void addNEWResourceBundleTest(TestNode** root)
|
||||
addTest(root, &TestResourceBundles, "tsutil/creststn/TestResourceBundle");
|
||||
addTest(root, &TestFallback, "tsutil/creststn/TestFallback");
|
||||
addTest(root, &TestAliasConflict, "tsutil/creststn/TestAlias");
|
||||
addTest(root, &TestNewTypes, "tsutil/creststn/TestNewTypes");
|
||||
|
||||
}
|
||||
|
||||
@ -188,6 +189,78 @@ void TestAliasConflict(void) {
|
||||
ures_close(he);
|
||||
}
|
||||
|
||||
void TestNewTypes() {
|
||||
UResourceBundle* theBundle = NULL;
|
||||
char action[256];
|
||||
char testdatapath[256];
|
||||
const char* directory = ctest_getTestDirectory();
|
||||
UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR;
|
||||
UResourceBundle* res = NULL;
|
||||
uint8_t *binResult = NULL;
|
||||
int32_t len = 0;
|
||||
int32_t i = 0;
|
||||
int32_t intResult = 0;
|
||||
|
||||
strcpy(action, "Construction of testtypes bundle");
|
||||
|
||||
strcpy(testdatapath, directory);
|
||||
strcat(testdatapath, "testdata");
|
||||
theBundle = ures_open(testdatapath, "testtypes", &status);
|
||||
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
|
||||
CONFIRM_INT_NE(theBundle, NULL);
|
||||
|
||||
strcpy(action, "getting and testing of binary type");
|
||||
res = ures_getByKey(theBundle, "binarytest", res, &status);
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(ures_getType(res), RES_BINARY);
|
||||
binResult=(uint8_t*)ures_getBinary(res, &len, &status);
|
||||
if(U_SUCCESS(status)){
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(len, 15);
|
||||
for(i = 0; i<15; i++) {
|
||||
CONFIRM_INT_EQ(binResult[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(action, "getting and testing of imported binary type");
|
||||
res = ures_getByKey(theBundle, "importtest", res, &status);
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(ures_getType(res), RES_BINARY);
|
||||
binResult=(uint8_t*)ures_getBinary(res, &len, &status);
|
||||
if(U_SUCCESS(status)){
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(len, 15);
|
||||
for(i = 0; i<15; i++) {
|
||||
CONFIRM_INT_EQ(binResult[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(action, "getting and testing of integer types");
|
||||
res = ures_getByKey(theBundle, "one", res, &status);
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(ures_getType(res), RES_INT);
|
||||
intResult=ures_getInt(res, &status);
|
||||
if(U_SUCCESS(status)){
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(intResult, 1);
|
||||
}
|
||||
|
||||
res = ures_getByKey(theBundle, "onehundredtwentythree", res, &status);
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(ures_getType(res), RES_INT);
|
||||
intResult=ures_getInt(res, &status);
|
||||
if(U_SUCCESS(status)){
|
||||
CONFIRM_ErrorCode(status, U_ZERO_ERROR);
|
||||
CONFIRM_INT_EQ(intResult, 123);
|
||||
}
|
||||
|
||||
ures_close(res);
|
||||
ures_close(theBundle);
|
||||
|
||||
}
|
||||
|
||||
void TestBinaryCollationData(){
|
||||
UErrorCode status=U_ZERO_ERROR;
|
||||
const char* directory=NULL;
|
||||
|
@ -36,9 +36,11 @@
|
||||
|
||||
static void TestAliasConflict(void);
|
||||
|
||||
static void TestFallback(void);
|
||||
static void TestFallback(void);
|
||||
|
||||
static void TestBinaryCollationData(void);
|
||||
static void TestBinaryCollationData(void);
|
||||
|
||||
static void TestNewTypes(void);
|
||||
|
||||
|
||||
|
||||
|
BIN
icu4c/source/test/testdata/importtest.txt
vendored
Normal file
BIN
icu4c/source/test/testdata/importtest.txt
vendored
Normal file
Binary file not shown.
23
icu4c/source/test/testdata/testtypes.txt
vendored
Normal file
23
icu4c/source/test/testdata/testtypes.txt
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
//*******************************************************************************
|
||||
//*
|
||||
//* Copyright (C) 1998-2000, International Business Machines
|
||||
//* Corporation and others. All Rights Reserved.
|
||||
//*
|
||||
//*******************************************************************************
|
||||
|
||||
|
||||
// This is a test resource to check new types of resources
|
||||
|
||||
testtypes
|
||||
{
|
||||
zerotest { "abc\u0000def" } // The length of this string should be 7, not 3
|
||||
binarytest:bin { 000102030405060708090a0b0c0d0e } // Binary 15 bytes long
|
||||
onehundredtwentythree:int { 123 } //
|
||||
one:int { 1 } // number one
|
||||
importtest:import { "importtest.txt" }
|
||||
// integerarray:intarray { 1, 2, 3, 4, 5, 6, 7 } // This will be done in the future
|
||||
}
|
||||
|
||||
//eof
|
||||
|
||||
|
@ -73,7 +73,8 @@ RES_FILES = $(TXT_FILES:$(top_srcdir)/../data/%.txt=@DATABUILDDIR@/%.res)
|
||||
#TRANSLIT_RES = $(TRANSLIT_SOURCE:%.txt=@DATABUILDDIR@/translit/%.res)
|
||||
TEST_FILES = @DATABUILDDIR@/../source/test/testdata/root.res \
|
||||
@DATABUILDDIR@/../source/test/testdata/te.res \
|
||||
@DATABUILDDIR@/../source/test/testdata/te_IN.res
|
||||
@DATABUILDDIR@/../source/test/testdata/te_IN.res \
|
||||
@DATABUILDDIR@/../source/test/testdata/testtypes.res
|
||||
|
||||
## List of phony targets
|
||||
.PHONY : all all-local install install-local clean clean-local \
|
||||
|
@ -155,20 +155,20 @@ LINK32_TESTDATA_FLAGS = /out:"$(TESTDATA)/testdata.dll" /DLL /NOENTRY
|
||||
testdata.dll : $(TESTDATA)testdata.dll
|
||||
@cd $(TESTDATA)
|
||||
|
||||
$(TESTDATA)testdata.dll : $(TESTDATA)root_res.obj $(TESTDATA)te_res.obj $(TESTDATA)te_IN_res.obj
|
||||
$(TESTDATA)testdata.dll : $(TESTDATA)root_res.obj $(TESTDATA)te_res.obj $(TESTDATA)te_IN_res.obj $(TESTDATA)testtypes_res.obj
|
||||
@echo Creating DLL file
|
||||
@cd $(TESTDATA)
|
||||
@$(LINK32) @<<
|
||||
$(LINK32_TESTDATA_FLAGS) root_res.obj te_res.obj te_IN_res.obj
|
||||
$(LINK32_TESTDATA_FLAGS) root_res.obj te_res.obj te_IN_res.obj testtypes_res.obj
|
||||
<<
|
||||
|
||||
$(TESTDATA)root_res.c $(TESTDATA)te_res.c $(TESTDATA)te_IN_res.c : $(TESTDATA)root.res $(TESTDATA)te.res $(TESTDATA)te_IN.res
|
||||
$(TESTDATA)root_res.c $(TESTDATA)te_res.c $(TESTDATA)te_IN_res.c $(TESTDATA)testtypes_res.c: $(TESTDATA)root.res $(TESTDATA)te.res $(TESTDATA)te_IN.res $(TESTDATA)testtypes.res
|
||||
@echo generating .c file for testdata
|
||||
@cd $(TESTDATA)
|
||||
@$(ICUTOOLS)\genccode\$(CFG)\genccode $?
|
||||
|
||||
#Targets for testdata.dat
|
||||
#testdata.dat : $(TESTDATA)root.res $(TESTDATA)te.res $(TESTDATA)te_IN.res
|
||||
#testdata.dat : $(TESTDATA)root.res $(TESTDATA)te.res $(TESTDATA)te_IN.res $(TESTDATA)testtypes.res
|
||||
# @echo Creating testdata.dat
|
||||
# @set ICU_DATA=$(ICUDATA)
|
||||
# @cd $(TESTDATA)
|
||||
@ -176,6 +176,7 @@ $(TESTDATA)root_res.c $(TESTDATA)te_res.c $(TESTDATA)te_IN_res.c : $(TESTDATA)ro
|
||||
#root.res
|
||||
#te.res
|
||||
#te_IN.res
|
||||
#testtypes.res
|
||||
#<<
|
||||
|
||||
# Targets for test.dat
|
||||
|
Loading…
Reference in New Issue
Block a user