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 void TestEmptyString(); 45 void TestGetAvailableLocales(); 46 void TestGetDisplayName(); 47 void TestEndBehaviour(); 48 void TestBug4153072(); 49 void TestJapaneseLineBreak(); 50 void TestThaiLineBreak(); 51 void TestMixedThaiLineBreak(); 52 void TestMaiyamok(); 53 void TestMonkey(); 54 55 void TestExtended(); 56 UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status); 57 void executeTest(TestParams *, UErrorCode &status); 58 59 void TestWordBreaks(); 60 void TestWordBoundary(); 61 void TestLineBreaks(); 62 void TestSentBreaks(); 63 void TestBug3818(); 64 void TestJapaneseWordBreak(); 65 void TestTrieDict(); 66 void TestUnicodeFiles(); 67 void TestBug5775(); 68 void TestTailoredBreaks(); 69 void TestDictRules(); 70 void TestBug5532(); 71 void TestBug9983(); 72 void TestBug7547(); 73 void TestBug12797(); 74 void TestBug12918(); 75 void TestBug12932(); 76 void TestEmoji(); 77 void TestBug12519(); 78 79 void TestDebug(); 80 void TestProperties(); 81 82 /***********************/ 83 private: 84 /** 85 * internal methods to prepare test data 86 **/ 87 88 /** 89 * Perform tests of BreakIterator forward and backward functionality 90 * on different kinds of iterators (word, sentence, line and character). 91 * It tests the methods first(), next(), current(), preceding(), following() 92 * previous() and isBoundary(). 93 * It makes use of internal functions to achieve this. 94 **/ 95 void generalIteratorTest(RuleBasedBreakIterator& bi, BITestData &td); 96 /** 97 * Internal method to perform iteration and test the first() and next() functions 98 **/ 99 void testFirstAndNext(RuleBasedBreakIterator& bi, BITestData &td); 100 /** 101 * Internal method to perform iteration and test the last() and previous() functions 102 **/ 103 void testLastAndPrevious(RuleBasedBreakIterator& bi, BITestData &td); 104 /** 105 * Internal method to perform iteration and test the following() function 106 **/ 107 void testFollowing(RuleBasedBreakIterator& bi, BITestData &td); 108 /** 109 * Internal method to perform iteration and test the preceding() function 110 **/ 111 void testPreceding(RuleBasedBreakIterator& bi, BITestData &td); 112 /** 113 * Internal method to perform iteration and test the isBoundary() function 114 **/ 115 void testIsBoundary(RuleBasedBreakIterator& bi, BITestData &td); 116 /** 117 * Internal method to perform tests of BreakIterator multiple selection functionality 118 * on different kinds of iterators (word, sentence, line and character) 119 **/ 120 void doMultipleSelectionTest(RuleBasedBreakIterator& iterator, BITestData &td); 121 122 void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t seed, 123 int32_t loopCount, UBool useUText); 124 125 // Run one of the Unicode Consortium boundary test data files. 126 void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi); 127 128 // Run a single test case from one of the Unicode Consortium test files. 129 void checkUnicodeTestCase(const char *testFileName, int lineNumber, 130 const UnicodeString &testString, 131 UVector32 *breakPositions, 132 RuleBasedBreakIterator *bi); 133 134 // Run the actual tests for TestTailoredBreaks() 135 void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText, 136 const int32_t *expectOffsets, int32_t expectOffsetsCount); 137 138 /** Filter for test cases from the Unicode test data files. 139 * Some need to be skipped because ICU is unable to fully implement the 140 * Unicode boundary specifications. 141 * @param testCase the test data string. 142 * @param fileName the Unicode test data file name. 143 * @return FALSE if the test case should be run, TRUE if it should be skipped. 144 */ 145 UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName); 146 147 // Test parameters, from the test framework and test invocation. 148 const char* fTestParams; 149 }; 150 151 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 152 153 #endif 154