Home | History | Annotate | Download | only in intltest
      1 /*
      2 **********************************************************************
      3 *   Copyright (C) 1999-2003, International Business Machines
      4 *   Corporation and others.  All Rights Reserved.
      5 **********************************************************************
      6 *   Date        Name        Description
      7 *   12/09/99    aliu        Ported from Java.
      8 **********************************************************************
      9 */
     10 
     11 #ifndef COLLATIONTHAITEST_H
     12 #define COLLATIONTHAITEST_H
     13 
     14 #include "unicode/utypes.h"
     15 
     16 #if !UCONFIG_NO_COLLATION
     17 
     18 #include "tscoll.h"
     19 
     20 class CollationThaiTest : public IntlTestCollator {
     21     Collator* coll; // Thai collator
     22 
     23 public:
     24 
     25     CollationThaiTest();
     26     virtual ~CollationThaiTest();
     27 
     28     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
     29 
     30 private:
     31 
     32     /**
     33      * Read the external dictionary file, which is already in proper
     34      * sorted order, and confirm that the collator compares each line as
     35      * preceding the following line.
     36      */
     37     void TestDictionary(void);
     38 
     39     /**
     40      * Odd corner conditions taken from "How to Sort Thai Without Rewriting Sort",
     41      * by Doug Cooper, http://seasrc.th.net/paper/thaisort.zip
     42      */
     43     void TestCornerCases(void);
     44 
     45     /**
     46      * Read the external names list, and confirms that the collator
     47      * gets the same results when comparing lines one to another
     48      * using regular and iterative comparison.
     49      */
     50     void TestNamesList(void);
     51 
     52     /**
     53      * test that invalid Thai sorts properly
     54      */
     55     void TestInvalidThai(void);
     56 
     57     /**
     58      * test that reording is done properly
     59      */
     60     void TestReordering(void);
     61 
     62 private:
     63 
     64     void compareArray(Collator& c, const char* tests[],
     65                       int32_t testsLength);
     66 
     67     int8_t sign(int32_t i);
     68 
     69     /**
     70      * Set a UnicodeString corresponding to the given string.  Use
     71      * UnicodeString and the default converter, unless we see the sequence
     72      * "\\u", in which case we interpret the subsequent escape.
     73      */
     74     UnicodeString& parseChars(UnicodeString& result,
     75                               const char* chars);
     76 };
     77 
     78 #endif /* #if !UCONFIG_NO_COLLATION */
     79 
     80 #endif
     81