1 // Copyright (C) 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 ************************************************************************/
16 #include "unicode/utypes.h"
18 #if !UCONFIG_NO_BREAK_ITERATION
21 #include "unicode/brkiter.h"
22 #include "unicode/rbbi.h"
34 * Test the RuleBasedBreakIterator class giving different rules
36 class RBBITest: public IntlTest {
42 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
45 * Tests rule status return values
47 void TestStatusReturn();
49 void TestEmptyString();
50 void TestGetAvailableLocales();
51 void TestGetDisplayName();
52 void TestEndBehaviour();
53 void TestBug4153072();
54 void TestJapaneseLineBreak();
55 void TestThaiLineBreak();
56 void TestMixedThaiLineBreak();
61 UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
62 void executeTest(TestParams *, UErrorCode &status);
64 void TestWordBreaks();
65 void TestWordBoundary();
66 void TestLineBreaks();
67 void TestSentBreaks();
69 void TestJapaneseWordBreak();
71 void TestUnicodeFiles();
73 void TestTailoredBreaks();
81 void TestProperties();
83 /***********************/
86 * internal methods to prepare test data
90 * Perform tests of BreakIterator forward and backward functionality
91 * on different kinds of iterators (word, sentence, line and character).
92 * It tests the methods first(), next(), current(), preceding(), following()
93 * previous() and isBoundary().
94 * It makes use of internal functions to achieve this.
96 void generalIteratorTest(RuleBasedBreakIterator& bi, BITestData &td);
98 * Internal method to perform iteration and test the first() and next() functions
100 void testFirstAndNext(RuleBasedBreakIterator& bi, BITestData &td);
102 * Internal method to perform iteration and test the last() and previous() functions
104 void testLastAndPrevious(RuleBasedBreakIterator& bi, BITestData &td);
106 * Internal method to perform iteration and test the following() function
108 void testFollowing(RuleBasedBreakIterator& bi, BITestData &td);
110 * Internal method to perform iteration and test the preceding() function
112 void testPreceding(RuleBasedBreakIterator& bi, BITestData &td);
114 * Internal method to perform iteration and test the isBoundary() function
116 void testIsBoundary(RuleBasedBreakIterator& bi, BITestData &td);
118 * Internal method to perform tests of BreakIterator multiple selection functionality
119 * on different kinds of iterators (word, sentence, line and character)
121 void doMultipleSelectionTest(RuleBasedBreakIterator& iterator, BITestData &td);
123 void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t seed,
124 int32_t loopCount, UBool useUText);
126 // Run one of the Unicode Consortium boundary test data files.
127 void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
129 // Run a single test case from one of the Unicode Consortium test files.
130 void checkUnicodeTestCase(const char *testFileName, int lineNumber,
131 const UnicodeString &testString,
132 UVector32 *breakPositions,
133 RuleBasedBreakIterator *bi);
135 // Run the actual tests for TestTailoredBreaks()
136 void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
137 const int32_t *expectOffsets, int32_t expectOffsetsCount);
139 /** Filter for test cases from the Unicode test data files.
140 * Some need to be skipped because ICU is unable to fully implement the
141 * Unicode boundary specifications.
142 * @param testCase the test data string.
143 * @param fileName the Unicode test data file name.
144 * @return FALSE if the test case should be run, TRUE if it should be skipped.
146 UBool testCaseIsKnownIssue(const UnicodeString &testCase, const char *fileName);
148 // Test parameters, from the test framework and test invocation.
149 const char* fTestParams;
152 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */