+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2003, International Business Machines Corporation and
+ * Copyright (c) 1997-2016, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/unistr.h"
#include "unicode/sortkey.h"
#include "encoll.h"
+#include "cmemory.h"
CollationEnglishTest::CollationEnglishTest()
: myCollation(0)
delete myCollation;
}
-const UChar CollationEnglishTest::testSourceCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+static const UChar testSourceCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
{(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
{(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0020 /* ' ' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
{(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0} // 49
};
-const UChar CollationEnglishTest::testTargetCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+static const UChar testTargetCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
{(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
{(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
{(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0} // 49
};
-const Collator::EComparisonResult CollationEnglishTest::results[] = {
+static const Collator::EComparisonResult results[] = {
Collator::LESS,
Collator::LESS, /*Collator::GREATER,*/
Collator::LESS,
Collator::LESS // 49
};
-const UChar CollationEnglishTest::testBugs[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+static const UChar testBugs[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{0x61, 0},
{0x41, 0},
{0x65, 0},
// 0x0300 is grave, 0x0301 is acute
// the order of elements in this array must be different than the order in CollationFrenchTest
-const UChar CollationEnglishTest::testAcute[][CollationEnglishTest::MAX_TOKEN_LEN] = {
+static const UChar testAcute[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{0x65, 0x65, 0},
{0x65, 0x65, 0x0301, 0},
{0x65, 0x65, 0x0301, 0x0300, 0},
static const UChar testMore[][CollationEnglishTest::MAX_TOKEN_LEN] = {
{(UChar)0x0061 /* 'a' */, (UChar)0x0065 /* 'e' */, 0},
- {(UChar)0x0061 /* 'a' */, (UChar)0x0066 /* 'f' */, 0},
{ 0x00E6, 0},
{ 0x00C6, 0},
+ {(UChar)0x0061 /* 'a' */, (UChar)0x0066 /* 'f' */, 0},
{(UChar)0x006F /* 'o' */, (UChar)0x0065 /* 'e' */, 0},
{ 0x0153, 0},
{ 0x0152, 0},
//test more interesting cases
Collator::EComparisonResult expected;
- const int32_t testMoreSize = (int32_t)(sizeof(testMore) / sizeof(testMore[0]));
+ const int32_t testMoreSize = UPRV_LENGTHOF(testMore);
for (i = 0; i < testMoreSize; i++)
{
for (j = 0; j < testMoreSize; j++)
//test acute and grave ordering (compare to french collation)
int32_t j;
Collator::EComparisonResult expected;
- const int32_t testAcuteSize = (int32_t)(sizeof(testAcute) / sizeof(testAcute[0]));
+ const int32_t testAcuteSize = UPRV_LENGTHOF(testAcute);
for (i = 0; i < testAcuteSize; i++)
{
for (j = 0; j < testAcuteSize; j++)
default: name = ""; break;
}
} else {
- errln("Collator couldn't be instantiated!");
+ dataerrln("Collator couldn't be instantiated!");
name = "";
}
}