]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/rbbitst.h
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 ************************************************************************/
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();
84 void TestProperties();
86 /***********************/
89 * internal methods to prepare test data
93 * Perform tests of BreakIterator forward and backward functionality
94 * on different kinds of iterators (word, sentence, line and character).
95 * It tests the methods first(), next(), current(), preceding(), following()
96 * previous() and isBoundary().
97 * It makes use of internal functions to achieve this.
99 void generalIteratorTest(RuleBasedBreakIterator
& bi
, BITestData
&td
);
101 * Internal method to perform iteration and test the first() and next() functions
103 void testFirstAndNext(RuleBasedBreakIterator
& bi
, BITestData
&td
);
105 * Internal method to perform iteration and test the last() and previous() functions
107 void testLastAndPrevious(RuleBasedBreakIterator
& bi
, BITestData
&td
);
109 * Internal method to perform iteration and test the following() function
111 void testFollowing(RuleBasedBreakIterator
& bi
, BITestData
&td
);
113 * Internal method to perform iteration and test the preceding() function
115 void testPreceding(RuleBasedBreakIterator
& bi
, BITestData
&td
);
117 * Internal method to perform iteration and test the isBoundary() function
119 void testIsBoundary(RuleBasedBreakIterator
& bi
, BITestData
&td
);
121 * Internal method to perform tests of BreakIterator multiple selection functionality
122 * on different kinds of iterators (word, sentence, line and character)
124 void doMultipleSelectionTest(RuleBasedBreakIterator
& iterator
, BITestData
&td
);
126 void RunMonkey(BreakIterator
*bi
, RBBIMonkeyKind
&mk
, const char *name
, uint32_t seed
,
127 int32_t loopCount
, UBool useUText
);
129 // Run one of the Unicode Consortium boundary test data files.
130 void runUnicodeTestData(const char *fileName
, RuleBasedBreakIterator
*bi
);
132 // Run a single test case from one of the Unicode Consortium test files.
133 void checkUnicodeTestCase(const char *testFileName
, int lineNumber
,
134 const UnicodeString
&testString
,
135 UVector32
*breakPositions
,
136 RuleBasedBreakIterator
*bi
);
138 // Run the actual tests for TestTailoredBreaks()
139 void TBTest(BreakIterator
* brkitr
, int type
, const char *locale
, const char* escapedText
,
140 const int32_t *expectOffsets
, int32_t expectOffsetsCount
);
142 /** Filter for test cases from the Unicode test data files.
143 * Some need to be skipped because ICU is unable to fully implement the
144 * Unicode boundary specifications.
145 * @param testCase the test data string.
146 * @param fileName the Unicode test data file name.
147 * @return FALSE if the test case should be run, TRUE if it should be skipped.
149 UBool
testCaseIsKnownIssue(const UnicodeString
&testCase
, const char *fileName
);
151 // Test parameters, from the test framework and test invocation.
152 const char* fTestParams
;
155 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */