• 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 
86     void TestDebug();
87     void TestProperties();
88 
89 /***********************/
90 private:
91     /**
92      * internal methods to prepare test data
93      **/
94 
95     void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t  seed,
96         int32_t loopCount, UBool useUText);
97 
98     // Run one of the Unicode Consortium boundary test data files.
99     void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
100 
101     // Run a single test case from one of the Unicode Consortium test files.
102     void checkUnicodeTestCase(const char *testFileName, int lineNumber,
103                          const UnicodeString &testString,
104                          UVector32 *breakPositions,
105                          RuleBasedBreakIterator *bi);
106 
107     // Run the actual tests for TestTailoredBreaks()
108     void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
109                 const int32_t *expectOffsets, int32_t expectOffsetsCount);
110 
111     /** Filter for test cases from the Unicode test data files.
112      *  Some need to be skipped because ICU is unable to fully implement the
113      *  Unicode boundary specifications.
114      *  @param testCase the test data string.
115      *  @param fileName the Unicode test data file name.
116      *  @return FALSE if the test case should be run, TRUE if it should be skipped.
117      */
118     UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName);
119 
120     // Test parameters, from the test framework and test invocation.
121     const char* fTestParams;
122 };
123 
124 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
125 
126 #endif
127