sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include "t_rfc1642.h" sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: #define test(cond) \ sl@0: TEST((cond)); \ sl@0: if (!(cond)) \ sl@0: { \ sl@0: ERR_PRINTF1(_L("ERROR: Test Failed")); \ sl@0: User::Leave(1); \ sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////// sl@0: /** sl@0: @SYMTestCaseID SYSLIB-CHARCONV-CT-0564 sl@0: @SYMTestCaseDesc Tests for conversion from UTF-7 to Unicode character set sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Tests for CnvUtfConverter::ConvertToUnicodeFromUtf7() function sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_RFC1642::TestRFC1642() sl@0: { sl@0: sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0564 Testing the examples given in RFC 1642 ")); sl@0: TBuf16<256> generatedUnicode; sl@0: TInt state=CnvUtfConverter::KStateDefault; sl@0: // sl@0: INFO_PRINTF1(_L("Empty descriptor")); sl@0: test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8(""), state)==0); sl@0: test(state==CnvUtfConverter::KStateDefault); sl@0: test(generatedUnicode==_L16("")); sl@0: INFO_PRINTF1(_L("\"A.\"")); sl@0: test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("A+ImIDkQ."), state)==0); sl@0: test(state==CnvUtfConverter::KStateDefault); sl@0: test(generatedUnicode.Length()==4); sl@0: test(generatedUnicode[0]==0x0041); sl@0: test(generatedUnicode[1]==0x2262); sl@0: test(generatedUnicode[2]==0x0391); sl@0: test(generatedUnicode[3]==0x002e); sl@0: INFO_PRINTF1(_L("\"Hi Mom !\"")); sl@0: test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("Hi Mom +Jjo-!"), state)==0); sl@0: test(state==CnvUtfConverter::KStateDefault); sl@0: test(generatedUnicode.Length()==9); sl@0: test(generatedUnicode[0]==0x0048); sl@0: test(generatedUnicode[1]==0x0069); sl@0: test(generatedUnicode[2]==0x0020); sl@0: test(generatedUnicode[3]==0x004d); sl@0: test(generatedUnicode[4]==0x006f); sl@0: test(generatedUnicode[5]==0x006d); sl@0: test(generatedUnicode[6]==0x0020); sl@0: test(generatedUnicode[7]==0x263a); sl@0: test(generatedUnicode[8]==0x0021); sl@0: INFO_PRINTF1(_L("The japanese word \"nihongo\"")); sl@0: test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+ZeVnLIqe-"), state)==0); sl@0: test(state==CnvUtfConverter::KStateDefault); sl@0: test(generatedUnicode.Length()==3); sl@0: test(generatedUnicode[0]==0x65e5); sl@0: test(generatedUnicode[1]==0x672c); sl@0: test(generatedUnicode[2]==0x8a9e); sl@0: INFO_PRINTF1(_L("The special case of \"+-\"")); sl@0: test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+-"), state)==0); sl@0: test(state==CnvUtfConverter::KStateDefault); sl@0: test(generatedUnicode==_L16("+")); sl@0: INFO_PRINTF1(_L("The special case of \"+-\" in a context")); sl@0: test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("2+-3 is 5"), state)==0); sl@0: test(state==CnvUtfConverter::KStateDefault); sl@0: test(generatedUnicode==_L16("2+3 is 5")); sl@0: // sl@0: sl@0: } sl@0: sl@0: CT_RFC1642::CT_RFC1642() sl@0: { sl@0: SetTestStepName(KTestStep_T_RFC1642); sl@0: } sl@0: sl@0: TVerdict CT_RFC1642::doTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TRAPD(error1, TestRFC1642()); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: if(error1 == KErrNone ) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: