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