Home | History | Annotate | Download | only in intltest
      1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /********************************************************************
      4  * COPYRIGHT:
      5  * Copyright (c) 1997-2016, International Business Machines Corporation and
      6  * others. All Rights Reserved.
      7  ********************************************************************/
      8 #ifndef _TESTMESSAGEFORMAT
      9 #define _TESTMESSAGEFORMAT
     10 
     11 #include "unicode/utypes.h"
     12 
     13 #if !UCONFIG_NO_FORMATTING
     14 
     15 #include "unicode/unistr.h"
     16 #include "unicode/fmtable.h"
     17 #include "unicode/msgfmt.h"
     18 #include "intltest.h"
     19 
     20 /**
     21  * TestMessageFormat tests MessageFormat, and also a few unctions in ChoiceFormat
     22  */
     23 class TestMessageFormat: public IntlTest {
     24 public:
     25     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
     26 
     27     /**
     28      * regression test for a specific bug regarding ChoiceFormat boundaries
     29      **/
     30     void testBug1(void);
     31     /**
     32      * regression test for a specific bug regarding MessageFormat using ChoiceFormat
     33      **/
     34     void testBug2(void);
     35     /**
     36      * regression test for a specific bug involving NumberFormat and Locales
     37      **/
     38     void testBug3(void);
     39     /**
     40      * test MessageFormat with various given patterns
     41      **/
     42     void PatternTest(void);
     43     /**
     44      * test MesageFormat formatting functionality in a simple example
     45      **/
     46     void sample(void);
     47 
     48     /**
     49     * tests the static MessageFormat::format method
     50      **/
     51     void testStaticFormat(/* char* par */);
     52     /**
     53      * tests MesageFormat functionality with a simple format
     54      **/
     55     void testSimpleFormat(/* char* par */);
     56     /**
     57      * tests MesageFormat functionality with a format including a ChoiceFormat
     58      **/
     59     void testMsgFormatChoice(/* char* par */);
     60     /**
     61      * tests MesageFormat functionality with a PluralFormat.
     62      **/
     63     void testMsgFormatPlural(/* char* par */);
     64 
     65     /**
     66      * tests MessageFormat functionality with a SelectFormat.
     67      **/
     68     void testMsgFormatSelect(/* char* par */);
     69 
     70     void testApostropheInPluralAndSelect();
     71 
     72     /**
     73      * Internal method to format a MessageFormat object with passed args
     74      **/
     75     void internalFormat(MessageFormat* msgFmt ,
     76         Formattable* args , int32_t numOfArgs ,
     77         UnicodeString expected, const char* errMsg);
     78 
     79     /**
     80      * Internal method to create a MessageFormat object with passed args
     81      **/
     82     MessageFormat* internalCreate(
     83         UnicodeString pattern ,Locale locale , UErrorCode& err, char* errMsg);
     84 
     85     /**
     86      * Verify that MessageFormat accomodates more than 10 arguments
     87      * and more than 10 subformats.
     88      */
     89     void TestUnlimitedArgsAndSubformats();
     90 
     91     /**
     92      * Test RBNF extensions to MessageFormat.
     93      */
     94     void TestRBNF();
     95 
     96     void TestApostropheMode();
     97 
     98     void TestCompatibleApostrophe();
     99 
    100     /**
    101      * ------------ API tests ----------
    102      * These routines test various API functionality.
    103      * In addition to the methods their name suggests,
    104      * they often test other methods as well.
    105      **/
    106     void testCopyConstructor(void);
    107     void testCopyConstructor2(void);
    108     void testAssignment(void);
    109     void testClone(void);
    110     void testEquals(void);
    111     void testNotEquals(void);
    112     void testSetLocale(void);
    113     void testFormat(void);
    114     void testParse(void);
    115     void testAdopt(void);
    116     void TestTurkishCasing(void);
    117     void testAutoQuoteApostrophe(void);
    118     void testCoverage();
    119     void testGetFormatNames();
    120     void TestTrimArgumentName();
    121     void TestSelectOrdinal();
    122     void TestDecimals();
    123     void TestArgIsPrefixOfAnother();
    124 
    125 private:
    126     UnicodeString GetPatternAndSkipSyntax(const MessagePattern& pattern);
    127 };
    128 
    129 #endif /* #if !UCONFIG_NO_FORMATTING */
    130 
    131 #endif
    132