diff --git a/icu4c/source/test/cintltst/trietest.c b/icu4c/source/test/cintltst/trietest.c index 89d8fc9970..3231879a21 100644 --- a/icu4c/source/test/cintltst/trietest.c +++ b/icu4c/source/test/cintltst/trietest.c @@ -18,6 +18,7 @@ #include "unicode/utypes.h" #include "utrie.h" #include "cstring.h" +#include "cmemory.h" #if 1 #include "cintltst.h" @@ -48,8 +49,11 @@ typedef struct CheckRange { UChar32 limit; uint32_t value; } CheckRange; +struct{ + double bogus; /* needed for aligining the storage */ + uint8_t storage[10000000]; +} storageHolder; -static uint8_t storage[100000]; static uint32_t U_CALLCONV _testFoldedValue32(UNewTrie *trie, UChar32 start, int32_t offset) { @@ -252,7 +256,7 @@ testTrieIteration(const char *testName, } static void -testTrieRanges(const char *testName, +testTrieRangesWithMalloc(const char *testName, const SetRange setRanges[], int32_t countSetRanges, const CheckRange checkRanges[], int32_t countCheckRanges, UBool dataIs32, UBool latin1Linear) { @@ -265,6 +269,8 @@ testTrieRanges(const char *testName, int32_t i, length; UErrorCode errorCode; UBool overwrite, ok; + uint8_t* storage =NULL; + storage = (uint8_t*) uprv_malloc(sizeof(uint8_t)*100000); log_verbose("\ntesting Trie '%s'\n", testName); newTrie=utrie_open(NULL, NULL, 2000, checkRanges[0].value, latin1Linear); @@ -309,7 +315,7 @@ testTrieRanges(const char *testName, } errorCode=U_ZERO_ERROR; - length=utrie_serialize(newTrie, storage, sizeof(storage), + length=utrie_serialize(newTrie, storage, 1000000, dataIs32 ? _testFoldedValue32 : _testFoldedValue16, (UBool)!dataIs32, &errorCode); @@ -431,6 +437,190 @@ testTrieRanges(const char *testName, } } + testTrieIteration(testName, &trie, checkRanges, countCheckRanges); + uprv_free(storage); +} + +static void +testTrieRanges(const char *testName, + const SetRange setRanges[], int32_t countSetRanges, + const CheckRange checkRanges[], int32_t countCheckRanges, + UBool dataIs32, UBool latin1Linear) { + UTrieGetFoldingOffset *getFoldingOffset; + const CheckRange *enumRanges; + UNewTrie *newTrie; + UTrie trie={ 0 }; + uint32_t value, value2; + UChar32 start, limit; + int32_t i, length; + UErrorCode errorCode; + UBool overwrite, ok; + + log_verbose("\ntesting Trie '%s'\n", testName); + newTrie=utrie_open(NULL, NULL, 2000, checkRanges[0].value, latin1Linear); + + /* set values from setRanges[] */ + ok=TRUE; + for(i=0; i