charconvfw/Charconv/ongoing/test/source/main/TBIG5.CPP
changeset 32 8b9155204a54
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/charconvfw/Charconv/ongoing/test/source/main/TBIG5.CPP	Fri Jun 04 10:37:54 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 1997-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:      
+*
+*/
+
+
+
+
+
+
+
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32test.h>
+#include <f32file.h>
+#include <charconv.h>
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+RTest TheTest(_L("TBig5"));
+	
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+//Tests macroses and functions.
+//If (!aValue) then the test will be panicked, the test data files will be deleted.
+static void Check(TInt aValue, TInt aLine)
+	{
+	if(!aValue)
+		{
+		TheTest(EFalse, aLine);
+		}
+	}
+//If (aValue != aExpected) then the test will be panicked, the test data files will be deleted.
+static void Check(TInt aValue, TInt aExpected, TInt aLine)
+	{
+	if(aValue != aExpected)
+		{
+		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
+		TheTest(EFalse, aLine);
+		}
+	}
+//Use these to test conditions.
+#define TEST(arg) ::Check((arg), __LINE__)
+#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
+
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+/**
+@SYMTestCaseID          SYSLIB-CHARCONV-CT-0515
+@SYMTestCaseDesc        Tests for defect number EDNSHAY-45VJAU
+@SYMTestPriority        Medium
+@SYMTestActions         Tests for CCnvCharacterSetConverter::ConvertToUnicode() function
+@SYMTestExpectedResults Test must not fail
+@SYMREQ                 REQ0000
+*/
+LOCAL_C void DoE32MainL()
+	{
+	RFs fileServerSession;
+	CleanupClosePushL(fileServerSession);
+	User::LeaveIfError(fileServerSession.Connect());
+	CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();
+	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
+	TheTest.Start(_L("Available:\n"));
+	for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i)
+		{
+		const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i];
+		characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession);
+		TPtrC charactersSetName(charactersSet.Name());
+		if (charactersSet.NameIsFileName())
+			{
+			charactersSetName.Set(TParsePtrC(charactersSetName).Name());
+			}
+		TheTest.Printf(_L("    %S\n"), &charactersSetName);
+		}
+	TInt state=CCnvCharacterSetConverter::KStateDefault;
+	TheTest.Next(_L("Testing fix for defect number EDNSHAY-45VJAU"));
+	characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierBig5, *arrayOfCharacterSetsAvailable, fileServerSession);
+	TBuf16<28> generatedUnicode;
+	TEST(characterSetConverter->ConvertToUnicode(generatedUnicode, _L8("++   ZAC"), state)==0);
+	TEST(state==CCnvCharacterSetConverter::KStateDefault);
+	CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+
+	TheTest.Title();
+
+	CTrapCleanup* trapCleanup=CTrapCleanup::New();
+	TEST(trapCleanup != NULL);
+
+	TRAPD(error, DoE32MainL());
+	TEST2(error, KErrNone);
+
+	delete trapCleanup;
+
+	TheTest.End();
+	TheTest.Close();
+
+	__UHEAP_MARKEND;
+	return KErrNone;
+	}
+