Home | History | Annotate | Download | only in intltest
      1 /*************************************************************************
      2  * Copyright (c) 1999-2010, International Business Machines
      3  * Corporation and others. All Rights Reserved.
      4  *************************************************************************
      5  *   Date        Name        Description
      6  *   12/15/99    Madhu        Creation.
      7  *   01/12/2000  Madhu        Updated for changed API and added new tests
      8  ************************************************************************/
      9 
     10 
     11 #ifndef RBBITEST_H
     12 #define RBBITEST_H
     13 
     14 #include "unicode/utypes.h"
     15 
     16 #if !UCONFIG_NO_BREAK_ITERATION
     17 
     18 #include "intltest.h"
     19 #include "unicode/brkiter.h"
     20 
     21 
     22 class  Enumeration;
     23 class  BITestData;
     24 struct TestParams;
     25 class  RBBIMonkeyKind;
     26 
     27 U_NAMESPACE_BEGIN
     28 class  UVector32;
     29 U_NAMESPACE_END
     30 
     31 /**
     32  * Test the RuleBasedBreakIterator class giving different rules
     33  */
     34 class RBBITest: public IntlTest {
     35 public:
     36 
     37     RBBITest();
     38     virtual ~RBBITest();
     39 
     40     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
     41 
     42     /**
     43      * Tests rule status return values
     44      **/
     45     void TestStatusReturn();
     46 
     47     void TestEmptyString();
     48     void TestGetAvailableLocales();
     49     void TestGetDisplayName();
     50     void TestEndBehaviour();
     51     void TestBug4153072();
     52     void TestJapaneseLineBreak();
     53     void TestThaiLineBreak();
     54     void TestMixedThaiLineBreak();
     55     void TestMaiyamok();
     56     void TestMonkey(char *params);
     57 
     58     void TestExtended();
     59     UChar *ReadAndConvertFile(const char *fileName, int &ulen, const char *encoding, UErrorCode &status);
     60     void executeTest(TestParams *);
     61 
     62     void TestWordBreaks();
     63     void TestWordBoundary();
     64     void TestLineBreaks();
     65     void TestSentBreaks();
     66     void TestBug3818();
     67     void TestJapaneseWordBreak();
     68     void TestTrieDict();
     69     void TestUnicodeFiles();
     70     void TestBug5775();
     71     void TestThaiBreaks();
     72     void TestTailoredBreaks();
     73     void TestTrieDictWithValue();
     74     void TestDictRules();
     75     void TestBug5532();
     76 
     77     void TestDebug();
     78 
     79 
     80 /***********************/
     81 private:
     82     /**
     83      * internal methods to prepare test data
     84      **/
     85 
     86     /**
     87      * Perform tests of BreakIterator forward and backward functionality
     88      * on different kinds of iterators (word, sentence, line and character).
     89      * It tests the methods first(), next(), current(), preceding(), following()
     90      * previous() and isBoundary().
     91      * It makes use of internal functions to achieve this.
     92      **/
     93     void generalIteratorTest(RuleBasedBreakIterator& bi, BITestData  &td);
     94     /**
     95      * Internal method to perform iteration and test the first() and next() functions
     96      **/
     97     void testFirstAndNext(RuleBasedBreakIterator& bi, BITestData &td);
     98     /**
     99      * Internal method to perform iteration and test the last() and previous() functions
    100      **/
    101     void testLastAndPrevious(RuleBasedBreakIterator& bi, BITestData &td);
    102     /**
    103      * Internal method to perform iteration and test the following() function
    104      **/
    105     void testFollowing(RuleBasedBreakIterator& bi, BITestData &td);
    106     /**
    107      * Internal method to perform iteration and test the preceding() function
    108      **/
    109     void testPreceding(RuleBasedBreakIterator& bi, BITestData &td);
    110     /**
    111      * Internal method to perform iteration and test the isBoundary() function
    112      **/
    113     void testIsBoundary(RuleBasedBreakIterator& bi, BITestData &td);
    114     /**
    115      * Internal method to perform tests of BreakIterator multiple selection functionality
    116      * on different kinds of iterators (word, sentence, line and character)
    117      **/
    118     void doMultipleSelectionTest(RuleBasedBreakIterator& iterator, BITestData &td);
    119 
    120     void RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name, uint32_t  seed,
    121         int32_t loopCount, UBool useUText);
    122 
    123     // Run one of the Unicode Consortium boundary test data files.
    124     void runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi);
    125 
    126     // Run a single test case from one of the Unicode Consortium test files.
    127     void checkUnicodeTestCase(const char *testFileName, int lineNumber,
    128                          const UnicodeString &testString,
    129                          UVector32 *breakPositions,
    130                          RuleBasedBreakIterator *bi);
    131 
    132     // Run the actual tests for TestTailoredBreaks()
    133     void TBTest(BreakIterator* brkitr, int type, const char *locale, const char* escapedText,
    134                 const int32_t *expectOffsets, int32_t expectOffsetsCount);
    135 };
    136 
    137 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
    138 
    139 #endif
    140