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_realut8.h"
24 ///////////////////////////////////////////////////////////////////////////////////////
29 TBool __bb = (cond); \
33 ERR_PRINTF1(_L("ERROR: Test Failed")); \
40 ///////////////////////////////////////////////////////////////////////////////////////
41 ///////////////////////////////////////////////////////////////////////////////////////
43 @SYMTestCaseID SYSLIB-CHARCONV-CT-0567
44 @SYMTestCaseDesc Testing a real UTF8 file's round trip
45 @SYMTestPriority Medium
46 @SYMTestActions Tests for CnvUtfConverter::ConvertToUnicodeFromUtf8() function
47 @SYMTestExpectedResults Test must not fail
50 void CT_REALUT8::TestREALUT8()
52 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0567 Testing a \"real\" UTF8 file's round trip "));
55 test(fs.Connect()== KErrNone);
56 TFindFile findFile=fs;
57 test(findFile.FindByDir(_L("ETHIOPIC.UT8"), _L("\\system\\data\\"))==KErrNone);
58 test(inputFile.Open(fs, findFile.File(), EFileShareExclusive|EFileStream|EFileRead)==KErrNone);
60 test(inputFile.Size(size) == KErrNone);
61 HBufC8* originalUtf8=HBufC8::New(size);
62 HBufC16* generatedUnicode=HBufC16::New(size);
63 HBufC8* generatedUtf8=HBufC8::New(size);
65 test(originalUtf8!=NULL);
66 test(generatedUnicode!=NULL);
67 test(generatedUtf8!=NULL);
68 TPtr8 ptr1=originalUtf8->Des();
69 test(inputFile.Read(ptr1) == KErrNone);
70 test(outputFile.Replace(fs, _L("c:\\ETHIOPIC.UNI"), EFileShareExclusive|EFileStream|EFileWrite)==KErrNone);
71 TPtr16 ptr2=generatedUnicode->Des();
72 test(CnvUtfConverter::ConvertToUnicodeFromUtf8(ptr2, *originalUtf8)==0);
73 TPtr8 ptr3=generatedUtf8->Des();
74 test(CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr3, *generatedUnicode)==0);
75 test(*generatedUtf8==*originalUtf8);
76 test(outputFile.Write(TPtrC8(REINTERPRET_CAST(const TUint8*, generatedUnicode->Ptr()), generatedUnicode->Size()))==KErrNone);
79 delete generatedUnicode;
85 CT_REALUT8::CT_REALUT8()
87 SetTestStepName(KTestStep_T_REALUT8);
90 TVerdict CT_REALUT8::doTestStepL()
92 SetTestStepResult(EFail);
96 TRAPD(error1, TestREALUT8());
100 if(error1 == KErrNone )
102 SetTestStepResult(EPass);
105 return TestStepResult();