1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/********************************************************************
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * COPYRIGHT:
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Copyright (c) 1997-2001, International Business Machines Corporation and
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * others. All Rights Reserved.
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ********************************************************************/
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Collation Iterator tests.
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (Let me reiterate my position...)
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef _ITERCOLL
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define _ITERCOLL
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_COLLATION
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/tblcoll.h"
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/coleitr.h"
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "tscoll.h"
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass CollationIteratorTest: public IntlTestCollator
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // If this is too small for the test data, just increase it.
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Just don't make it too large, otherwise the executable will get too big
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    enum EToken_Len { MAX_TOKEN_LEN = 16 };
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    CollationIteratorTest();
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~CollationIteratorTest();
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par = NULL);
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    * Test that results from CollationElementIterator.next is equivalent to
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    * the reversed results from CollationElementIterator.previous, for the set
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    * of BMP characters.
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    */
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestUnicodeChar();
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Test for CollationElementIterator.previous()
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @bug 4108758 - Make sure it works with contracting characters
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestPrevious(/* char* par */);
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Test for getOffset() and setOffset()
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestOffset(/* char* par */);
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Test for setText()
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestSetText(/* char* par */);
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /** @bug 4108762
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Test for getMaxExpansion()
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestMaxExpansion(/* char* par */);
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @bug 4157299
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestClearBuffers(/* char* par */);
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Testing the assignment operator
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestAssignment();
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Testing the constructors
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestConstructors();
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    * Testing the strength order functionality
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    */
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void TestStrengthOrder();
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //------------------------------------------------------------------------
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Internal utilities
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    struct ExpansionRecord
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        UChar character;
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        int32_t count;
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    };
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Verify that getMaxExpansion works on a given set of collation rules
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void verifyExpansion(UnicodeString rules, ExpansionRecord tests[], int32_t testCount);
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Return a string containing all of the collation orders
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * returned by calls to next on the specified iterator
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UnicodeString &orderString(CollationElementIterator &iter, UnicodeString &target);
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void assertEqual(CollationElementIterator &i1, CollationElementIterator &i2);
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    RuleBasedCollator *en_us;
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UnicodeString test1;
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const UnicodeString test2;
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_COLLATION */
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
120