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