ICU-96 added tests for incremental compare
X-SVN-Rev: 3198
This commit is contained in:
parent
eda54a40f9
commit
ca0831016f
@ -24,6 +24,8 @@
|
|||||||
#include "allcoll.h"
|
#include "allcoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Include callcoll.c to get the test data.
|
* Include callcoll.c to get the test data.
|
||||||
* This helps maintain a single copy of the data.
|
* This helps maintain a single copy of the data.
|
||||||
@ -95,6 +97,7 @@ const Collator::EComparisonResult CollationDummyTest::results[] = {
|
|||||||
void CollationDummyTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationDummyTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -106,7 +109,7 @@ void CollationDummyTest::doTest( UnicodeString source, UnicodeString target, Col
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationDummyTest::TestTertiary(/* char* par */)
|
void CollationDummyTest::TestTertiary(/* char* par */)
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
#include "unicode/chariter.h"
|
#include "unicode/chariter.h"
|
||||||
#include "unicode/schriter.h"
|
#include "unicode/schriter.h"
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
CollationAPITest::doAssert(UBool condition, const char *message)
|
CollationAPITest::doAssert(UBool condition, const char *message)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "currcoll.h"
|
#include "currcoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
|
#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
|
||||||
|
|
||||||
CollationCurrencyTest::CollationCurrencyTest()
|
CollationCurrencyTest::CollationCurrencyTest()
|
||||||
@ -94,6 +96,7 @@ void CollationCurrencyTest::currencyTest(/*char *par*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult compareResult = c->compare(source, target);
|
Collator::EComparisonResult compareResult = c->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = c->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
|
|
||||||
CollationKey sourceKey, targetKey;
|
CollationKey sourceKey, targetKey;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
@ -116,8 +119,7 @@ void CollationCurrencyTest::currencyTest(/*char *par*/)
|
|||||||
|
|
||||||
Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey);
|
Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey);
|
||||||
|
|
||||||
reportCResult(source, target, sourceKey, targetKey,
|
reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, incResult, expectedResult );
|
||||||
compareResult, keyResult, expectedResult);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "dacoll.h"
|
#include "dacoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationDanishTest::CollationDanishTest()
|
CollationDanishTest::CollationDanishTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -186,6 +188,7 @@ const UChar CollationDanishTest::testNTList[][CollationDanishTest::MAX_TOKEN_LEN
|
|||||||
void CollationDanishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationDanishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -195,7 +198,7 @@ void CollationDanishTest::doTest( UnicodeString source, UnicodeString target, Co
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationDanishTest::TestTertiary(/* char* par */)
|
void CollationDanishTest::TestTertiary(/* char* par */)
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "decoll.h"
|
#include "decoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationGermanTest::CollationGermanTest()
|
CollationGermanTest::CollationGermanTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -89,6 +91,7 @@ const Collator::EComparisonResult CollationGermanTest::results[][2] =
|
|||||||
void CollationGermanTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationGermanTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -100,7 +103,7 @@ void CollationGermanTest::doTest( UnicodeString source, UnicodeString target, Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationGermanTest::TestTertiary(/* char* par */)
|
void CollationGermanTest::TestTertiary(/* char* par */)
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "encoll.h"
|
#include "encoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationEnglishTest::CollationEnglishTest()
|
CollationEnglishTest::CollationEnglishTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -254,6 +256,7 @@ static const UChar testMore[][CollationEnglishTest::MAX_TOKEN_LEN] = {
|
|||||||
void CollationEnglishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationEnglishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -265,7 +268,7 @@ void CollationEnglishTest::doTest( UnicodeString source, UnicodeString target, C
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationEnglishTest::TestTertiary(/* char* par */)
|
void CollationEnglishTest::TestTertiary(/* char* par */)
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include "escoll.h"
|
#include "escoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationSpanishTest::CollationSpanishTest()
|
CollationSpanishTest::CollationSpanishTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -77,6 +79,7 @@ const Collator::EComparisonResult CollationSpanishTest::results[] = {
|
|||||||
void CollationSpanishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationSpanishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -86,7 +89,7 @@ void CollationSpanishTest::doTest( UnicodeString source, UnicodeString target, C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationSpanishTest::TestTertiary(/* char* par */)
|
void CollationSpanishTest::TestTertiary(/* char* par */)
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "ficoll.h"
|
#include "ficoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationFinnishTest::CollationFinnishTest()
|
CollationFinnishTest::CollationFinnishTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -64,6 +66,7 @@ const Collator::EComparisonResult CollationFinnishTest::results[] = {
|
|||||||
void CollationFinnishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationFinnishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -73,7 +76,7 @@ void CollationFinnishTest::doTest( UnicodeString source, UnicodeString target, C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationFinnishTest::TestTertiary(/* char* par */)
|
void CollationFinnishTest::TestTertiary(/* char* par */)
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "frcoll.h"
|
#include "frcoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationFrenchTest::CollationFrenchTest()
|
CollationFrenchTest::CollationFrenchTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -160,6 +162,7 @@ const UChar CollationFrenchTest::testBugs[][CollationFrenchTest::MAX_TOKEN_LEN]
|
|||||||
void CollationFrenchTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationFrenchTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -171,7 +174,7 @@ void CollationFrenchTest::doTest( UnicodeString source, UnicodeString target, Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationFrenchTest::TestTertiary(/* char* par */)
|
void CollationFrenchTest::TestTertiary(/* char* par */)
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "g7coll.h"
|
#include "g7coll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
const Locale G7CollationTest::locales[8] = {
|
const Locale G7CollationTest::locales[8] = {
|
||||||
Locale("en", "US", ""),
|
Locale("en", "US", ""),
|
||||||
Locale("en", "GB", ""),
|
Locale("en", "GB", ""),
|
||||||
@ -92,6 +94,7 @@ const int32_t G7CollationTest::results[G7CollationTest::TESTLOCALES][G7Collation
|
|||||||
void G7CollationTest::doTest( Collator* myCollation, UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void G7CollationTest::doTest( Collator* myCollation, UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -101,7 +104,7 @@ void G7CollationTest::doTest( Collator* myCollation, UnicodeString source, Unico
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void G7CollationTest::TestG7Locales(/* char* par */)
|
void G7CollationTest::TestG7Locales(/* char* par */)
|
||||||
|
@ -171,6 +171,7 @@ IntlTest::reportCResult( UnicodeString &source, UnicodeString &target,
|
|||||||
CollationKey &sourceKey, CollationKey &targetKey,
|
CollationKey &sourceKey, CollationKey &targetKey,
|
||||||
Collator::EComparisonResult compareResult,
|
Collator::EComparisonResult compareResult,
|
||||||
Collator::EComparisonResult keyResult,
|
Collator::EComparisonResult keyResult,
|
||||||
|
Collator::EComparisonResult incResult,
|
||||||
Collator::EComparisonResult expectedResult )
|
Collator::EComparisonResult expectedResult )
|
||||||
{
|
{
|
||||||
if (expectedResult < -1 || expectedResult > 1)
|
if (expectedResult < -1 || expectedResult > 1)
|
||||||
@ -181,8 +182,10 @@ IntlTest::reportCResult( UnicodeString &source, UnicodeString &target,
|
|||||||
|
|
||||||
UBool ok1 = (compareResult == expectedResult);
|
UBool ok1 = (compareResult == expectedResult);
|
||||||
UBool ok2 = (keyResult == expectedResult);
|
UBool ok2 = (keyResult == expectedResult);
|
||||||
|
UBool ok3 = (incResult == expectedResult);
|
||||||
|
|
||||||
if (ok1 && ok2 && !verbose) {
|
|
||||||
|
if (ok1 && ok2 && ok3 && !verbose) {
|
||||||
// Keep non-verbose, passing tests fast
|
// Keep non-verbose, passing tests fast
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -220,6 +223,17 @@ IntlTest::reportCResult( UnicodeString &source, UnicodeString &target,
|
|||||||
|
|
||||||
errln(msg1 + prettySource + msg2 + prettyTarget);
|
errln(msg1 + prettySource + msg2 + prettyTarget);
|
||||||
}
|
}
|
||||||
|
msg1 = UnicodeString (ok3 ? "Ok: incCompare(" : "FAIL: incCompare(");
|
||||||
|
msg2 = ", ";
|
||||||
|
msg3 = ") returned ";
|
||||||
|
|
||||||
|
appendCompareResult(incResult, sResult);
|
||||||
|
|
||||||
|
if (ok3) {
|
||||||
|
logln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult);
|
||||||
|
} else {
|
||||||
|
errln(msg1 + prettySource + msg2 + prettyTarget + msg3 + sResult + msg4 + sExpect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +309,10 @@ SOURCE=.\sdtfmtts.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\sfwdchit.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\strtest.cpp
|
SOURCE=.\strtest.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@ -633,6 +637,10 @@ SOURCE=.\sdtfmtts.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\sfwdchit.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\strtest.h
|
SOURCE=.\strtest.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -124,6 +124,7 @@ protected:
|
|||||||
CollationKey &sourceKey, CollationKey &targetKey,
|
CollationKey &sourceKey, CollationKey &targetKey,
|
||||||
Collator::EComparisonResult compareResult,
|
Collator::EComparisonResult compareResult,
|
||||||
Collator::EComparisonResult keyResult,
|
Collator::EComparisonResult keyResult,
|
||||||
|
Collator::EComparisonResult incResult,
|
||||||
Collator::EComparisonResult expectedResult );
|
Collator::EComparisonResult expectedResult );
|
||||||
|
|
||||||
static UnicodeString &prettify(const UnicodeString &source, UnicodeString &target);
|
static UnicodeString &prettify(const UnicodeString &source, UnicodeString &target);
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "jacoll.h"
|
#include "jacoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationKanaTest::CollationKanaTest()
|
CollationKanaTest::CollationKanaTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -81,6 +83,7 @@ const Collator::EComparisonResult CollationKanaTest::results[] = {
|
|||||||
void CollationKanaTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationKanaTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -90,7 +93,7 @@ void CollationKanaTest::doTest( UnicodeString source, UnicodeString target, Coll
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationKanaTest::TestTertiary(/* char* par */)
|
void CollationKanaTest::TestTertiary(/* char* par */)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "mnkytst.h"
|
#include "mnkytst.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -263,6 +264,7 @@ void CollationMonkeyTest::TestRules(/* char* par */){
|
|||||||
void CollationMonkeyTest::doTest(RuleBasedCollator *myCollation, UnicodeString mysource, UnicodeString target, Collator::EComparisonResult result)
|
void CollationMonkeyTest::doTest(RuleBasedCollator *myCollation, UnicodeString mysource, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -274,7 +276,7 @@ void CollationMonkeyTest::doTest(RuleBasedCollator *myCollation, UnicodeString m
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( mysource, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( mysource, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationMonkeyTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
void CollationMonkeyTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "regcoll.h"
|
#include "regcoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
|
#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0])
|
||||||
|
|
||||||
static UErrorCode status = U_ZERO_ERROR;
|
static UErrorCode status = U_ZERO_ERROR;
|
||||||
@ -1117,6 +1119,7 @@ void CollationRegressionTest::compareArray(Collator &c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collator::EComparisonResult compareResult = c.compare(source, target);
|
Collator::EComparisonResult compareResult = c.compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = c.compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
|
|
||||||
CollationKey sourceKey, targetKey;
|
CollationKey sourceKey, targetKey;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
@ -1139,8 +1142,7 @@ void CollationRegressionTest::compareArray(Collator &c,
|
|||||||
|
|
||||||
Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey);
|
Collator::EComparisonResult keyResult = sourceKey.compareTo(targetKey);
|
||||||
|
|
||||||
reportCResult(source, target, sourceKey, targetKey,
|
reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, incResult, expectedResult );
|
||||||
compareResult, keyResult, expectedResult);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
103
icu4c/source/test/intltest/sfwdchit.cpp
Normal file
103
icu4c/source/test/intltest/sfwdchit.cpp
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#include "sfwdchit.h"
|
||||||
|
#include "unicode/ustring.h"
|
||||||
|
#include "unicode/unistr.h"
|
||||||
|
#include "uhash.h"
|
||||||
|
#include "cmemory.h"
|
||||||
|
|
||||||
|
// A hash code of kInvalidHashCode indicates that the has code needs
|
||||||
|
// to be computed. A hash code of kEmptyHashCode is used for empty keys
|
||||||
|
// and for any key whose computed hash code is kInvalidHashCode.
|
||||||
|
const int32_t SimpleFwdCharIterator::kInvalidHashCode = 0;
|
||||||
|
const int32_t SimpleFwdCharIterator::kEmptyHashCode = 1;
|
||||||
|
|
||||||
|
SimpleFwdCharIterator::SimpleFwdCharIterator(const UnicodeString& s) {
|
||||||
|
|
||||||
|
fHashCode = kInvalidHashCode;
|
||||||
|
fLen = s.length();
|
||||||
|
fStart = new UChar[fLen];
|
||||||
|
if(fStart == NULL) {
|
||||||
|
fBogus = TRUE;
|
||||||
|
} else {
|
||||||
|
fEnd = fStart+fLen;
|
||||||
|
fCurrent = fStart;
|
||||||
|
fBogus = FALSE;
|
||||||
|
s.extract(0, fLen, fStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleFwdCharIterator::SimpleFwdCharIterator(UChar *s, int32_t len, UBool adopt) {
|
||||||
|
|
||||||
|
fHashCode = kInvalidHashCode;
|
||||||
|
|
||||||
|
fLen = len==-1 ? u_strlen(s) : len;
|
||||||
|
|
||||||
|
if(adopt == FALSE) {
|
||||||
|
fStart = new UChar[fLen];
|
||||||
|
if(fStart == NULL) {
|
||||||
|
fBogus = TRUE;
|
||||||
|
} else {
|
||||||
|
uprv_memcpy(fStart, s, fLen);
|
||||||
|
fEnd = fStart+fLen;
|
||||||
|
fCurrent = fStart;
|
||||||
|
fBogus = FALSE;
|
||||||
|
}
|
||||||
|
} else { // adopt = TRUE
|
||||||
|
fCurrent = fStart = s;
|
||||||
|
fEnd = fStart + fLen;
|
||||||
|
fBogus = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleFwdCharIterator::~SimpleFwdCharIterator() {
|
||||||
|
delete[] fStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
UBool SimpleFwdCharIterator::operator==(const ForwardCharacterIterator& that) const {
|
||||||
|
if(this == &that) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if(that->fHashCode != kInvalidHashCode && this->fHashCode = that->fHashCode) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->fStart == that->fStart) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->fLen == that->fLen && uprv_memcmp(this->fStart, that->fStart, this->fLen) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t SimpleFwdCharIterator::hashCode(void) const {
|
||||||
|
if (fHashCode == kInvalidHashCode)
|
||||||
|
{
|
||||||
|
((SimpleFwdCharIterator *)this)->fHashCode = uhash_hashUChars(fStart);
|
||||||
|
}
|
||||||
|
return fHashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
UClassID SimpleFwdCharIterator::getDynamicClassID(void) const {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
UChar SimpleFwdCharIterator::nextPostInc(void) {
|
||||||
|
if(fCurrent == fEnd) {
|
||||||
|
return ForwardCharacterIterator::DONE;
|
||||||
|
} else {
|
||||||
|
return *(fCurrent)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UChar32 SimpleFwdCharIterator::next32PostInc(void) {
|
||||||
|
return ForwardCharacterIterator::DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
UBool SimpleFwdCharIterator::hasNext() {
|
||||||
|
return fCurrent < fEnd;
|
||||||
|
}
|
75
icu4c/source/test/intltest/sfwdchit.h
Normal file
75
icu4c/source/test/intltest/sfwdchit.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#ifndef SFDWCHIT_H
|
||||||
|
#define SFDWCHIT_H
|
||||||
|
|
||||||
|
#include "unicode/utypes.h"
|
||||||
|
#include "unicode/chariter.h"
|
||||||
|
|
||||||
|
class SimpleFwdCharIterator : public ForwardCharacterIterator {
|
||||||
|
public:
|
||||||
|
SimpleFwdCharIterator(const UnicodeString& s);
|
||||||
|
SimpleFwdCharIterator(UChar *s, int32_t len, UBool adopt = FALSE);
|
||||||
|
|
||||||
|
virtual ~SimpleFwdCharIterator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when both iterators refer to the same
|
||||||
|
* character in the same character-storage object.
|
||||||
|
* @stable
|
||||||
|
*/
|
||||||
|
virtual UBool operator==(const ForwardCharacterIterator& that) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a hash code for this iterator.
|
||||||
|
* @stable
|
||||||
|
*/
|
||||||
|
virtual int32_t hashCode(void) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a UClassID for this ForwardCharacterIterator ("poor man's
|
||||||
|
* RTTI").<P> Despite the fact that this function is public,
|
||||||
|
* DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API!
|
||||||
|
* @stable
|
||||||
|
*/
|
||||||
|
virtual UClassID getDynamicClassID(void) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current code unit for returning and advances to the next code unit
|
||||||
|
* in the iteration range
|
||||||
|
* (toward endIndex()). If there are
|
||||||
|
* no more code units to return, returns DONE.
|
||||||
|
* @draft
|
||||||
|
*/
|
||||||
|
virtual UChar nextPostInc(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current code point for returning and advances to the next code point
|
||||||
|
* in the iteration range
|
||||||
|
* (toward endIndex()). If there are
|
||||||
|
* no more code points to return, returns DONE.
|
||||||
|
* @draft
|
||||||
|
*/
|
||||||
|
virtual UChar32 next32PostInc(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns FALSE if there are no more code units or code points
|
||||||
|
* at or after the current position in the iteration range.
|
||||||
|
* This is used with nextPostInc() or next32PostInc() in forward
|
||||||
|
* iteration.
|
||||||
|
*/
|
||||||
|
virtual UBool hasNext();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SimpleFwdCharIterator() {}
|
||||||
|
SimpleFwdCharIterator(const SimpleFwdCharIterator&) {}
|
||||||
|
SimpleFwdCharIterator &operator=(const SimpleFwdCharIterator&) { return *this; }
|
||||||
|
private:
|
||||||
|
static const int32_t kInvalidHashCode;
|
||||||
|
static const int32_t kEmptyHashCode;
|
||||||
|
|
||||||
|
UChar *fStart, *fEnd, *fCurrent;
|
||||||
|
int32_t fLen;
|
||||||
|
UBool fBogus;
|
||||||
|
int32_t fHashCode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -23,6 +23,8 @@
|
|||||||
#include "trcoll.h"
|
#include "trcoll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sfwdchit.h"
|
||||||
|
|
||||||
CollationTurkishTest::CollationTurkishTest()
|
CollationTurkishTest::CollationTurkishTest()
|
||||||
: myCollation(0)
|
: myCollation(0)
|
||||||
{
|
{
|
||||||
@ -81,6 +83,7 @@ const Collator::EComparisonResult CollationTurkishTest::results[] = {
|
|||||||
void CollationTurkishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
void CollationTurkishTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||||
{
|
{
|
||||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||||
|
Collator::EComparisonResult incResult = myCollation->compare(SimpleFwdCharIterator(source), SimpleFwdCharIterator(target));
|
||||||
CollationKey sortKey1, sortKey2;
|
CollationKey sortKey1, sortKey2;
|
||||||
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
UErrorCode key1status = U_ZERO_ERROR, key2status = U_ZERO_ERROR; //nos
|
||||||
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
myCollation->getCollationKey(source, /*nos*/ sortKey1, key1status );
|
||||||
@ -90,7 +93,7 @@ void CollationTurkishTest::doTest( UnicodeString source, UnicodeString target, C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
Collator::EComparisonResult keyResult = sortKey1.compareTo(sortKey2);
|
||||||
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, result );
|
reportCResult( source, target, sortKey1, sortKey2, compareResult, keyResult, incResult, result );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollationTurkishTest::TestTertiary(/* char* par */)
|
void CollationTurkishTest::TestTertiary(/* char* par */)
|
||||||
|
Loading…
Reference in New Issue
Block a user