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