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