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 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 97 #if U_ENABLE_TRACING 98 void TestTraceCreateCharacter(); 99 void TestTraceCreateWord(); 100 void TestTraceCreateSentence(); 101 void TestTraceCreateTitle(); 102 void TestTraceCreateLine(); 103 void TestTraceCreateLineNormal(); 104 void TestTraceCreateLineStrict(); 105 void TestTraceCreateLineLoose(); 106 void TestTraceCreateBreakEngine(); 107 #endif 108 109 /***********************/ 110 private: 111 /** 112 * internal methods to prepare test data 113 **/ 114 115 void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t seed, 116 int32_t loopCount, UBool useUText); 117 118 // Run one of the Unicode Consortium boundary test data files. 119 void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi); 120 121 // Run a single test case from one of the Unicode Consortium test files. 122 void checkUnicodeTestCase(const char *testFileName, int lineNumber, 123 const UnicodeString &testString, 124 UVector32 *breakPositions, 125 RuleBasedBreakIterator *bi); 126 127 // Run the actual tests for TestTailoredBreaks() 128 void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText, 129 const int32_t *expectOffsets, int32_t expectOffsetsCount); 130 131 /** Filter for test cases from the Unicode test data files. 132 * Some need to be skipped because ICU is unable to fully implement the 133 * Unicode boundary specifications. 134 * @param testCase the test data string. 135 * @param fileName the Unicode test data file name. 136 * @return FALSE if the test case should be run, TRUE if it should be skipped. 137 */ 138 UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName); 139 140 // Test parameters, from the test framework and test invocation. 141 const char* fTestParams; 142 143 // Helper functions to test different trie bit sizes and state table bit sizes. 144 void testTrieStateTable(int32_t numChar, bool expectedTrieWidthIn8Bits, bool expectedStateRowIn8Bits); 145 146 #if U_ENABLE_TRACING 147 void assertTestTraceResult(int32_t fnNumber, const char* expectedData); 148 #endif 149 150 }; 151 152 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 153 154 #endif 155