sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <utf.h>
|
sl@0
|
21 |
#include "t_rfc1642.h"
|
sl@0
|
22 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
23 |
#define test(cond) \
|
sl@0
|
24 |
TEST((cond)); \
|
sl@0
|
25 |
if (!(cond)) \
|
sl@0
|
26 |
{ \
|
sl@0
|
27 |
ERR_PRINTF1(_L("ERROR: Test Failed")); \
|
sl@0
|
28 |
User::Leave(1); \
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
32 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
@SYMTestCaseID SYSLIB-CHARCONV-CT-0564
|
sl@0
|
35 |
@SYMTestCaseDesc Tests for conversion from UTF-7 to Unicode character set
|
sl@0
|
36 |
@SYMTestPriority Medium
|
sl@0
|
37 |
@SYMTestActions Tests for CnvUtfConverter::ConvertToUnicodeFromUtf7() function
|
sl@0
|
38 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
39 |
@SYMREQ REQ0000
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
void CT_RFC1642::TestRFC1642()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
|
sl@0
|
44 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0564 Testing the examples given in RFC 1642 "));
|
sl@0
|
45 |
TBuf16<256> generatedUnicode;
|
sl@0
|
46 |
TInt state=CnvUtfConverter::KStateDefault;
|
sl@0
|
47 |
//
|
sl@0
|
48 |
INFO_PRINTF1(_L("Empty descriptor"));
|
sl@0
|
49 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8(""), state)==0);
|
sl@0
|
50 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
51 |
test(generatedUnicode==_L16(""));
|
sl@0
|
52 |
INFO_PRINTF1(_L("\"A<NOT IDENTICAL TO><ALPHA>.\""));
|
sl@0
|
53 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("A+ImIDkQ."), state)==0);
|
sl@0
|
54 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
55 |
test(generatedUnicode.Length()==4);
|
sl@0
|
56 |
test(generatedUnicode[0]==0x0041);
|
sl@0
|
57 |
test(generatedUnicode[1]==0x2262);
|
sl@0
|
58 |
test(generatedUnicode[2]==0x0391);
|
sl@0
|
59 |
test(generatedUnicode[3]==0x002e);
|
sl@0
|
60 |
INFO_PRINTF1(_L("\"Hi Mom <WHITE SMILING FACE>!\""));
|
sl@0
|
61 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("Hi Mom +Jjo-!"), state)==0);
|
sl@0
|
62 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
63 |
test(generatedUnicode.Length()==9);
|
sl@0
|
64 |
test(generatedUnicode[0]==0x0048);
|
sl@0
|
65 |
test(generatedUnicode[1]==0x0069);
|
sl@0
|
66 |
test(generatedUnicode[2]==0x0020);
|
sl@0
|
67 |
test(generatedUnicode[3]==0x004d);
|
sl@0
|
68 |
test(generatedUnicode[4]==0x006f);
|
sl@0
|
69 |
test(generatedUnicode[5]==0x006d);
|
sl@0
|
70 |
test(generatedUnicode[6]==0x0020);
|
sl@0
|
71 |
test(generatedUnicode[7]==0x263a);
|
sl@0
|
72 |
test(generatedUnicode[8]==0x0021);
|
sl@0
|
73 |
INFO_PRINTF1(_L("The japanese word \"nihongo\""));
|
sl@0
|
74 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+ZeVnLIqe-"), state)==0);
|
sl@0
|
75 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
76 |
test(generatedUnicode.Length()==3);
|
sl@0
|
77 |
test(generatedUnicode[0]==0x65e5);
|
sl@0
|
78 |
test(generatedUnicode[1]==0x672c);
|
sl@0
|
79 |
test(generatedUnicode[2]==0x8a9e);
|
sl@0
|
80 |
INFO_PRINTF1(_L("The special case of \"+-\""));
|
sl@0
|
81 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("+-"), state)==0);
|
sl@0
|
82 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
83 |
test(generatedUnicode==_L16("+"));
|
sl@0
|
84 |
INFO_PRINTF1(_L("The special case of \"+-\" in a context"));
|
sl@0
|
85 |
test(CnvUtfConverter::ConvertToUnicodeFromUtf7(generatedUnicode, _L8("2+-3 is 5"), state)==0);
|
sl@0
|
86 |
test(state==CnvUtfConverter::KStateDefault);
|
sl@0
|
87 |
test(generatedUnicode==_L16("2+3 is 5"));
|
sl@0
|
88 |
//
|
sl@0
|
89 |
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
CT_RFC1642::CT_RFC1642()
|
sl@0
|
93 |
{
|
sl@0
|
94 |
SetTestStepName(KTestStep_T_RFC1642);
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
TVerdict CT_RFC1642::doTestStepL()
|
sl@0
|
98 |
{
|
sl@0
|
99 |
SetTestStepResult(EFail);
|
sl@0
|
100 |
|
sl@0
|
101 |
__UHEAP_MARK;
|
sl@0
|
102 |
|
sl@0
|
103 |
TRAPD(error1, TestRFC1642());
|
sl@0
|
104 |
|
sl@0
|
105 |
__UHEAP_MARKEND;
|
sl@0
|
106 |
|
sl@0
|
107 |
if(error1 == KErrNone )
|
sl@0
|
108 |
{
|
sl@0
|
109 |
SetTestStepResult(EPass);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
return TestStepResult();
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|