2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2012-08-27 20:14:25 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 2012-2013, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2012-08-27 20:14:25 +00:00
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: listformattertest.cpp
|
2017-02-03 18:57:23 +00:00
|
|
|
* encoding: UTF-8
|
2012-08-27 20:14:25 +00:00
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2012aug27
|
|
|
|
* created by: Umesh P. Nair
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LISTFORMATTERTEST_H__
|
|
|
|
#define __LISTFORMATTERTEST_H__
|
|
|
|
|
2018-09-10 02:14:16 +00:00
|
|
|
#include "unicode/fpositer.h"
|
2012-08-27 20:14:25 +00:00
|
|
|
#include "unicode/listformatter.h"
|
|
|
|
#include "intltest.h"
|
2019-02-05 02:47:04 +00:00
|
|
|
#include "itformat.h"
|
2012-08-27 20:14:25 +00:00
|
|
|
|
2019-02-28 19:20:22 +00:00
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
2019-02-05 02:47:04 +00:00
|
|
|
class ListFormatterTest : public IntlTestWithFieldPosition {
|
2012-08-27 20:14:25 +00:00
|
|
|
public:
|
|
|
|
ListFormatterTest();
|
|
|
|
virtual ~ListFormatterTest() {}
|
|
|
|
|
|
|
|
void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0);
|
|
|
|
|
|
|
|
void TestRoot();
|
|
|
|
void TestBogus();
|
|
|
|
void TestEnglish();
|
|
|
|
void TestEnglishUS();
|
2017-03-24 08:13:10 +00:00
|
|
|
void TestEnglishGB();
|
|
|
|
void TestNynorsk();
|
|
|
|
void TestChineseTradHK();
|
2012-08-27 20:14:25 +00:00
|
|
|
void TestRussian();
|
|
|
|
void TestMalayalam();
|
|
|
|
void TestZulu();
|
2012-09-12 00:14:25 +00:00
|
|
|
void TestOutOfOrderPatterns();
|
2013-09-17 18:01:18 +00:00
|
|
|
void Test9946();
|
2018-09-10 02:14:16 +00:00
|
|
|
void TestFieldPositionIteratorWontCrash();
|
|
|
|
void TestFieldPositionIteratorWith1Item();
|
|
|
|
void TestFieldPositionIteratorWith2Items();
|
|
|
|
void TestFieldPositionIteratorWith3Items();
|
|
|
|
void TestFieldPositionIteratorWith1ItemAndDataBefore();
|
|
|
|
void TestFieldPositionIteratorWith2ItemsAndDataBefore();
|
|
|
|
void TestFieldPositionIteratorWith3ItemsAndDataBefore();
|
|
|
|
void TestFieldPositionIteratorWith2ItemsPatternShift();
|
|
|
|
void TestFieldPositionIteratorWith3ItemsPatternShift();
|
2019-02-05 02:47:04 +00:00
|
|
|
void TestFormattedValue();
|
2019-02-15 18:42:54 +00:00
|
|
|
void TestDifferentStyles();
|
|
|
|
void TestBadStylesFail();
|
2019-11-16 07:28:26 +00:00
|
|
|
void TestCreateStyled();
|
2012-08-27 20:14:25 +00:00
|
|
|
|
|
|
|
private:
|
2018-09-10 02:14:16 +00:00
|
|
|
void CheckFormatting(
|
|
|
|
const ListFormatter* formatter,
|
|
|
|
UnicodeString data[],
|
|
|
|
int32_t data_size,
|
|
|
|
const UnicodeString& expected_result,
|
|
|
|
const char* testName);
|
|
|
|
void ExpectPositions(
|
|
|
|
FieldPositionIterator& iter,
|
|
|
|
int32_t *values,
|
|
|
|
int32_t tupleCount);
|
|
|
|
void RunTestFieldPositionIteratorWithNItems(
|
|
|
|
UnicodeString *data,
|
|
|
|
int32_t n,
|
|
|
|
int32_t *values,
|
|
|
|
int32_t tupleCount,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
const char16_t *expectedFormatted,
|
|
|
|
const char* testName);
|
|
|
|
void RunTestFieldPositionIteratorWithNItemsPatternShift(
|
|
|
|
UnicodeString *data,
|
|
|
|
int32_t n,
|
|
|
|
int32_t *values,
|
|
|
|
int32_t tupleCount,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
const char16_t *expectedFormatted,
|
|
|
|
const char* testName);
|
|
|
|
void RunTestFieldPositionIteratorWithFormatter(
|
|
|
|
ListFormatter* formatter,
|
|
|
|
UnicodeString *data,
|
|
|
|
int32_t n,
|
|
|
|
int32_t *values,
|
|
|
|
int32_t tupleCount,
|
|
|
|
UnicodeString& appendTo,
|
|
|
|
const char16_t *expectedFormatted,
|
|
|
|
const char* testName);
|
2012-08-27 20:14:25 +00:00
|
|
|
void CheckFourCases(
|
|
|
|
const char* locale_string,
|
|
|
|
UnicodeString one,
|
|
|
|
UnicodeString two,
|
|
|
|
UnicodeString three,
|
|
|
|
UnicodeString four,
|
2018-09-10 02:14:16 +00:00
|
|
|
UnicodeString results[4],
|
|
|
|
const char* testName);
|
2012-11-15 18:15:37 +00:00
|
|
|
UBool RecordFourCases(
|
|
|
|
const Locale& locale,
|
|
|
|
UnicodeString one,
|
|
|
|
UnicodeString two,
|
|
|
|
UnicodeString three,
|
|
|
|
UnicodeString four,
|
2018-09-10 02:14:16 +00:00
|
|
|
UnicodeString results[4],
|
|
|
|
const char* testName);
|
2019-02-15 18:42:54 +00:00
|
|
|
void DoTheRealListStyleTesting(
|
|
|
|
Locale locale,
|
|
|
|
UnicodeString items[],
|
|
|
|
int32_t itemCount,
|
|
|
|
const char* style,
|
|
|
|
const char* expected,
|
|
|
|
IcuTestErrorCode status);
|
2012-08-27 20:14:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Reused test data.
|
|
|
|
const UnicodeString prefix;
|
|
|
|
const UnicodeString one;
|
|
|
|
const UnicodeString two;
|
|
|
|
const UnicodeString three;
|
|
|
|
const UnicodeString four;
|
|
|
|
};
|
|
|
|
|
2019-02-28 19:20:22 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
|
|
|
|
2012-08-27 20:14:25 +00:00
|
|
|
#endif
|