xref: /aosp_15_r20/external/icu/icu4c/source/test/intltest/utxttest.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4  * COPYRIGHT:
5  * Copyright (c) 2005-2016, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  ********************************************************************/
8 /************************************************************************
9 *   Tests for the UText and UTextIterator text abstraction classes
10 *
11 ************************************************************************/
12 
13 
14 #ifndef UTXTTEST_H
15 #define UTXTTEST_H
16 
17 #include "unicode/utypes.h"
18 #include "unicode/unistr.h"
19 #include "unicode/utext.h"
20 
21 #include "intltest.h"
22 
23 /**
24  * @test
25  * @summary Testing the Replaceable class
26  */
27 class UTextTest : public IntlTest {
28 public:
29     UTextTest();
30     virtual ~UTextTest();
31 
32     void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=nullptr) override;
33     void TextTest();
34     void ErrorTest();
35     void FreezeTest();
36     void Ticket5560();
37     void Ticket6847();
38     void Ticket10562();
39     void Ticket10983();
40     void Ticket12130();
41     void Ticket13344();
42     void AccessChangesChunkSize();
43 
44 private:
45     struct m {                              // Map between native indices & code points.
46         int         nativeIdx;
47         UChar32     cp;
48     };
49 
50     void TestString(const UnicodeString &s);
51     void TestAccess(const UnicodeString &us, UText *ut, int cpCount, m *cpMap);
52     void TestAccessNoClone(const UnicodeString &us, UText *ut, int cpCount, m *cpMap);
53     void TestCMR   (const UnicodeString &us, UText *ut, int cpCount, m *nativeMap, m *utf16Map);
54     void TestCopyMove(const UnicodeString &us, UText *ut, UBool move,
55                       int32_t nativeStart, int32_t nativeLimit, int32_t nativeDest,
56                       int32_t u16Start, int32_t u16Limit, int32_t u16Dest);
57     void TestReplace(const UnicodeString &us,  // reference UnicodeString in which to do the replace
58             UText         *ut,                 // UnicodeText object under test.
59             int32_t       nativeStart,         // Range to be replaced, in UText native units.
60             int32_t       nativeLimit,
61             int32_t       u16Start,            // Range to be replaced, in UTF-16 units
62             int32_t       u16Limit,            //    for use in the reference UnicodeString.
63             const UnicodeString &repStr);      // The replacement string
64 
65 
66 };
67 
68 
69 #endif
70