]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/rbbitst.h
ICU-59152.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / rbbitst.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*************************************************************************
4 * Copyright (c) 1999-2016, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *************************************************************************
7 * Date Name Description
8 * 12/15/99 Madhu Creation.
9 * 01/12/2000 Madhu Updated for changed API and added new tests
10 ************************************************************************/
11
12
13 #ifndef RBBITEST_H
14 #define RBBITEST_H
15
16 #include "unicode/utypes.h"
17
18 #if !UCONFIG_NO_BREAK_ITERATION
19
20 #include "intltest.h"
21 #include "unicode/brkiter.h"
22 #include "unicode/rbbi.h"
23
24 class Enumeration;
25 class BITestData;
26 struct TestParams;
27 class RBBIMonkeyKind;
28
29 U_NAMESPACE_BEGIN
30 class UVector32;
31 U_NAMESPACE_END
32
33 /**
34 * Test the RuleBasedBreakIterator class giving different rules
35 */
36 class RBBITest: public IntlTest {
37 public:
38
39 RBBITest();
40 virtual ~RBBITest();
41
42 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
43
44 /**
45 * Tests rule status return values
46 **/
47 void TestStatusReturn();
48
49 void TestEmptyString();
50 void TestGetAvailableLocales();
51 void TestGetDisplayName();
52 void TestEndBehaviour();
53 void TestBug4153072();
54 void TestJapaneseLineBreak();
55 void TestThaiLineBreak();
56 void TestMixedThaiLineBreak();
57 void TestMaiyamok();
58 void TestMonkey();
59
60 void TestExtended();
61 UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
62 void executeTest(TestParams *, UErrorCode &status);
63
64 void TestWordBreaks();
65 void TestWordBoundary();
66 void TestLineBreaks();
67 void TestSentBreaks();
68 void TestBug3818();
69 void TestJapaneseWordBreak();
70 void TestTrieDict();
71 void TestUnicodeFiles();
72 void TestBug5775();
73 void TestTailoredBreaks();
74 void TestDictRules();
75 void TestBug5532();
76 void TestBug9983();
77 void TestBug7547();
78 void TestBug12797();
79 void TestBug12918();
80 void TestBug12932();
81 void TestEmoji();
82
83 void TestDebug();
84 void TestProperties();
85
86 /***********************/
87 private:
88 /**
89 * internal methods to prepare test data
90 **/
91
92 /**
93 * Perform tests of BreakIterator forward and backward functionality
94 * on different kinds of iterators (word, sentence, line and character).
95 * It tests the methods first(), next(), current(), preceding(), following()
96 * previous() and isBoundary().
97 * It makes use of internal functions to achieve this.
98 **/
99 void generalIteratorTest(RuleBasedBreakIterator& bi, BITestData &td);
100 /**
101 * Internal method to perform iteration and test the first() and next() functions
102 **/
103 void testFirstAndNext(RuleBasedBreakIterator& bi, BITestData &td);
104 /**
105 * Internal method to perform iteration and test the last() and previous() functions
106 **/
107 void testLastAndPrevious(RuleBasedBreakIterator& bi, BITestData &td);
108 /**
109 * Internal method to perform iteration and test the following() function
110 **/
111 void testFollowing(RuleBasedBreakIterator& bi, BITestData &td);
112 /**
113 * Internal method to perform iteration and test the preceding() function
114 **/
115 void testPreceding(RuleBasedBreakIterator& bi, BITestData &td);
116 /**
117 * Internal method to perform iteration and test the isBoundary() function
118 **/
119 void testIsBoundary(RuleBasedBreakIterator& bi, BITestData &td);
120 /**
121 * Internal method to perform tests of BreakIterator multiple selection functionality
122 * on different kinds of iterators (word, sentence, line and character)
123 **/
124 void doMultipleSelectionTest(RuleBasedBreakIterator& iterator, BITestData &td);
125
126 void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t seed,
127 int32_t loopCount, UBool useUText);
128
129 // Run one of the Unicode Consortium boundary test data files.
130 void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
131
132 // Run a single test case from one of the Unicode Consortium test files.
133 void checkUnicodeTestCase(const char *testFileName, int lineNumber,
134 const UnicodeString &testString,
135 UVector32 *breakPositions,
136 RuleBasedBreakIterator *bi);
137
138 // Run the actual tests for TestTailoredBreaks()
139 void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
140 const int32_t *expectOffsets, int32_t expectOffsetsCount);
141
142 /** Filter for test cases from the Unicode test data files.
143 * Some need to be skipped because ICU is unable to fully implement the
144 * Unicode boundary specifications.
145 * @param testCase the test data string.
146 * @param fileName the Unicode test data file name.
147 * @return FALSE if the test case should be run, TRUE if it should be skipped.
148 */
149 UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName);
150
151 // Test parameters, from the test framework and test invocation.
152 const char* fTestParams;
153 };
154
155 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
156
157 #endif