summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-src/source/test/intltest/listformattertest.h
blob: 0f0390010e4e295e1e32afb6520e6178667c54b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
*   Copyright (C) 2012-2013, International Business Machines
*   Corporation and others.  All Rights Reserved.
*
*******************************************************************************
*   file name:  listformattertest.cpp
*   encoding:   UTF-8
*   tab size:   8 (not used)
*   indentation:4
*
*   created on: 2012aug27
*   created by: Umesh P. Nair
*/

#ifndef __LISTFORMATTERTEST_H__
#define __LISTFORMATTERTEST_H__

#include "unicode/fpositer.h"
#include "unicode/listformatter.h"
#include "intltest.h"
#include "itformat.h"

#if !UCONFIG_NO_FORMATTING

class ListFormatterTest : public IntlTestWithFieldPosition {
  public:
    ListFormatterTest();
    virtual ~ListFormatterTest() {}

    void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0) override;

    void TestRoot();
    void TestBogus();
    void TestEnglish();
    void TestEnglishUS();
    void TestEnglishGB();
    void TestNynorsk();
    void TestChineseTradHK();
    void TestRussian();
    void TestMalayalam();
    void TestZulu();
    void TestOutOfOrderPatterns();
    void Test9946();
    void TestFieldPositionIteratorWith1Item();
    void TestFieldPositionIteratorWith2Items();
    void TestFieldPositionIteratorWith3Items();
    void TestFieldPositionIteratorWith2ItemsPatternShift();
    void TestFieldPositionIteratorWith3ItemsPatternShift();
    void TestFormattedValue();
    void TestDifferentStyles();
    void TestCreateStyled();
    void TestContextual();
    void TestNextPosition();
    void TestInt32Overflow();
    void Test21871();

  private:
    void CheckFormatting(
        const ListFormatter* formatter,
        UnicodeString data[],
        int32_t data_size,
        const UnicodeString& expected_result,
        const char* testName);
    void ExpectPositions(
        const FormattedList& iter,
        int32_t *values,
        int32_t tupleCount,
        UErrorCode& status);
    void RunTestFieldPositionIteratorWithNItems(
        UnicodeString *data,
        int32_t n,
        int32_t *values,
        int32_t tupleCount,
        const char16_t *expectedFormatted,
        const char* testName);
    void RunTestFieldPositionIteratorWithNItemsPatternShift(
        UnicodeString *data,
        int32_t n,
        int32_t *values,
        int32_t tupleCount,
        const char16_t *expectedFormatted,
        const char* testName);
    void RunTestFieldPositionIteratorWithFormatter(
        ListFormatter* formatter,
        UnicodeString *data,
        int32_t n,
        int32_t *values,
        int32_t tupleCount,
        const char16_t *expectedFormatted,
        const char* testName);
    void CheckFourCases(
        const char* locale_string,
        UnicodeString one,
        UnicodeString two,
        UnicodeString three,
        UnicodeString four,
        UnicodeString results[4],
        const char* testName);
    UBool RecordFourCases(
        const Locale& locale,
        UnicodeString one,
        UnicodeString two,
        UnicodeString three,
        UnicodeString four,
        UnicodeString results[4],
        const char* testName);
    void DoTheRealListStyleTesting(
        Locale locale,
        UnicodeString items[],
        int itemCount,
        UListFormatterType type,
        UListFormatterWidth width,
        const char* expected,
        IcuTestErrorCode status);

  private:
    // Reused test data.
    const UnicodeString prefix;
    const UnicodeString one;
    const UnicodeString two;
    const UnicodeString three;
    const UnicodeString four;
};

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif