2007-07-27 03:25:38 +00:00
|
|
|
/*************************************************************************
|
2011-07-13 06:49:42 +00:00
|
|
|
* Copyright (c) 1999-2011, International Business Machines
|
2007-07-27 03:25:38 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*************************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 12/15/99 Madhu Creation.
|
|
|
|
* 01/12/2000 Madhu Updated for changed API and added new tests
|
|
|
|
************************************************************************/
|
2000-01-17 20:59:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef RBBITEST_H
|
|
|
|
#define RBBITEST_H
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_BREAK_ITERATION
|
2000-01-17 20:59:08 +00:00
|
|
|
|
|
|
|
#include "intltest.h"
|
|
|
|
#include "unicode/brkiter.h"
|
|
|
|
|
2007-05-29 22:56:20 +00:00
|
|
|
|
2003-05-27 16:29:25 +00:00
|
|
|
class Enumeration;
|
|
|
|
class BITestData;
|
2003-05-16 22:05:35 +00:00
|
|
|
struct TestParams;
|
2003-05-27 16:29:25 +00:00
|
|
|
class RBBIMonkeyKind;
|
2000-01-17 20:59:08 +00:00
|
|
|
|
2007-05-29 22:56:20 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
class UVector32;
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2000-01-17 20:59:08 +00:00
|
|
|
/**
|
|
|
|
* Test the RuleBasedBreakIterator class giving different rules
|
|
|
|
*/
|
|
|
|
class RBBITest: public IntlTest {
|
|
|
|
public:
|
2005-03-23 02:13:53 +00:00
|
|
|
|
2002-08-27 19:10:11 +00:00
|
|
|
RBBITest();
|
2002-08-28 15:55:37 +00:00
|
|
|
virtual ~RBBITest();
|
2002-08-27 19:10:11 +00:00
|
|
|
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
|
2005-03-23 02:13:53 +00:00
|
|
|
|
2002-06-27 01:50:22 +00:00
|
|
|
/**
|
|
|
|
* Tests rule status return values
|
2005-03-23 02:13:53 +00:00
|
|
|
**/
|
2002-06-27 01:50:22 +00:00
|
|
|
void TestStatusReturn();
|
|
|
|
|
2002-08-27 19:10:11 +00:00
|
|
|
void TestEmptyString();
|
|
|
|
void TestGetAvailableLocales();
|
|
|
|
void TestGetDisplayName();
|
|
|
|
void TestEndBehaviour();
|
|
|
|
void TestBug4153072();
|
|
|
|
void TestJapaneseLineBreak();
|
|
|
|
void TestThaiLineBreak();
|
2005-03-23 02:13:53 +00:00
|
|
|
void TestMixedThaiLineBreak();
|
|
|
|
void TestMaiyamok();
|
2003-05-27 16:29:25 +00:00
|
|
|
void TestMonkey(char *params);
|
2000-01-17 20:59:08 +00:00
|
|
|
|
2003-05-16 22:05:35 +00:00
|
|
|
void TestExtended();
|
2007-05-29 22:56:20 +00:00
|
|
|
UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
|
2003-05-16 22:05:35 +00:00
|
|
|
void executeTest(TestParams *);
|
|
|
|
|
2003-11-05 23:50:39 +00:00
|
|
|
void TestWordBreaks();
|
|
|
|
void TestWordBoundary();
|
|
|
|
void TestLineBreaks();
|
|
|
|
void TestSentBreaks();
|
2004-06-09 18:12:01 +00:00
|
|
|
void TestBug3818();
|
2004-10-21 01:03:01 +00:00
|
|
|
void TestJapaneseWordBreak();
|
2006-03-29 23:33:02 +00:00
|
|
|
void TestTrieDict();
|
2007-05-29 22:56:20 +00:00
|
|
|
void TestUnicodeFiles();
|
2007-07-10 18:11:43 +00:00
|
|
|
void TestBug5775();
|
2009-04-22 07:53:50 +00:00
|
|
|
void TestTailoredBreaks();
|
2009-09-10 23:17:38 +00:00
|
|
|
void TestDictRules();
|
2010-07-23 00:15:37 +00:00
|
|
|
void TestBug5532();
|
2007-05-29 22:56:20 +00:00
|
|
|
|
2005-03-23 02:13:53 +00:00
|
|
|
void TestDebug();
|
2011-12-08 22:37:24 +00:00
|
|
|
void TestProperties();
|
2005-03-23 02:13:53 +00:00
|
|
|
|
2000-01-17 20:59:08 +00:00
|
|
|
/***********************/
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* internal methods to prepare test data
|
|
|
|
**/
|
2005-03-23 02:13:53 +00:00
|
|
|
|
2000-01-17 20:59:08 +00:00
|
|
|
/**
|
2005-03-23 02:13:53 +00:00
|
|
|
* Perform tests of BreakIterator forward and backward functionality
|
2000-01-17 20:59:08 +00:00
|
|
|
* on different kinds of iterators (word, sentence, line and character).
|
2000-08-14 21:42:36 +00:00
|
|
|
* It tests the methods first(), next(), current(), preceding(), following()
|
|
|
|
* previous() and isBoundary().
|
|
|
|
* It makes use of internal functions to achieve this.
|
2000-01-17 20:59:08 +00:00
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void generalIteratorTest(RuleBasedBreakIterator& bi, BITestData &td);
|
2000-01-17 20:59:08 +00:00
|
|
|
/**
|
2000-08-14 21:42:36 +00:00
|
|
|
* Internal method to perform iteration and test the first() and next() functions
|
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void testFirstAndNext(RuleBasedBreakIterator& bi, BITestData &td);
|
2000-01-17 20:59:08 +00:00
|
|
|
/**
|
2000-08-14 21:42:36 +00:00
|
|
|
* Internal method to perform iteration and test the last() and previous() functions
|
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void testLastAndPrevious(RuleBasedBreakIterator& bi, BITestData &td);
|
2000-08-14 21:42:36 +00:00
|
|
|
/**
|
|
|
|
* Internal method to perform iteration and test the following() function
|
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void testFollowing(RuleBasedBreakIterator& bi, BITestData &td);
|
2000-08-14 21:42:36 +00:00
|
|
|
/**
|
|
|
|
* Internal method to perform iteration and test the preceding() function
|
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void testPreceding(RuleBasedBreakIterator& bi, BITestData &td);
|
2000-08-14 21:42:36 +00:00
|
|
|
/**
|
|
|
|
* Internal method to perform iteration and test the isBoundary() function
|
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void testIsBoundary(RuleBasedBreakIterator& bi, BITestData &td);
|
2000-01-17 20:59:08 +00:00
|
|
|
/**
|
2005-03-23 02:13:53 +00:00
|
|
|
* Internal method to perform tests of BreakIterator multiple selection functionality
|
2000-01-17 20:59:08 +00:00
|
|
|
* on different kinds of iterators (word, sentence, line and character)
|
|
|
|
**/
|
2002-07-22 22:02:08 +00:00
|
|
|
void doMultipleSelectionTest(RuleBasedBreakIterator& iterator, BITestData &td);
|
2000-08-14 21:42:36 +00:00
|
|
|
|
2005-07-08 01:57:58 +00:00
|
|
|
void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t seed,
|
|
|
|
int32_t loopCount, UBool useUText);
|
2003-05-27 16:29:25 +00:00
|
|
|
|
2007-05-29 22:56:20 +00:00
|
|
|
// Run one of the Unicode Consortium boundary test data files.
|
2007-05-30 22:34:39 +00:00
|
|
|
void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
|
2007-05-29 22:56:20 +00:00
|
|
|
|
|
|
|
// Run a single test case from one of the Unicode Consortium test files.
|
2007-05-30 22:34:39 +00:00
|
|
|
void checkUnicodeTestCase(const char *testFileName, int lineNumber,
|
2007-05-29 22:56:20 +00:00
|
|
|
const UnicodeString &testString,
|
|
|
|
UVector32 *breakPositions,
|
|
|
|
RuleBasedBreakIterator *bi);
|
2009-04-22 07:53:50 +00:00
|
|
|
|
|
|
|
// Run the actual tests for TestTailoredBreaks()
|
|
|
|
void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
|
|
|
|
const int32_t *expectOffsets, int32_t expectOffsetsCount);
|
2000-01-17 20:59:08 +00:00
|
|
|
};
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_BREAK_ITERATION */
|
2000-01-17 20:59:08 +00:00
|
|
|
|
|
|
|
#endif
|