• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <memory>
21 
22 #include "intltest.h"
23 #include "unicode/brkiter.h"
24 #include "unicode/rbbi.h"
25 #include "unicode/uscript.h"
26 
27 class  Enumeration;
28 class  BITestData;
29 struct TestParams;
30 class  RBBIMonkeyKind;
31 
32 U_NAMESPACE_BEGIN
33 class  UVector32;
34 U_NAMESPACE_END
35 
36 /**
37  * Test the RuleBasedBreakIterator class giving different rules
38  */
39 class RBBITest: public IntlTest {
40 public:
41 
42     RBBITest();
43     virtual ~RBBITest();
44 
45     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL ) override;
46 
47     void TestGetAvailableLocales();
48     void TestGetDisplayName();
49     void TestEndBehaviour();
50     void TestBug4153072();
51     void TestJapaneseLineBreak();
52     void TestThaiLineBreak();
53     void TestMixedThaiLineBreak();
54     void TestMaiyamok();
55     void TestMonkey();
56 
57     void TestExtended();
58     void executeTest(TestParams *, UErrorCode &status);
59 
60     void TestWordBreaks();
61     void TestWordBoundary();
62     void TestLineBreaks();
63     void TestSentBreaks();
64     void TestBug3818();
65     void TestJapaneseWordBreak();
66     void TestTrieDict();
67     void TestUnicodeFiles();
68     void TestBug5775();
69     void TestTailoredBreaks();
70     void TestDictRules();
71     void TestBug5532();
72     void TestBug9983();
73     void TestBug7547();
74     void TestBug12797();
75     void TestBug12918();
76     void TestBug12932();
77     void TestEmoji();
78     void TestBug12519();
79     void TestBug12677();
80     void TestTableRedundancies();
81     void TestBug13447();
82     void TestReverse();
83     void TestReverse(std::unique_ptr<RuleBasedBreakIterator>bi);
84     void TestBug13692();
85     void TestDebugRules();
86     void TestUnpairedSurrogate();
87 
88     void TestDebug();
89     void TestProperties();
90     void Test8BitsTrieWith8BitStateTable();
91     void Test8BitsTrieWith16BitStateTable();
92     void Test16BitsTrieWith8BitStateTable();
93     void Test16BitsTrieWith16BitStateTable();
94     void TestTable_8_16_Bits();
95     void TestBug13590();
96     void TestLSTMThai();
97     void TestLSTMBurmese();
98 
99 #if U_ENABLE_TRACING
100     void TestTraceCreateCharacter();
101     void TestTraceCreateWord();
102     void TestTraceCreateSentence();
103     void TestTraceCreateTitle();
104     void TestTraceCreateLine();
105     void TestTraceCreateLineNormal();
106     void TestTraceCreateLineStrict();
107     void TestTraceCreateLineLoose();
108     void TestTraceCreateLineNormalPhrase();
109     void TestTraceCreateLineLoosePhrase();
110     void TestTraceCreateLineStrictPhrase();
111     void TestTraceCreateLinePhrase();
112     void TestTraceCreateBreakEngine();
113 #endif
114 
115 /***********************/
116 private:
117     /**
118      * internal methods to prepare test data
119      **/
120 
121     void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t  seed,
122         int32_t loopCount, UBool useUText);
123 
124     // Run one of the Unicode Consortium boundary test data files.
125     void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
126 
127     // Run tests from one of the LSTM test files.
128     void runLSTMTestFromFile(const char* filename, UScriptCode script);
129 
130     // Run a single test case from one of the Unicode Consortium test files.
131     void checkUnicodeTestCase(const char *testFileName, int lineNumber,
132                          const UnicodeString &testString,
133                          UVector32 *breakPositions,
134                          RuleBasedBreakIterator *bi);
135 
136     // Run the actual tests for TestTailoredBreaks()
137     void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
138                 const int32_t *expectOffsets, int32_t expectOffsetsCount);
139 
140     /** Filter for test cases from the Unicode test data files.
141      *  Some need to be skipped because ICU is unable to fully implement the
142      *  Unicode boundary specifications.
143      *  @param testCase the test data string.
144      *  @param fileName the Unicode test data file name.
145      *  @return FALSE if the test case should be run, TRUE if it should be skipped.
146      */
147     UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName);
148 
149     // Test parameters, from the test framework and test invocation.
150     const char* fTestParams;
151 
152     // Helper functions to test different trie bit sizes and state table bit sizes.
153     void testTrieStateTable(int32_t numChar, bool expectedTrieWidthIn8Bits, bool expectedStateRowIn8Bits);
154 
155 #if U_ENABLE_TRACING
156     void assertTestTraceResult(int32_t fnNumber, const char* expectedData);
157 #endif
158 
159 };
160 
161 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
162 
163 #endif
164