First public contribution.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 #include "t_realuni.h"
24 ///////////////////////////////////////////////////////////////////////////////////////
29 TBool __bb = (cond); \
33 ERR_PRINTF1(_L("ERROR: Test Failed")); \
38 ///////////////////////////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////////////////
41 @SYMTestCaseID SYSLIB-CHARCONV-CT-0568
42 @SYMTestCaseDesc Testing a real Unicode file's round trip
43 @SYMTestPriority Medium
44 @SYMTestActions Tests for CnvUtfConverter::ConvertFromUnicodeToUtf8() function
45 @SYMTestExpectedResults Test must not fail
48 void CT_REALUNI::TestREALUNI()
50 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0568 Testing a \"real\" Unicode file's round trip "));
53 test(fs.Connect() == KErrNone);
54 TFindFile findFile=fs;
55 test(findFile.FindByDir(_L("DAXUE.UNI"), _L("\\system\\data\\"))==KErrNone);
56 test(file.Open(fs, findFile.File(), EFileShareExclusive|EFileStream|EFileRead)==KErrNone);
58 test(file.Size(size) == KErrNone);
59 test((size>0) && (size%2==0));
60 HBufC16* originalUnicode=HBufC16::New(size/2);
61 HBufC8* generatedUtf8=HBufC8::New(size*2);
62 HBufC16* generatedUnicode=HBufC16::New(size/2);
63 test(originalUnicode!=NULL);
64 test(generatedUtf8!=NULL);
65 test(generatedUnicode!=NULL);
66 TPtr8 ptr1(REINTERPRET_CAST(TUint8*, CONST_CAST(TUint16*, originalUnicode->Ptr())), 0, size);
67 test(file.Read(ptr1) == KErrNone);
68 test(ptr1.Length()==size);
69 TPtr16 ptr2=originalUnicode->Des();
70 ptr2.SetLength(size/2);
71 test(originalUnicode->Size()==size);
72 TPtr8 ptr3=generatedUtf8->Des();
73 test(CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr3, *originalUnicode)==0);
74 TPtr16 ptr4=generatedUnicode->Des();
75 test(CnvUtfConverter::ConvertToUnicodeFromUtf8(ptr4, *generatedUtf8)==0);
76 test(*generatedUnicode==*originalUnicode);
77 delete originalUnicode;
79 delete generatedUnicode;
85 CT_REALUNI::CT_REALUNI()
87 SetTestStepName(KTestStep_T_REALUNI);
90 TVerdict CT_REALUNI::doTestStepL()
92 SetTestStepResult(EFail);
96 TRAPD(error1, TestREALUNI());
100 if(error1 == KErrNone )
102 SetTestStepResult(EPass);
105 return TestStepResult();