1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /************************************************************************* 4*0e209d39SAndroid Build Coastguard Worker * Copyright (c) 1999-2016, International Business Machines 5*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 6*0e209d39SAndroid Build Coastguard Worker ************************************************************************* 7*0e209d39SAndroid Build Coastguard Worker * Date Name Description 8*0e209d39SAndroid Build Coastguard Worker * 12/15/99 Madhu Creation. 9*0e209d39SAndroid Build Coastguard Worker * 01/12/2000 Madhu Updated for changed API and added new tests 10*0e209d39SAndroid Build Coastguard Worker ************************************************************************/ 11*0e209d39SAndroid Build Coastguard Worker 12*0e209d39SAndroid Build Coastguard Worker 13*0e209d39SAndroid Build Coastguard Worker #ifndef RBBITEST_H 14*0e209d39SAndroid Build Coastguard Worker #define RBBITEST_H 15*0e209d39SAndroid Build Coastguard Worker 16*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 17*0e209d39SAndroid Build Coastguard Worker 18*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_BREAK_ITERATION 19*0e209d39SAndroid Build Coastguard Worker 20*0e209d39SAndroid Build Coastguard Worker #include <stdio.h> 21*0e209d39SAndroid Build Coastguard Worker 22*0e209d39SAndroid Build Coastguard Worker #include <memory> 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker #include "intltest.h" 25*0e209d39SAndroid Build Coastguard Worker #include "unicode/brkiter.h" 26*0e209d39SAndroid Build Coastguard Worker #include "unicode/rbbi.h" 27*0e209d39SAndroid Build Coastguard Worker #include "unicode/uscript.h" 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker class Enumeration; 30*0e209d39SAndroid Build Coastguard Worker class BITestData; 31*0e209d39SAndroid Build Coastguard Worker struct TestParams; 32*0e209d39SAndroid Build Coastguard Worker class RBBIMonkeyKind; 33*0e209d39SAndroid Build Coastguard Worker 34*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 35*0e209d39SAndroid Build Coastguard Worker class UVector32; 36*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 37*0e209d39SAndroid Build Coastguard Worker 38*0e209d39SAndroid Build Coastguard Worker /** 39*0e209d39SAndroid Build Coastguard Worker * Test the RuleBasedBreakIterator class giving different rules 40*0e209d39SAndroid Build Coastguard Worker */ 41*0e209d39SAndroid Build Coastguard Worker class RBBITest: public IntlTest { 42*0e209d39SAndroid Build Coastguard Worker public: 43*0e209d39SAndroid Build Coastguard Worker 44*0e209d39SAndroid Build Coastguard Worker RBBITest(); 45*0e209d39SAndroid Build Coastguard Worker virtual ~RBBITest(); 46*0e209d39SAndroid Build Coastguard Worker 47*0e209d39SAndroid Build Coastguard Worker void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = nullptr ) override; 48*0e209d39SAndroid Build Coastguard Worker 49*0e209d39SAndroid Build Coastguard Worker void TestGetAvailableLocales(); 50*0e209d39SAndroid Build Coastguard Worker void TestGetDisplayName(); 51*0e209d39SAndroid Build Coastguard Worker void TestEndBehaviour(); 52*0e209d39SAndroid Build Coastguard Worker void TestBug4153072(); 53*0e209d39SAndroid Build Coastguard Worker void TestJapaneseLineBreak(); 54*0e209d39SAndroid Build Coastguard Worker void TestThaiLineBreak(); 55*0e209d39SAndroid Build Coastguard Worker void TestMixedThaiLineBreak(); 56*0e209d39SAndroid Build Coastguard Worker void TestMaiyamok(); 57*0e209d39SAndroid Build Coastguard Worker void TestMonkey(); 58*0e209d39SAndroid Build Coastguard Worker 59*0e209d39SAndroid Build Coastguard Worker void TestExtended(); 60*0e209d39SAndroid Build Coastguard Worker void executeTest(TestParams *, UErrorCode &status); 61*0e209d39SAndroid Build Coastguard Worker 62*0e209d39SAndroid Build Coastguard Worker void TestWordBreaks(); 63*0e209d39SAndroid Build Coastguard Worker void TestWordBoundary(); 64*0e209d39SAndroid Build Coastguard Worker void TestLineBreaks(); 65*0e209d39SAndroid Build Coastguard Worker void TestSentBreaks(); 66*0e209d39SAndroid Build Coastguard Worker void TestBug3818(); 67*0e209d39SAndroid Build Coastguard Worker void TestJapaneseWordBreak(); 68*0e209d39SAndroid Build Coastguard Worker void TestTrieDict(); 69*0e209d39SAndroid Build Coastguard Worker void TestUnicodeFiles(); 70*0e209d39SAndroid Build Coastguard Worker void TestBug5775(); 71*0e209d39SAndroid Build Coastguard Worker void TestTailoredBreaks(); 72*0e209d39SAndroid Build Coastguard Worker void TestDictRules(); 73*0e209d39SAndroid Build Coastguard Worker void TestBug5532(); 74*0e209d39SAndroid Build Coastguard Worker void TestBug9983(); 75*0e209d39SAndroid Build Coastguard Worker void TestBug7547(); 76*0e209d39SAndroid Build Coastguard Worker void TestBug12797(); 77*0e209d39SAndroid Build Coastguard Worker void TestBug12918(); 78*0e209d39SAndroid Build Coastguard Worker void TestBug12932(); 79*0e209d39SAndroid Build Coastguard Worker void TestEmoji(); 80*0e209d39SAndroid Build Coastguard Worker void TestBug12519(); 81*0e209d39SAndroid Build Coastguard Worker void TestBug12677(); 82*0e209d39SAndroid Build Coastguard Worker void TestTableRedundancies(); 83*0e209d39SAndroid Build Coastguard Worker void TestBug13447(); 84*0e209d39SAndroid Build Coastguard Worker void TestReverse(); 85*0e209d39SAndroid Build Coastguard Worker void TestReverse(std::unique_ptr<RuleBasedBreakIterator>bi); 86*0e209d39SAndroid Build Coastguard Worker void TestBug13692(); 87*0e209d39SAndroid Build Coastguard Worker void TestDebugRules(); 88*0e209d39SAndroid Build Coastguard Worker void TestUnpairedSurrogate(); 89*0e209d39SAndroid Build Coastguard Worker 90*0e209d39SAndroid Build Coastguard Worker void TestDebug(); 91*0e209d39SAndroid Build Coastguard Worker void TestProperties(); 92*0e209d39SAndroid Build Coastguard Worker void Test8BitsTrieWith8BitStateTable(); 93*0e209d39SAndroid Build Coastguard Worker void Test8BitsTrieWith16BitStateTable(); 94*0e209d39SAndroid Build Coastguard Worker void Test16BitsTrieWith8BitStateTable(); 95*0e209d39SAndroid Build Coastguard Worker void Test16BitsTrieWith16BitStateTable(); 96*0e209d39SAndroid Build Coastguard Worker void TestTable_8_16_Bits(); 97*0e209d39SAndroid Build Coastguard Worker void TestBug13590(); 98*0e209d39SAndroid Build Coastguard Worker void TestLSTMThai(); 99*0e209d39SAndroid Build Coastguard Worker void TestLSTMBurmese(); 100*0e209d39SAndroid Build Coastguard Worker void TestRandomAccess(); 101*0e209d39SAndroid Build Coastguard Worker void TestExternalBreakEngineWithFakeTaiLe(); 102*0e209d39SAndroid Build Coastguard Worker void TestExternalBreakEngineWithFakeYue(); 103*0e209d39SAndroid Build Coastguard Worker void TestBug22579(); 104*0e209d39SAndroid Build Coastguard Worker void TestBug22581(); 105*0e209d39SAndroid Build Coastguard Worker void TestBug22584(); 106*0e209d39SAndroid Build Coastguard Worker void TestBug22585(); 107*0e209d39SAndroid Build Coastguard Worker void TestBug22602(); 108*0e209d39SAndroid Build Coastguard Worker void TestBug22636(); 109*0e209d39SAndroid Build Coastguard Worker 110*0e209d39SAndroid Build Coastguard Worker #if U_ENABLE_TRACING 111*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateCharacter(); 112*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateWord(); 113*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateSentence(); 114*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateTitle(); 115*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLine(); 116*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLineNormal(); 117*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLineStrict(); 118*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLineLoose(); 119*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLineNormalPhrase(); 120*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLineLoosePhrase(); 121*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLineStrictPhrase(); 122*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateLinePhrase(); 123*0e209d39SAndroid Build Coastguard Worker void TestTraceCreateBreakEngine(); 124*0e209d39SAndroid Build Coastguard Worker #endif 125*0e209d39SAndroid Build Coastguard Worker 126*0e209d39SAndroid Build Coastguard Worker /***********************/ 127*0e209d39SAndroid Build Coastguard Worker private: 128*0e209d39SAndroid Build Coastguard Worker /** 129*0e209d39SAndroid Build Coastguard Worker * internal methods to prepare test data 130*0e209d39SAndroid Build Coastguard Worker **/ 131*0e209d39SAndroid Build Coastguard Worker 132*0e209d39SAndroid Build Coastguard Worker void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t seed, 133*0e209d39SAndroid Build Coastguard Worker int32_t loopCount, UBool useUText, FILE *exportFile, UBool scalarsOnly); 134*0e209d39SAndroid Build Coastguard Worker 135*0e209d39SAndroid Build Coastguard Worker // Run one of the Unicode Consortium boundary test data files. 136*0e209d39SAndroid Build Coastguard Worker void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi); 137*0e209d39SAndroid Build Coastguard Worker 138*0e209d39SAndroid Build Coastguard Worker // Run tests from one of the LSTM test files. 139*0e209d39SAndroid Build Coastguard Worker void runLSTMTestFromFile(const char* filename, UScriptCode script); 140*0e209d39SAndroid Build Coastguard Worker 141*0e209d39SAndroid Build Coastguard Worker // Run a single test case from one of the Unicode Consortium test files. 142*0e209d39SAndroid Build Coastguard Worker void checkUnicodeTestCase(const char *testFileName, int lineNumber, 143*0e209d39SAndroid Build Coastguard Worker const UnicodeString &testString, 144*0e209d39SAndroid Build Coastguard Worker UVector32 *breakPositions, 145*0e209d39SAndroid Build Coastguard Worker RuleBasedBreakIterator *bi); 146*0e209d39SAndroid Build Coastguard Worker 147*0e209d39SAndroid Build Coastguard Worker // Run the actual tests for TestTailoredBreaks() 148*0e209d39SAndroid Build Coastguard Worker void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText, 149*0e209d39SAndroid Build Coastguard Worker const int32_t *expectOffsets, int32_t expectOffsetsCount); 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker /** Filter for test cases from the Unicode test data files. 152*0e209d39SAndroid Build Coastguard Worker * Some need to be skipped because ICU is unable to fully implement the 153*0e209d39SAndroid Build Coastguard Worker * Unicode boundary specifications. 154*0e209d39SAndroid Build Coastguard Worker * @param testCase the test data string. 155*0e209d39SAndroid Build Coastguard Worker * @param fileName the Unicode test data file name. 156*0e209d39SAndroid Build Coastguard Worker * @return false if the test case should be run, true if it should be skipped. 157*0e209d39SAndroid Build Coastguard Worker */ 158*0e209d39SAndroid Build Coastguard Worker UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName); 159*0e209d39SAndroid Build Coastguard Worker 160*0e209d39SAndroid Build Coastguard Worker // Test parameters, from the test framework and test invocation. 161*0e209d39SAndroid Build Coastguard Worker const char* fTestParams; 162*0e209d39SAndroid Build Coastguard Worker 163*0e209d39SAndroid Build Coastguard Worker // Helper functions to test different trie bit sizes and state table bit sizes. 164*0e209d39SAndroid Build Coastguard Worker void testTrieStateTable(int32_t numChar, bool expectedTrieWidthIn8Bits, bool expectedStateRowIn8Bits); 165*0e209d39SAndroid Build Coastguard Worker 166*0e209d39SAndroid Build Coastguard Worker #if U_ENABLE_TRACING 167*0e209d39SAndroid Build Coastguard Worker void assertTestTraceResult(int32_t fnNumber, const char* expectedData); 168*0e209d39SAndroid Build Coastguard Worker #endif 169*0e209d39SAndroid Build Coastguard Worker 170*0e209d39SAndroid Build Coastguard Worker }; 171*0e209d39SAndroid Build Coastguard Worker 172*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 173*0e209d39SAndroid Build Coastguard Worker 174*0e209d39SAndroid Build Coastguard Worker #endif 175