2000-07-26 16:27:18 +00:00
|
|
|
/*
|
|
|
|
************************************************************************
|
2001-03-21 20:09:56 +00:00
|
|
|
* Copyright (c) 1997-2001, International Business Machines
|
2000-07-26 16:27:18 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NORMCONF
|
|
|
|
#define _NORMCONF
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/normlzr.h"
|
|
|
|
#include "intltest.h"
|
|
|
|
|
|
|
|
#define TEST_SUITE_DIR "unidata"
|
2001-03-23 19:51:42 +00:00
|
|
|
#define TEST_SUITE_FILE "NormalizationTest.txt"
|
2000-07-26 16:27:18 +00:00
|
|
|
|
|
|
|
class NormalizerConformanceTest : public IntlTest {
|
|
|
|
Normalizer normalizer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NormalizerConformanceTest();
|
2000-12-09 03:17:45 +00:00
|
|
|
virtual ~NormalizerConformanceTest();
|
2000-07-26 16:27:18 +00:00
|
|
|
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
|
2000-07-26 16:27:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the conformance of Normalizer to
|
2001-03-23 19:51:42 +00:00
|
|
|
* http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt
|
2000-07-26 16:27:18 +00:00
|
|
|
* This file must be located at the path specified as TEST_SUITE_FILE.
|
|
|
|
*/
|
|
|
|
void TestConformance(void);
|
|
|
|
|
|
|
|
// Specific tests for debugging. These are generally failures taken from
|
|
|
|
// the conformance file, but culled out to make debugging easier.
|
|
|
|
void TestCase6(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Verify the conformance of the given line of the Unicode
|
|
|
|
* normalization (UTR 15) test suite file. For each line,
|
|
|
|
* there are five columns, corresponding to field[0]..field[4].
|
|
|
|
*
|
|
|
|
* The following invariants must be true for all conformant implementations
|
|
|
|
* c2 == NFC(c1) == NFC(c2) == NFC(c3)
|
|
|
|
* c3 == NFD(c1) == NFD(c2) == NFD(c3)
|
|
|
|
* c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
|
|
|
|
* c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
|
|
|
|
*
|
|
|
|
* @param field the 5 columns
|
|
|
|
* @param line the source line from the test suite file
|
|
|
|
* @return true if the test passes
|
|
|
|
*/
|
|
|
|
UBool checkConformance(const UnicodeString* field,
|
|
|
|
const UnicodeString& line);
|
|
|
|
|
|
|
|
void iterativeNorm(const UnicodeString& str,
|
2001-11-06 23:09:34 +00:00
|
|
|
UNormalizationMode mode,
|
2000-07-26 16:27:18 +00:00
|
|
|
UnicodeString& result,
|
|
|
|
int8_t dir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param op name of normalization form, e.g., "KC"
|
|
|
|
* @param s string being normalized
|
|
|
|
* @param got value received
|
|
|
|
* @param exp expected value
|
|
|
|
* @param msg description of this test
|
|
|
|
* @param return true if got == exp
|
|
|
|
*/
|
2001-03-20 19:39:51 +00:00
|
|
|
UBool assertEqual(const char *op,
|
2000-07-26 16:27:18 +00:00
|
|
|
const UnicodeString& s,
|
|
|
|
const UnicodeString& got,
|
|
|
|
const UnicodeString& exp,
|
2001-03-20 19:39:51 +00:00
|
|
|
const char *msg,
|
|
|
|
int32_t field);
|
2000-07-26 16:27:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Split a string into pieces based on the given delimiter
|
|
|
|
* character. Then, parse the resultant fields from hex into
|
|
|
|
* characters. That is, "0040 0400;0C00;0899" -> new String[] {
|
|
|
|
* "\u0040\u0400", "\u0C00", "\u0899" }. The output is assumed to
|
|
|
|
* be of the proper length already, and exactly output.length
|
|
|
|
* fields are parsed. If there are too few an exception is
|
|
|
|
* thrown. If there are too many the extras are ignored.
|
|
|
|
*
|
|
|
|
* @param buf scratch buffer
|
|
|
|
* @return FALSE upon failure
|
|
|
|
*/
|
2001-08-17 22:50:39 +00:00
|
|
|
UBool hexsplit(const char *s, char delimiter,
|
|
|
|
UnicodeString output[], int32_t outputLength);
|
2000-07-26 16:27:18 +00:00
|
|
|
|
2001-08-17 22:50:39 +00:00
|
|
|
void _testOneLine(const char *line);
|
2000-07-26 16:27:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|