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 *
      6 *   Copyright (C) 2012-2013, International Business Machines
      7 *   Corporation and others.  All Rights Reserved.
      8 *
      9 *******************************************************************************
     10 *   file name:  listformattertest.cpp
     11 *   encoding:   UTF-8
     12 *   tab size:   8 (not used)
     13 *   indentation:4
     14 *
     15 *   created on: 2012aug27
     16 *   created by: Umesh P. Nair
     17 */
     18 
     19 #ifndef __LISTFORMATTERTEST_H__
     20 #define __LISTFORMATTERTEST_H__
     21 
     22 #include "unicode/fpositer.h"
     23 #include "unicode/listformatter.h"
     24 #include "intltest.h"
     25 
     26 class ListFormatterTest : public IntlTest {
     27   public:
     28     ListFormatterTest();
     29     virtual ~ListFormatterTest() {}
     30 
     31     void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0);
     32 
     33     void TestRoot();
     34     void TestBogus();
     35     void TestEnglish();
     36     void TestEnglishUS();
     37     void TestEnglishGB();
     38     void TestNynorsk();
     39     void TestChineseTradHK();
     40     void TestRussian();
     41     void TestMalayalam();
     42     void TestZulu();
     43     void TestOutOfOrderPatterns();
     44     void Test9946();
     45     void TestFieldPositionIteratorWontCrash();
     46     void TestFieldPositionIteratorWith1Item();
     47     void TestFieldPositionIteratorWith2Items();
     48     void TestFieldPositionIteratorWith3Items();
     49     void TestFieldPositionIteratorWith1ItemAndDataBefore();
     50     void TestFieldPositionIteratorWith2ItemsAndDataBefore();
     51     void TestFieldPositionIteratorWith3ItemsAndDataBefore();
     52     void TestFieldPositionIteratorWith2ItemsPatternShift();
     53     void TestFieldPositionIteratorWith3ItemsPatternShift();
     54 
     55   private:
     56     void CheckFormatting(
     57         const ListFormatter* formatter,
     58         UnicodeString data[],
     59         int32_t data_size,
     60         const UnicodeString& expected_result,
     61         const char* testName);
     62     void ExpectPositions(
     63         FieldPositionIterator& iter,
     64         int32_t *values,
     65         int32_t tupleCount);
     66     void RunTestFieldPositionIteratorWithNItems(
     67         UnicodeString *data,
     68         int32_t n,
     69         int32_t *values,
     70         int32_t tupleCount,
     71         UnicodeString& appendTo,
     72         const char16_t *expectedFormatted,
     73         const char* testName);
     74     void RunTestFieldPositionIteratorWithNItemsPatternShift(
     75         UnicodeString *data,
     76         int32_t n,
     77         int32_t *values,
     78         int32_t tupleCount,
     79         UnicodeString& appendTo,
     80         const char16_t *expectedFormatted,
     81         const char* testName);
     82     void RunTestFieldPositionIteratorWithFormatter(
     83         ListFormatter* formatter,
     84         UnicodeString *data,
     85         int32_t n,
     86         int32_t *values,
     87         int32_t tupleCount,
     88         UnicodeString& appendTo,
     89         const char16_t *expectedFormatted,
     90         const char* testName);
     91     void CheckFourCases(
     92         const char* locale_string,
     93         UnicodeString one,
     94         UnicodeString two,
     95         UnicodeString three,
     96         UnicodeString four,
     97         UnicodeString results[4],
     98         const char* testName);
     99     UBool RecordFourCases(
    100         const Locale& locale,
    101         UnicodeString one,
    102         UnicodeString two,
    103         UnicodeString three,
    104         UnicodeString four,
    105         UnicodeString results[4],
    106         const char* testName);
    107 
    108   private:
    109     // Reused test data.
    110     const UnicodeString prefix;
    111     const UnicodeString one;
    112     const UnicodeString two;
    113     const UnicodeString three;
    114     const UnicodeString four;
    115 };
    116 
    117 #endif
    118