• 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 
26 class  Enumeration;
27 class  BITestData;
28 struct TestParams;
29 class  RBBIMonkeyKind;
30 
31 U_NAMESPACE_BEGIN
32 class  UVector32;
33 U_NAMESPACE_END
34 
35 /**
36  * Test the RuleBasedBreakIterator class giving different rules
37  */
38 class RBBITest: public IntlTest {
39 public:
40 
41     RBBITest();
42     virtual ~RBBITest();
43 
44     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
45 
46     void TestGetAvailableLocales();
47     void TestGetDisplayName();
48     void TestEndBehaviour();
49     void TestBug4153072();
50     void TestJapaneseLineBreak();
51     void TestThaiLineBreak();
52     void TestMixedThaiLineBreak();
53     void TestMaiyamok();
54     void TestMonkey();
55 
56     void TestExtended();
57     UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
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 
87     void TestDebug();
88     void TestProperties();
89 
90 #if U_ENABLE_TRACING
91     void TestTraceCreateCharacter();
92     void TestTraceCreateWord();
93     void TestTraceCreateSentence();
94     void TestTraceCreateTitle();
95     void TestTraceCreateLine();
96     void TestTraceCreateLineNormal();
97     void TestTraceCreateLineStrict();
98     void TestTraceCreateLineLoose();
99     void TestTraceCreateBreakEngine();
100 #endif
101 
102 /***********************/
103 private:
104     /**
105      * internal methods to prepare test data
106      **/
107 
108     void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t  seed,
109         int32_t loopCount, UBool useUText);
110 
111     // Run one of the Unicode Consortium boundary test data files.
112     void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
113 
114     // Run a single test case from one of the Unicode Consortium test files.
115     void checkUnicodeTestCase(const char *testFileName, int lineNumber,
116                          const UnicodeString &testString,
117                          UVector32 *breakPositions,
118                          RuleBasedBreakIterator *bi);
119 
120     // Run the actual tests for TestTailoredBreaks()
121     void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
122                 const int32_t *expectOffsets, int32_t expectOffsetsCount);
123 
124     /** Filter for test cases from the Unicode test data files.
125      *  Some need to be skipped because ICU is unable to fully implement the
126      *  Unicode boundary specifications.
127      *  @param testCase the test data string.
128      *  @param fileName the Unicode test data file name.
129      *  @return FALSE if the test case should be run, TRUE if it should be skipped.
130      */
131     UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName);
132 
133     // Test parameters, from the test framework and test invocation.
134     const char* fTestParams;
135 
136 #if U_ENABLE_TRACING
137     void assertTestTraceResult(int32_t fnNumber, const char* expectedData);
138 #endif
139 
140 };
141 
142 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
143 
144 #endif
145