2 ************************************************************************
3 * Copyright (c) 1997-2003, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ************************************************************************
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_NORMALIZATION
15 #include "unicode/normlzr.h"
18 typedef struct _FileStream FileStream
;
20 class NormalizerConformanceTest
: public IntlTest
{
21 Normalizer normalizer
;
24 NormalizerConformanceTest();
25 virtual ~NormalizerConformanceTest();
27 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
, char* par
=NULL
);
30 * Test the conformance of Normalizer to
31 * http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt
33 void TestConformance();
34 void TestConformance32();
35 void TestConformance(FileStream
*input
, int32_t options
);
37 // Specific tests for debugging. These are generally failures taken from
38 // the conformance file, but culled out to make debugging easier.
42 FileStream
*openNormalizationTestFile(const char *filename
);
45 * Verify the conformance of the given line of the Unicode
46 * normalization (UTR 15) test suite file. For each line,
47 * there are five columns, corresponding to field[0]..field[4].
49 * The following invariants must be true for all conformant implementations
50 * c2 == NFC(c1) == NFC(c2) == NFC(c3)
51 * c3 == NFD(c1) == NFD(c2) == NFD(c3)
52 * c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
53 * c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
55 * @param field the 5 columns
56 * @param line the source line from the test suite file
57 * @return true if the test passes
59 UBool
checkConformance(const UnicodeString
* field
,
64 void iterativeNorm(const UnicodeString
& str
,
65 UNormalizationMode mode
, int32_t options
,
66 UnicodeString
& result
,
70 * @param op name of normalization form, e.g., "KC"
71 * @param s string being normalized
72 * @param got value received
73 * @param exp expected value
74 * @param msg description of this test
75 * @param return true if got == exp
77 UBool
assertEqual(const char *op
,
78 const UnicodeString
& s
,
79 const UnicodeString
& got
,
80 const UnicodeString
& exp
,
85 * Split a string into pieces based on the given delimiter
86 * character. Then, parse the resultant fields from hex into
87 * characters. That is, "0040 0400;0C00;0899" -> new String[] {
88 * "\u0040\u0400", "\u0C00", "\u0899" }. The output is assumed to
89 * be of the proper length already, and exactly output.length
90 * fields are parsed. If there are too few an exception is
91 * thrown. If there are too many the extras are ignored.
93 * @param buf scratch buffer
94 * @return FALSE upon failure
96 UBool
hexsplit(const char *s
, char delimiter
,
97 UnicodeString output
[], int32_t outputLength
);
99 void _testOneLine(const char *line
);
100 void compare(const UnicodeString
& s1
,const UnicodeString
& s2
);
103 #endif /* #if !UCONFIG_NO_NORMALIZATION */