os/textandloc/charconvfw/charconv_fw/test/rtest/tsrc/utf/tnewlin7.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_newlin7.h"
    22 
    23 ///////////////////////////////////////////////////////////////////////////////////////
    24 
    25 #define test(cond)                                          \
    26     {                                                       \
    27     TBool __bb = (cond);                                    \
    28     TEST(__bb);                                             \
    29     if (!__bb)                                              \
    30         {                                                   \
    31         ERR_PRINTF1(_L("ERROR: Test Failed"));              \
    32         User::Leave(1);                                     \
    33         }                                                   \
    34     }
    35 ///////////////////////////////////////////////////////////////////////////////////////
    36 ///////////////////////////////////////////////////////////////////////////////////////
    37 /**
    38 @SYMTestCaseID          SYSLIB-CHARCONV-CT-0570
    39 @SYMTestCaseDesc        Testing base64 sequences combined with line-breaks
    40 @SYMTestPriority        Medium
    41 @SYMTestActions        	Tests for conversion from UTF-7 to Unicode with line-breaks
    42 @SYMTestExpectedResults Test must not fail
    43 @SYMREQ                 REQ0000
    44 */
    45 void CT_NEWLIN7::TestNEWLIN7()
    46 	{
    47     INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0570 Testing base64 sequences combined with line-breaks "));
    48 	TBuf16<256> unicode;
    49 	TBuf8<256> utf7;
    50 	TInt state=CnvUtfConverter::KStateDefault;
    51 	utf7=_L8("+U0E\nU0E");
    52 	test(CnvUtfConverter::ConvertToUnicodeFromUtf7(unicode, utf7, state)==0);
    53 	test(state==CnvUtfConverter::KStateDefault);
    54 	test(unicode.Length()==5);
    55 	test(unicode[0]==0x5341);
    56 	test(unicode[1]==0x000a);
    57 	test(unicode[2]==0x0055);
    58 	test(unicode[3]==0x0030);
    59 	test(unicode[4]==0x0045);
    60 	unicode=_L16(")\n)\n*\n*\n+\n+\n)\n)\n*\n*\n+\n+");
    61 	test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf7, unicode, ETrue)==0);
    62 	test(utf7==_L8(")\n)\n+ACo-\n+ACo-\n+-\n+-\n)\n)\n+ACo-\n+ACo-\n+-\n+-"));
    63 	test(CnvUtfConverter::ConvertFromUnicodeToUtf7(utf7, unicode, EFalse)==0);
    64 	test(utf7==_L8(")\n)\n*\n*\n+-\n+-\n)\n)\n*\n*\n+-\n+-"));
    65 	}
    66 
    67 CT_NEWLIN7::CT_NEWLIN7()
    68     {
    69     SetTestStepName(KTestStep_T_NEWLIN7);
    70     }
    71 
    72 TVerdict CT_NEWLIN7::doTestStepL()
    73     {
    74     SetTestStepResult(EFail);
    75 
    76     __UHEAP_MARK;
    77 
    78     TRAPD(error1, TestNEWLIN7());
    79 
    80     __UHEAP_MARKEND;
    81 
    82     if(error1 == KErrNone )
    83         {
    84         SetTestStepResult(EPass);
    85         }
    86 
    87     return TestStepResult();
    88     }