Index: source/test/intltest/ucharstrietest.cpp |
diff --git a/source/test/intltest/ucharstrietest.cpp b/source/test/intltest/ucharstrietest.cpp |
index 92f9bcee4c24f45be46d68c0ec5d62590a47cf67..fc24faab05785c3c57d13068564411ed5e0f85fd 100644 |
--- a/source/test/intltest/ucharstrietest.cpp |
+++ b/source/test/intltest/ucharstrietest.cpp |
@@ -1,6 +1,6 @@ |
/* |
******************************************************************************* |
-* Copyright (C) 2010-2013, International Business Machines |
+* Copyright (C) 2010-2014, International Business Machines |
* Corporation and others. All Rights Reserved. |
******************************************************************************* |
* file name: ucharstrietest.cpp |
@@ -22,8 +22,7 @@ |
#include "unicode/uniset.h" |
#include "unicode/unistr.h" |
#include "intltest.h" |
- |
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) |
+#include "cmemory.h" |
struct StringAndValue { |
const char *s; |
@@ -138,14 +137,14 @@ void UCharsTrieTest::TestEmpty() { |
static const StringAndValue data[]={ |
{ "", 0 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::Test_a() { |
static const StringAndValue data[]={ |
{ "a", 1 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::Test_a_ab() { |
@@ -153,7 +152,7 @@ void UCharsTrieTest::Test_a_ab() { |
{ "a", 1 }, |
{ "ab", 100 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestShortestBranch() { |
@@ -161,7 +160,7 @@ void UCharsTrieTest::TestShortestBranch() { |
{ "a", 1000 }, |
{ "b", 2000 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestBranches() { |
@@ -181,7 +180,7 @@ void UCharsTrieTest::TestBranches() { |
{ "vv", 0x7fffffff }, |
{ "zz", (int32_t)0x80000000 } |
}; |
- for(int32_t length=2; length<=LENGTHOF(data); ++length) { |
+ for(int32_t length=2; length<=UPRV_LENGTHOF(data); ++length) { |
logln("TestBranches length=%d", (int)length); |
checkData(data, length); |
} |
@@ -200,7 +199,7 @@ void UCharsTrieTest::TestLongSequence() { |
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -3 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestLongBranch() { |
@@ -228,7 +227,7 @@ void UCharsTrieTest::TestLongBranch() { |
{ "t234567890", 0x77777777 }, |
{ "z", (int32_t)0x80000001 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestValuesForState() { |
@@ -242,7 +241,7 @@ void UCharsTrieTest::TestValuesForState() { |
{ "abcde", -5 }, |
{ "abcdef", -6 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestCompact() { |
@@ -269,7 +268,7 @@ void UCharsTrieTest::TestCompact() { |
{ "xjuly", 7 }, |
{ "xjune", 6 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestFirstForCodePoint() { |
@@ -284,7 +283,7 @@ void UCharsTrieTest::TestFirstForCodePoint() { |
{ "\\U00050000xy", 8 }, |
{ "\\U00050000xyz", 9 } |
}; |
- checkData(data, LENGTHOF(data)); |
+ checkData(data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestNextForCodePoint() { |
@@ -293,7 +292,7 @@ void UCharsTrieTest::TestNextForCodePoint() { |
{ "\\u4dff\\U00010000\\u9999\\U00020002", 44444 }, |
{ "\\u4dff\\U000103ff", 99999 } |
}; |
- LocalPointer<UCharsTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST)); |
+ LocalPointer<UCharsTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST)); |
if(trie.isNull()) { |
return; // buildTrie() reported an error |
} |
@@ -457,7 +456,7 @@ UCharsTrie *UCharsTrieTest::buildMonthsTrie(UStringTrieBuildOption buildOption) |
{ "jun.", 6 }, |
{ "june", 6 } |
}; |
- return buildTrie(data, LENGTHOF(data), buildOption); |
+ return buildTrie(data, UPRV_LENGTHOF(data), buildOption); |
} |
void UCharsTrieTest::TestHasUniqueValue() { |
@@ -589,10 +588,10 @@ void UCharsTrieTest::TestIteratorFromBranch() { |
{ "uar", 1 }, |
{ "uary", 1 } |
}; |
- checkIterator(iter, data, LENGTHOF(data)); |
+ checkIterator(iter, data, UPRV_LENGTHOF(data)); |
// Reset, and we should get the same result. |
logln("after iter.reset()"); |
- checkIterator(iter.reset(), data, LENGTHOF(data)); |
+ checkIterator(iter.reset(), data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestIteratorFromLinearMatch() { |
@@ -617,10 +616,10 @@ void UCharsTrieTest::TestIteratorFromLinearMatch() { |
{ "r", 1 }, |
{ "ry", 1 } |
}; |
- checkIterator(iter, data, LENGTHOF(data)); |
+ checkIterator(iter, data, UPRV_LENGTHOF(data)); |
// Reset, and we should get the same result. |
logln("after iter.reset()"); |
- checkIterator(iter.reset(), data, LENGTHOF(data)); |
+ checkIterator(iter.reset(), data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestTruncatingIteratorFromRoot() { |
@@ -663,10 +662,10 @@ void UCharsTrieTest::TestTruncatingIteratorFromRoot() { |
{ "jun.", 6 }, |
{ "june", 6 } |
}; |
- checkIterator(iter, data, LENGTHOF(data)); |
+ checkIterator(iter, data, UPRV_LENGTHOF(data)); |
// Reset, and we should get the same result. |
logln("after iter.reset()"); |
- checkIterator(iter.reset(), data, LENGTHOF(data)); |
+ checkIterator(iter.reset(), data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchShort() { |
@@ -675,7 +674,7 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchShort() { |
{ "abcdepq", 200 }, |
{ "abcdeyz", 3000 } |
}; |
- LocalPointer<UCharsTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST)); |
+ LocalPointer<UCharsTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST)); |
if(trie.isNull()) { |
return; // buildTrie() reported an error |
} |
@@ -691,10 +690,10 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchShort() { |
static const StringAndValue expected[]={ |
{ "cd", -1 } |
}; |
- checkIterator(iter, expected, LENGTHOF(expected)); |
+ checkIterator(iter, expected, UPRV_LENGTHOF(expected)); |
// Reset, and we should get the same result. |
logln("after iter.reset()"); |
- checkIterator(iter.reset(), expected, LENGTHOF(expected)); |
+ checkIterator(iter.reset(), expected, UPRV_LENGTHOF(expected)); |
} |
void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchLong() { |
@@ -703,7 +702,7 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchLong() { |
{ "abcdepq", 200 }, |
{ "abcdeyz", 3000 } |
}; |
- LocalPointer<UCharsTrie> trie(buildTrie(data, LENGTHOF(data), USTRINGTRIE_BUILD_FAST)); |
+ LocalPointer<UCharsTrie> trie(buildTrie(data, UPRV_LENGTHOF(data), USTRINGTRIE_BUILD_FAST)); |
if(trie.isNull()) { |
return; // buildTrie() reported an error |
} |
@@ -722,10 +721,10 @@ void UCharsTrieTest::TestTruncatingIteratorFromLinearMatchLong() { |
{ "dep", -1 }, |
{ "dey", -1 } |
}; |
- checkIterator(iter, expected, LENGTHOF(expected)); |
+ checkIterator(iter, expected, UPRV_LENGTHOF(expected)); |
// Reset, and we should get the same result. |
logln("after iter.reset()"); |
- checkIterator(iter.reset(), expected, LENGTHOF(expected)); |
+ checkIterator(iter.reset(), expected, UPRV_LENGTHOF(expected)); |
} |
void UCharsTrieTest::TestIteratorFromUChars() { |
@@ -736,13 +735,13 @@ void UCharsTrieTest::TestIteratorFromUChars() { |
}; |
builder_->clear(); |
IcuTestErrorCode errorCode(*this, "TestIteratorFromUChars()"); |
- for(int32_t i=0; i<LENGTHOF(data); ++i) { |
+ for(int32_t i=0; i<UPRV_LENGTHOF(data); ++i) { |
builder_->add(data[i].s, data[i].value, errorCode); |
} |
UnicodeString trieUChars; |
builder_->buildUnicodeString(USTRINGTRIE_BUILD_FAST, trieUChars, errorCode); |
UCharsTrie::Iterator iter(trieUChars.getBuffer(), 0, errorCode); |
- checkIterator(iter, data, LENGTHOF(data)); |
+ checkIterator(iter, data, UPRV_LENGTHOF(data)); |
} |
void UCharsTrieTest::checkData(const StringAndValue data[], int32_t dataLength) { |
@@ -1035,7 +1034,7 @@ void UCharsTrieTest::checkIterator(UCharsTrie::Iterator &iter, |
if(iter.getString()!=expectedString) { |
char buffer[1000]; |
UnicodeString invString(prettify(iter.getString())); |
- invString.extract(0, invString.length(), buffer, LENGTHOF(buffer), US_INV); |
+ invString.extract(0, invString.length(), buffer, UPRV_LENGTHOF(buffer), US_INV); |
errln("trie iterator next().getString()=%s but expected %s for item %d", |
buffer, data[i].s, (int)i); |
} |