|
1 /* |
|
2 * Copyright (c) 1997-2005 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 the License "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 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 #include <e32test.h> |
|
28 #include <f32file.h> |
|
29 #include <charconv.h> |
|
30 |
|
31 /////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
33 RTest TheTest(_L("TBig5")); |
|
34 |
|
35 /////////////////////////////////////////////////////////////////////////////////////// |
|
36 /////////////////////////////////////////////////////////////////////////////////////// |
|
37 //Tests macroses and functions. |
|
38 //If (!aValue) then the test will be panicked, the test data files will be deleted. |
|
39 static void Check(TInt aValue, TInt aLine) |
|
40 { |
|
41 if(!aValue) |
|
42 { |
|
43 TheTest(EFalse, aLine); |
|
44 } |
|
45 } |
|
46 //If (aValue != aExpected) then the test will be panicked, the test data files will be deleted. |
|
47 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
48 { |
|
49 if(aValue != aExpected) |
|
50 { |
|
51 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
52 TheTest(EFalse, aLine); |
|
53 } |
|
54 } |
|
55 //Use these to test conditions. |
|
56 #define TEST(arg) ::Check((arg), __LINE__) |
|
57 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
58 |
|
59 /////////////////////////////////////////////////////////////////////////////////////// |
|
60 /////////////////////////////////////////////////////////////////////////////////////// |
|
61 /** |
|
62 @SYMTestCaseID SYSLIB-CHARCONV-CT-0515 |
|
63 @SYMTestCaseDesc Tests for defect number EDNSHAY-45VJAU |
|
64 @SYMTestPriority Medium |
|
65 @SYMTestActions Tests for CCnvCharacterSetConverter::ConvertToUnicode() function |
|
66 @SYMTestExpectedResults Test must not fail |
|
67 @SYMREQ REQ0000 |
|
68 */ |
|
69 LOCAL_C void DoE32MainL() |
|
70 { |
|
71 RFs fileServerSession; |
|
72 CleanupClosePushL(fileServerSession); |
|
73 User::LeaveIfError(fileServerSession.Connect()); |
|
74 CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC(); |
|
75 CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession); |
|
76 TheTest.Start(_L("Available:\n")); |
|
77 for (TInt i=arrayOfCharacterSetsAvailable->Count()-1; i>=0; --i) |
|
78 { |
|
79 const CCnvCharacterSetConverter::SCharacterSet& charactersSet=(*arrayOfCharacterSetsAvailable)[i]; |
|
80 characterSetConverter->PrepareToConvertToOrFromL(charactersSet.Identifier(), *arrayOfCharacterSetsAvailable, fileServerSession); |
|
81 TPtrC charactersSetName(charactersSet.Name()); |
|
82 if (charactersSet.NameIsFileName()) |
|
83 { |
|
84 charactersSetName.Set(TParsePtrC(charactersSetName).Name()); |
|
85 } |
|
86 TheTest.Printf(_L(" %S\n"), &charactersSetName); |
|
87 } |
|
88 TInt state=CCnvCharacterSetConverter::KStateDefault; |
|
89 TheTest.Next(_L("Testing fix for defect number EDNSHAY-45VJAU")); |
|
90 characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierBig5, *arrayOfCharacterSetsAvailable, fileServerSession); |
|
91 TBuf16<28> generatedUnicode; |
|
92 TEST(characterSetConverter->ConvertToUnicode(generatedUnicode, _L8("++ ZAC"), state)==0); |
|
93 TEST(state==CCnvCharacterSetConverter::KStateDefault); |
|
94 CleanupStack::PopAndDestroy(3); // arrayOfCharacterSetsAvailable and characterSetConverter and fileServerSession |
|
95 } |
|
96 |
|
97 GLDEF_C TInt E32Main() |
|
98 { |
|
99 __UHEAP_MARK; |
|
100 |
|
101 TheTest.Title(); |
|
102 |
|
103 CTrapCleanup* trapCleanup=CTrapCleanup::New(); |
|
104 TEST(trapCleanup != NULL); |
|
105 |
|
106 TRAPD(error, DoE32MainL()); |
|
107 TEST2(error, KErrNone); |
|
108 |
|
109 delete trapCleanup; |
|
110 |
|
111 TheTest.End(); |
|
112 TheTest.Close(); |
|
113 |
|
114 __UHEAP_MARKEND; |
|
115 return KErrNone; |
|
116 } |
|
117 |