/*
******************************************************************************
*
-* Copyright (C) 2001-2005, International Business Machines
+* Copyright (C) 2001-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
#include <stdio.h>
#include "unicode/utypes.h"
+#include "unicode/utf16.h"
#include "utrie.h"
#include "cstring.h"
#include "cmemory.h"
UChar32 limit;
uint32_t value;
} CheckRange;
-struct{
- double bogus; /* needed for aligining the storage */
- uint8_t storage[10000000];
-} storageHolder;
static uint32_t U_CALLCONV
c=checkRanges[i].limit;
if(c!=0) {
--c;
- UTF_APPEND_CHAR_UNSAFE(s, length, c);
+ U16_APPEND_UNSAFE(s, length, c);
values[countValues++]=checkRanges[i].value;
}
}
if(
c2==0 ?
c!=*(p-1) :
- !UTF_IS_LEAD(c) || !UTF_IS_TRAIL(c2) || c!=*(p-2) || c2!=*(p-1)
+ !U16_IS_LEAD(c) || !U16_IS_TRAIL(c2) || c!=*(p-2) || c2!=*(p-1)
) {
log_err("error: wrong (c, c2) from UTRIE_NEXT(%s): (U+%04lx, U+%04lx)\n",
testName, c, c2);
if(
c2==0 ?
c!=*p:
- !UTF_IS_LEAD(c) || !UTF_IS_TRAIL(c2) || c!=*p || c2!=*(p+1)
+ !U16_IS_LEAD(c) || !U16_IS_TRAIL(c2) || c!=*p || c2!=*(p+1)
) {
log_err("error: wrong (c, c2) from UTRIE_PREVIOUS(%s): (U+%04lx, U+%04lx)\n",
testName, c, c2);
UErrorCode errorCode;
UBool overwrite, ok;
uint8_t* storage =NULL;
- storage = (uint8_t*) uprv_malloc(sizeof(uint8_t)*100000);
+ static const int32_t DEFAULT_STORAGE_SIZE = 32768;
+ storage = (uint8_t*) uprv_malloc(sizeof(uint8_t)*DEFAULT_STORAGE_SIZE);
log_verbose("\ntesting Trie '%s'\n", testName);
newTrie=utrie_open(NULL, NULL, 2000,
}
errorCode=U_ZERO_ERROR;
- length=utrie_serialize(newTrie, storage, 1000000,
+ length=utrie_serialize(newTrie, storage, DEFAULT_STORAGE_SIZE,
dataIs32 ? _testFoldedValue32 : _testFoldedValue16,
(UBool)!dataIs32,
&errorCode);
log_err("error: unserialized trie(%s).fromBMP(U+%04lx)==0x%lx instead of 0x%lx\n",
testName, start, value2, value);
}
- if(!UTF_IS_LEAD(start)) {
+ if(!U16_IS_LEAD(start)) {
if(dataIs32) {
value2=UTRIE_GET32_FROM_LEAD(&trie, start);
} else {
const SetRange setRanges[], int32_t countSetRanges,
const CheckRange checkRanges[], int32_t countCheckRanges,
UBool dataIs32, UBool latin1Linear) {
+ union{
+ double bogus; /* needed for aligining the storage */
+ uint8_t storage[32768];
+ } storageHolder;
UTrieGetFoldingOffset *getFoldingOffset;
UNewTrieGetFoldedValue *getFoldedValue;
const CheckRange *enumRanges;
utrie_close(newTrie);
return;
}
+ if (length >= (int32_t)sizeof(storageHolder.storage)) {
+ log_err("error: utrie_serialize(%s) needs more memory\n", testName);
+ utrie_close(newTrie);
+ return;
+ }
/* test linear Latin-1 range from utrie_getData() */
if(latin1Linear) {
log_err("error: unserialized trie(%s).fromBMP(U+%04lx)==0x%lx instead of 0x%lx\n",
testName, start, value2, value);
}
- if(!UTF_IS_LEAD(start)) {
+ if(!U16_IS_LEAD(start)) {
if(dataIs32) {
value2=UTRIE_GET32_FROM_LEAD(&trie, start);
} else {
{0x2f800,0x2fedc, 0x7a, TRUE},
{0x72, 0xdd, 3, TRUE},
{0xdd, 0xde, 4, FALSE},
+ {0x201, 0x220, 6, TRUE}, /* 3 consecutive blocks with the same pattern but discontiguous value ranges */
+ {0x221, 0x240, 6, TRUE},
+ {0x241, 0x260, 6, TRUE},
{0x2f987,0x2fa98, 5, TRUE},
{0x2f777,0x2f833, 0, TRUE},
{0x2f900,0x2ffee, 1, FALSE},
{0x72, 0x5555},
{0xdd, 3},
{0xde, 4},
+ {0x201, 0},
+ {0x220, 6},
+ {0x221, 0},
+ {0x240, 6},
+ {0x241, 0},
+ {0x260, 6},
{0x2f833,0},
{0x2f987,0x7a},
{0x2fa98,5},
static void
dummyTest(UBool make16BitTrie) {
- static int32_t mem[UTRIE_DUMMY_SIZE/4];
+ int32_t mem[UTRIE_DUMMY_SIZE/4];
UTrie trie;
UErrorCode errorCode;