os/textandloc/charconvfw/charconv_fw/test/rtest/tsrc/utf/trfc1642.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <e32std.h>
    20 #include <utf.h>
    21 #include "t_rfc1642.h"
    22 ///////////////////////////////////////////////////////////////////////////////////////
    23 #define test(cond)                                  \
    24     TEST((cond));                                   \
    25     if (!(cond))                                    \
    26         {                                           \
    27         ERR_PRINTF1(_L("ERROR: Test Failed"));      \
    28         User::Leave(1);                             \
    29         }
    30 
    31 ///////////////////////////////////////////////////////////////////////////////////////
    32 ///////////////////////////////////////////////////////////////////////////////////////
    33 /**
    34 @SYMTestCaseID          SYSLIB-CHARCONV-CT-0564
    35 @SYMTestCaseDesc        Tests for conversion from UTF-7 to Unicode character set
    36 @SYMTestPriority        Medium
    37 @SYMTestActions        	Tests for CnvUtfConverter::ConvertToUnicodeFromUtf7() function
    38 @SYMTestExpectedResults Test must not fail
    39 @SYMREQ                 REQ0000
    40 */
    41 void CT_RFC1642::TestRFC1642()
    42 	{
    43 
    44     INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0564 Testing the examples given in RFC 1642 "));
    45 	TBuf16<256> generatedUnicode;
    46 	TInt state=CnvUtfConverter::KStateDefault;
    47 	//
    48 	INFO_PRINTF1(_L("Empty descriptor"));
    49 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8(""), state)==0);
    50 	test(state==CnvUtfConverter::KStateDefault);
    51 	test(generatedUnicode==_L16(""));
    52 	INFO_PRINTF1(_L("\"A<NOT IDENTICAL TO><ALPHA>.\""));
    53 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("A+ImIDkQ."), state)==0);
    54 	test(state==CnvUtfConverter::KStateDefault);
    55 	test(generatedUnicode.Length()==4);
    56 	test(generatedUnicode[0]==0x0041);
    57 	test(generatedUnicode[1]==0x2262);
    58 	test(generatedUnicode[2]==0x0391);
    59 	test(generatedUnicode[3]==0x002e);
    60 	INFO_PRINTF1(_L("\"Hi Mom <WHITE SMILING FACE>!\""));
    61 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("Hi Mom +Jjo-!"), state)==0);
    62 	test(state==CnvUtfConverter::KStateDefault);
    63 	test(generatedUnicode.Length()==9);
    64 	test(generatedUnicode[0]==0x0048);
    65 	test(generatedUnicode[1]==0x0069);
    66 	test(generatedUnicode[2]==0x0020);
    67 	test(generatedUnicode[3]==0x004d);
    68 	test(generatedUnicode[4]==0x006f);
    69 	test(generatedUnicode[5]==0x006d);
    70 	test(generatedUnicode[6]==0x0020);
    71 	test(generatedUnicode[7]==0x263a);
    72 	test(generatedUnicode[8]==0x0021);
    73 	INFO_PRINTF1(_L("The japanese word \"nihongo\""));
    74 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+ZeVnLIqe-"), state)==0);
    75 	test(state==CnvUtfConverter::KStateDefault);
    76 	test(generatedUnicode.Length()==3);
    77 	test(generatedUnicode[0]==0x65e5);
    78 	test(generatedUnicode[1]==0x672c);
    79 	test(generatedUnicode[2]==0x8a9e);
    80 	INFO_PRINTF1(_L("The special case of \"+-\""));
    81 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+-"), state)==0);
    82 	test(state==CnvUtfConverter::KStateDefault);
    83 	test(generatedUnicode==_L16("+"));
    84 	INFO_PRINTF1(_L("The special case of \"+-\" in a context"));
    85 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("2+-3 is 5"), state)==0);
    86 	test(state==CnvUtfConverter::KStateDefault);
    87 	test(generatedUnicode==_L16("2+3 is 5"));
    88 	//
    89 
    90 	}
    91 
    92 CT_RFC1642::CT_RFC1642()
    93     {
    94     SetTestStepName(KTestStep_T_RFC1642);
    95     }
    96 
    97 TVerdict CT_RFC1642::doTestStepL()
    98     {
    99     SetTestStepResult(EFail);
   100 
   101     __UHEAP_MARK;
   102 
   103     TRAPD(error1, TestRFC1642());
   104 
   105     __UHEAP_MARKEND;
   106 
   107     if(error1 == KErrNone )
   108         {
   109         SetTestStepResult(EPass);
   110         }
   111 
   112     return TestStepResult();
   113     }
   114