]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/normconf.h
ICU-59152.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / normconf.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ************************************************************************
5 * Copyright (c) 1997-2003, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ************************************************************************
8 */
9
10 #ifndef _NORMCONF
11 #define _NORMCONF
12
13 #include "unicode/utypes.h"
14
15 #if !UCONFIG_NO_NORMALIZATION
16
17 #include "unicode/normlzr.h"
18 #include "intltest.h"
19
20 typedef struct _FileStream FileStream;
21
22 class NormalizerConformanceTest : public IntlTest {
23 Normalizer normalizer;
24
25 public:
26 NormalizerConformanceTest();
27 virtual ~NormalizerConformanceTest();
28
29 void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
30
31 /**
32 * Test the conformance of Normalizer to
33 * http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt
34 */
35 void TestConformance();
36 void TestConformance32();
37 void TestConformance(FileStream *input, int32_t options);
38
39 // Specific tests for debugging. These are generally failures taken from
40 // the conformance file, but culled out to make debugging easier.
41 void TestCase6(void);
42
43 private:
44 FileStream *openNormalizationTestFile(const char *filename);
45
46 /**
47 * Verify the conformance of the given line of the Unicode
48 * normalization (UTR 15) test suite file. For each line,
49 * there are five columns, corresponding to field[0]..field[4].
50 *
51 * The following invariants must be true for all conformant implementations
52 * c2 == NFC(c1) == NFC(c2) == NFC(c3)
53 * c3 == NFD(c1) == NFD(c2) == NFD(c3)
54 * c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
55 * c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
56 *
57 * @param field the 5 columns
58 * @param line the source line from the test suite file
59 * @return true if the test passes
60 */
61 UBool checkConformance(const UnicodeString* field,
62 const char *line,
63 int32_t options,
64 UErrorCode &status);
65
66 void iterativeNorm(const UnicodeString& str,
67 UNormalizationMode mode, int32_t options,
68 UnicodeString& result,
69 int8_t dir);
70
71 /**
72 * @param op name of normalization form, e.g., "KC"
73 * @param s string being normalized
74 * @param got value received
75 * @param exp expected value
76 * @param msg description of this test
77 * @param return true if got == exp
78 */
79 UBool assertEqual(const char *op,
80 const UnicodeString& s,
81 const UnicodeString& got,
82 const UnicodeString& exp,
83 const char *msg,
84 int32_t field);
85
86 /**
87 * Split a string into pieces based on the given delimiter
88 * character. Then, parse the resultant fields from hex into
89 * characters. That is, "0040 0400;0C00;0899" -> new String[] {
90 * "\u0040\u0400", "\u0C00", "\u0899" }. The output is assumed to
91 * be of the proper length already, and exactly output.length
92 * fields are parsed. If there are too few an exception is
93 * thrown. If there are too many the extras are ignored.
94 *
95 * @param buf scratch buffer
96 * @return FALSE upon failure
97 */
98 UBool hexsplit(const char *s, char delimiter,
99 UnicodeString output[], int32_t outputLength);
100
101 void _testOneLine(const char *line);
102 void compare(const UnicodeString& s1,const UnicodeString& s2);
103 };
104
105 #endif /* #if !UCONFIG_NO_NORMALIZATION */
106
107 #endif