sl@0
|
1 |
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\buffer\t_lex.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test TLex and TLexMark classes.
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// TLex, TLexMark.
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// - For Unicode, non Unicode and build independent variant of TLex class
|
sl@0
|
21 |
// - Test that string-parsing methods are present.
|
sl@0
|
22 |
// - Test the constructors with no parameter, by a string, with an empty TLex class,
|
sl@0
|
23 |
// non-empty TLex class is as expected.
|
sl@0
|
24 |
// - Test assignment operator of TLex, by initializing with TLex reference, string,
|
sl@0
|
25 |
// TBuf reference and check it is as expected.
|
sl@0
|
26 |
// - Check that Eos, Inc, Mark, Get, Peek, UnGet, SkipSpace, SkipSpaceAndMark,
|
sl@0
|
27 |
// SkipCharacters, TokenLength, MarkedToken methods are as expected.
|
sl@0
|
28 |
// - Initialize Lex string, assign different values, Parse to extract signed,
|
sl@0
|
29 |
// unsigned integer of different lengths, using specified radix and verify
|
sl@0
|
30 |
// that the return value is KErrNone when a valid string is parsed, KErrGeneral
|
sl@0
|
31 |
// when invalid string is parsed, KErrOverflow when converted value is greater
|
sl@0
|
32 |
// than the limit.
|
sl@0
|
33 |
// - Refresh the contents with the system's locale settings, separate whole number from
|
sl@0
|
34 |
// it's fractional part, change locale settings then parse a 64-bit floating point
|
sl@0
|
35 |
// number and check that results are as expected.
|
sl@0
|
36 |
// Platforms/Drives/Compatibility:
|
sl@0
|
37 |
// All
|
sl@0
|
38 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
39 |
// Failures and causes:
|
sl@0
|
40 |
// Base Port information:
|
sl@0
|
41 |
//
|
sl@0
|
42 |
//
|
sl@0
|
43 |
|
sl@0
|
44 |
#include <e32test.h>
|
sl@0
|
45 |
|
sl@0
|
46 |
LOCAL_D RTest test(_L("T_LEX"));
|
sl@0
|
47 |
|
sl@0
|
48 |
struct TLexMark8Dump
|
sl@0
|
49 |
{
|
sl@0
|
50 |
const TUint8* iPtr;
|
sl@0
|
51 |
};
|
sl@0
|
52 |
|
sl@0
|
53 |
struct TLexMark16Dump
|
sl@0
|
54 |
{
|
sl@0
|
55 |
const TUint16* iPtr;
|
sl@0
|
56 |
};
|
sl@0
|
57 |
|
sl@0
|
58 |
void TLexMark8::__DbgTest(void *pTLexMark8Dump) const
|
sl@0
|
59 |
{
|
sl@0
|
60 |
((TLexMark8Dump*)pTLexMark8Dump)->iPtr=iPtr;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
void TLexMark16::__DbgTest(void *pTLexMark16Dump) const
|
sl@0
|
64 |
{
|
sl@0
|
65 |
((TLexMark16Dump*)pTLexMark16Dump)->iPtr=iPtr;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
struct TLex8Dump
|
sl@0
|
69 |
{
|
sl@0
|
70 |
const TUint8* iNext;
|
sl@0
|
71 |
const TUint8* iBuf;
|
sl@0
|
72 |
const TUint8* iEnd;
|
sl@0
|
73 |
TLexMark8Dump iMark;
|
sl@0
|
74 |
};
|
sl@0
|
75 |
|
sl@0
|
76 |
struct TLex16Dump
|
sl@0
|
77 |
{
|
sl@0
|
78 |
const TUint16* iNext;
|
sl@0
|
79 |
const TUint16* iBuf;
|
sl@0
|
80 |
const TUint16* iEnd;
|
sl@0
|
81 |
TLexMark16Dump iMark;
|
sl@0
|
82 |
};
|
sl@0
|
83 |
|
sl@0
|
84 |
|
sl@0
|
85 |
void TLex8::__DbgTest(void* pTLex8Dump) const
|
sl@0
|
86 |
{
|
sl@0
|
87 |
((TLex8Dump*)pTLex8Dump)->iNext=iNext;
|
sl@0
|
88 |
((TLex8Dump*)pTLex8Dump)->iBuf=iBuf;
|
sl@0
|
89 |
((TLex8Dump*)pTLex8Dump)->iEnd=iEnd;
|
sl@0
|
90 |
iMark.__DbgTest(&((TLex8Dump*)pTLex8Dump)->iMark);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
void TLex16::__DbgTest(void* pTLex16Dump) const
|
sl@0
|
94 |
{
|
sl@0
|
95 |
((TLex16Dump*)pTLex16Dump)->iNext=iNext;
|
sl@0
|
96 |
((TLex16Dump*)pTLex16Dump)->iBuf=iBuf;
|
sl@0
|
97 |
((TLex16Dump*)pTLex16Dump)->iEnd=iEnd;
|
sl@0
|
98 |
iMark.__DbgTest(&((TLex16Dump*)pTLex16Dump)->iMark);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|
sl@0
|
101 |
|
sl@0
|
102 |
LOCAL_C void TestDes(const TUint16* start1, const TUint16* start2, const TUint16* end1, const TUint16* end2)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
TPtrC16 des1(start1, end1-start1);
|
sl@0
|
105 |
TPtrC16 des2(start2, end2-start2);
|
sl@0
|
106 |
test(des1==des2);
|
sl@0
|
107 |
}
|
sl@0
|
108 |
LOCAL_C void TestDes(const TUint8* start1, const TUint8* start2, const TUint8* end1, const TUint8* end2)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
TPtrC8 des1(start1, end1-start1);
|
sl@0
|
111 |
TPtrC8 des2(start2, end2-start2);
|
sl@0
|
112 |
test(des1==des2);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
LOCAL_C void TestDes(const TUint16* start, const TUint16* end, const TUint16* string)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
TPtrC16 des1(start, end-start);
|
sl@0
|
117 |
TPtrC16 des2(string);
|
sl@0
|
118 |
test(des1==des2);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
LOCAL_C void TestDes(const TUint8* start, const TUint8* end, const TUint8* string)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
TPtrC8 des1(start, end-start);
|
sl@0
|
123 |
TPtrC8 des2(string);
|
sl@0
|
124 |
test(des1==des2);
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
|
sl@0
|
128 |
void _LL(TText8 array[], TText8 string[])
|
sl@0
|
129 |
{
|
sl@0
|
130 |
|
sl@0
|
131 |
TInt index=0;
|
sl@0
|
132 |
for(;string[index]; index++)
|
sl@0
|
133 |
array[index]=string[index];
|
sl@0
|
134 |
array[index]='\0';
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
void _LL(TText16 array[], TText8 string[])
|
sl@0
|
138 |
{
|
sl@0
|
139 |
|
sl@0
|
140 |
TInt index=0;
|
sl@0
|
141 |
for(;string[index]; index++)
|
sl@0
|
142 |
array[index]=string[index];
|
sl@0
|
143 |
array[index]='\0';
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
147 |
class TestTLex
|
sl@0
|
148 |
{
|
sl@0
|
149 |
public:
|
sl@0
|
150 |
void Test1();
|
sl@0
|
151 |
void Test2();
|
sl@0
|
152 |
void Test3();
|
sl@0
|
153 |
void Test4();
|
sl@0
|
154 |
void Test5();
|
sl@0
|
155 |
protected:
|
sl@0
|
156 |
void TestList(TLexType* object, TUint param, ...);
|
sl@0
|
157 |
};
|
sl@0
|
158 |
|
sl@0
|
159 |
|
sl@0
|
160 |
//*********************************
|
sl@0
|
161 |
// Test that methods are in the DLL
|
sl@0
|
162 |
//*********************************
|
sl@0
|
163 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
164 |
GLDEF_C void TestTLex<TDesType, TLexType, TLexMarkType, TBufType, DumpType, MarkDumpType, S>::Test1()
|
sl@0
|
165 |
{
|
sl@0
|
166 |
test.Start(_L("Constructors"));
|
sl@0
|
167 |
S String[100];
|
sl@0
|
168 |
_LL(&String[0], (TText8*)"hello");
|
sl@0
|
169 |
TBufType aTBufObject;
|
sl@0
|
170 |
TLexType a;
|
sl@0
|
171 |
TLexType b(a);
|
sl@0
|
172 |
TLexType c(&String[0]);
|
sl@0
|
173 |
TLexType d(aTBufObject);
|
sl@0
|
174 |
d.Offset(); // Avoids 'unused' warning
|
sl@0
|
175 |
TLexMarkType mark;
|
sl@0
|
176 |
|
sl@0
|
177 |
test.Next(_L("Assignment operations"));
|
sl@0
|
178 |
a=b;
|
sl@0
|
179 |
a=&String[0];
|
sl@0
|
180 |
a=aTBufObject;
|
sl@0
|
181 |
|
sl@0
|
182 |
test.Next(_L("Assorted"));
|
sl@0
|
183 |
c.Eos();
|
sl@0
|
184 |
c.Mark(mark);
|
sl@0
|
185 |
c.Mark();
|
sl@0
|
186 |
c.Inc();
|
sl@0
|
187 |
c.Get();
|
sl@0
|
188 |
(S)c.Peek();
|
sl@0
|
189 |
c.UnGet();
|
sl@0
|
190 |
c.UnGetToMark(mark);
|
sl@0
|
191 |
c.UnGetToMark();
|
sl@0
|
192 |
c.SkipSpace();
|
sl@0
|
193 |
c.SkipSpaceAndMark(mark);
|
sl@0
|
194 |
c.SkipSpaceAndMark();
|
sl@0
|
195 |
c.SkipCharacters();
|
sl@0
|
196 |
c.TokenLength(mark);
|
sl@0
|
197 |
c.TokenLength();
|
sl@0
|
198 |
aTBufObject=c.MarkedToken(mark);
|
sl@0
|
199 |
aTBufObject=c.MarkedToken();
|
sl@0
|
200 |
aTBufObject=c.NextToken();
|
sl@0
|
201 |
aTBufObject=c.Remainder();
|
sl@0
|
202 |
aTBufObject=c.RemainderFromMark(mark);
|
sl@0
|
203 |
aTBufObject=c.RemainderFromMark();
|
sl@0
|
204 |
c.Offset();
|
sl@0
|
205 |
c.MarkedOffset(mark);
|
sl@0
|
206 |
c.MarkedOffset();
|
sl@0
|
207 |
|
sl@0
|
208 |
test.Next(_L("Val"));
|
sl@0
|
209 |
TInt TI=1;
|
sl@0
|
210 |
c.Val(TI);
|
sl@0
|
211 |
TInt8 TI8='a';
|
sl@0
|
212 |
c.Val(TI8);
|
sl@0
|
213 |
TInt16 TI16=1;
|
sl@0
|
214 |
c.Val(TI16);
|
sl@0
|
215 |
TInt32 TI32=1;
|
sl@0
|
216 |
c.Val(TI32);
|
sl@0
|
217 |
TInt64 TI64=1;
|
sl@0
|
218 |
c.Val(TI64);
|
sl@0
|
219 |
TUint TU=1;
|
sl@0
|
220 |
c.Val(TU);
|
sl@0
|
221 |
TReal32 TR32=1.0F;
|
sl@0
|
222 |
c.Val(TR32);
|
sl@0
|
223 |
TReal64 TR64=1.0;
|
sl@0
|
224 |
c.Val(TR64);
|
sl@0
|
225 |
TUint8 TU8='a';
|
sl@0
|
226 |
TUint32 TU32=1;
|
sl@0
|
227 |
TRadix TR=(TRadix)EDecimal;
|
sl@0
|
228 |
TUint16 TU16=1;
|
sl@0
|
229 |
|
sl@0
|
230 |
c.Val(TU8, TR);
|
sl@0
|
231 |
c.Val(TU16, TR);
|
sl@0
|
232 |
c.BoundedVal(TI32, TU);
|
sl@0
|
233 |
c.BoundedVal(TU32, TR, TU);
|
sl@0
|
234 |
c.BoundedVal(TI64, TR, TU);
|
sl@0
|
235 |
|
sl@0
|
236 |
test.Next(_L("Assign"));
|
sl@0
|
237 |
c.Assign(b);
|
sl@0
|
238 |
c.Assign(&String[0]);
|
sl@0
|
239 |
c.Assign(aTBufObject);
|
sl@0
|
240 |
|
sl@0
|
241 |
test.Next(_L("Test Dumps"));
|
sl@0
|
242 |
MarkDumpType mDump;
|
sl@0
|
243 |
mark.__DbgTest(&mDump);
|
sl@0
|
244 |
|
sl@0
|
245 |
DumpType dump;
|
sl@0
|
246 |
c.__DbgTest(&dump);
|
sl@0
|
247 |
test.End();
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
|
sl@0
|
251 |
///////////////////////////////////////
|
sl@0
|
252 |
// Test calling Convert() with a list
|
sl@0
|
253 |
///////////////////////////////////////
|
sl@0
|
254 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
255 |
GLDEF_C void TestTLex<TDesType, TLexType, TLexMarkType, TBufType, DumpType, MarkDumpType, S>::TestList(TLexType *object, TUint param, ...)
|
sl@0
|
256 |
{
|
sl@0
|
257 |
VA_LIST l;
|
sl@0
|
258 |
TBufType b;
|
sl@0
|
259 |
|
sl@0
|
260 |
VA_START(l, param);
|
sl@0
|
261 |
object->Convert(b, l);
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
|
sl@0
|
265 |
/////////////////////////
|
sl@0
|
266 |
// Test the constructors
|
sl@0
|
267 |
////////////////////////
|
sl@0
|
268 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
269 |
GLDEF_C void TestTLex<TDesType, TLexType, TLexMarkType, TBufType, DumpType, MarkDumpType, S>::Test2()
|
sl@0
|
270 |
{
|
sl@0
|
271 |
// Test constructors NOTE: there's no getters for iMark or iBuf
|
sl@0
|
272 |
DumpType dump, dump2;
|
sl@0
|
273 |
S String[40];
|
sl@0
|
274 |
|
sl@0
|
275 |
test.Start(_L("Constructors:")); // TLexx::TLexx()
|
sl@0
|
276 |
test.Next(_L("By default"));
|
sl@0
|
277 |
TLexType a;
|
sl@0
|
278 |
a.__DbgTest(&dump);
|
sl@0
|
279 |
test(dump.iBuf==NULL);
|
sl@0
|
280 |
|
sl@0
|
281 |
test.Next(_L("By string")); // TLexx::TLexx(const TUintx*)
|
sl@0
|
282 |
_LL(&String[0], (TText8*)"AB");
|
sl@0
|
283 |
TLexType b(&String[0]);
|
sl@0
|
284 |
b.__DbgTest(&dump);
|
sl@0
|
285 |
TestDes(dump.iNext, dump.iEnd, &String[0]);
|
sl@0
|
286 |
TestDes(dump.iBuf, dump.iEnd, &String[0]);
|
sl@0
|
287 |
TestDes(dump.iMark.iPtr, dump.iEnd, &String[0]);
|
sl@0
|
288 |
|
sl@0
|
289 |
test.Next(_L("By TLex reference")); // TLexx::TLexx(const TLexx&)
|
sl@0
|
290 |
// Test with an empty class
|
sl@0
|
291 |
TLexType c, d(c);
|
sl@0
|
292 |
c.__DbgTest(&dump);
|
sl@0
|
293 |
d.__DbgTest(&dump2);
|
sl@0
|
294 |
TestDes(dump.iNext, dump2.iNext, dump.iEnd, dump2.iEnd);
|
sl@0
|
295 |
test(dump.iBuf==NULL);
|
sl@0
|
296 |
test(dump.iBuf==dump2.iBuf);
|
sl@0
|
297 |
TestDes(dump.iMark.iPtr, dump2.iMark.iPtr, dump.iEnd, dump2.iEnd);
|
sl@0
|
298 |
|
sl@0
|
299 |
//Test with a non empty class
|
sl@0
|
300 |
_LL(&String[0], (TText8*)"XYZ");
|
sl@0
|
301 |
TLexType e(&String[0]), f(e);
|
sl@0
|
302 |
e.__DbgTest(&dump);
|
sl@0
|
303 |
f.__DbgTest(&dump2);
|
sl@0
|
304 |
TestDes(dump.iNext, dump.iEnd, &String[0]);
|
sl@0
|
305 |
TestDes(dump.iNext, dump2.iNext, dump.iEnd, dump2.iEnd);
|
sl@0
|
306 |
TestDes(dump.iBuf, dump2.iBuf, dump.iEnd, dump2.iEnd);
|
sl@0
|
307 |
TestDes(dump.iMark.iPtr, dump2.iMark.iPtr, dump.iEnd, dump2.iEnd);
|
sl@0
|
308 |
|
sl@0
|
309 |
test.Next(_L("By TBuf reference")); //TLexx::TLexx(const TBufBasex&)
|
sl@0
|
310 |
_LL(&String[0], (TText8*)"Hello");
|
sl@0
|
311 |
TBufType aBuf(&String[0]);
|
sl@0
|
312 |
TLexType g(aBuf);
|
sl@0
|
313 |
g.__DbgTest(&dump);
|
sl@0
|
314 |
TestDes(dump.iNext, dump.iEnd, &String[0]);
|
sl@0
|
315 |
TestDes(dump.iBuf, dump.iEnd, &String[0]);
|
sl@0
|
316 |
TestDes(dump.iMark.iPtr, dump.iEnd, &String[0]);
|
sl@0
|
317 |
|
sl@0
|
318 |
test.End();
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
|
sl@0
|
322 |
//*********************************
|
sl@0
|
323 |
// Test the = methods
|
sl@0
|
324 |
//*********************************
|
sl@0
|
325 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
326 |
GLDEF_C void TestTLex<TDesType, TLexType, TLexMarkType, TBufType, DumpType, MarkDumpType, S>::Test3()
|
sl@0
|
327 |
{
|
sl@0
|
328 |
DumpType dump, dump2;
|
sl@0
|
329 |
S String[40];
|
sl@0
|
330 |
|
sl@0
|
331 |
test.Start(_L("= operators"));
|
sl@0
|
332 |
test.Next(_L("by TLex reference")); //TLexx::operator=(const TLexx&)
|
sl@0
|
333 |
_LL(&String[0], (TText8*)"MNO");
|
sl@0
|
334 |
TLexType a(&String[0]), b;
|
sl@0
|
335 |
b=a;
|
sl@0
|
336 |
a.__DbgTest(&dump);
|
sl@0
|
337 |
b.__DbgTest(&dump2);
|
sl@0
|
338 |
TestDes(dump.iNext, dump2.iNext, dump.iEnd, dump2.iEnd);
|
sl@0
|
339 |
TestDes(dump.iMark.iPtr, dump2.iMark.iPtr, dump.iEnd, dump2.iEnd);
|
sl@0
|
340 |
TestDes(dump.iBuf, dump2.iBuf, dump.iEnd, dump2.iEnd);
|
sl@0
|
341 |
|
sl@0
|
342 |
test.Next(_L("by string")); //TLexx::operator=(const TUintx*)
|
sl@0
|
343 |
TLexType c;
|
sl@0
|
344 |
_LL(&String[0], (TText8*)" abc");
|
sl@0
|
345 |
c=&String[0];
|
sl@0
|
346 |
c.__DbgTest(&dump);
|
sl@0
|
347 |
TestDes(dump.iNext, dump.iEnd, &String[0]);
|
sl@0
|
348 |
TestDes(dump.iBuf, dump.iEnd, &String[0]);
|
sl@0
|
349 |
TestDes(dump.iMark.iPtr, dump.iEnd, &String[0]);
|
sl@0
|
350 |
|
sl@0
|
351 |
test.Next(_L("by TBuf reference")); //TLexx::operator=(const TBufx&);
|
sl@0
|
352 |
_LL(&String[0], (TText8*)"PQ R ");
|
sl@0
|
353 |
TLexType d;
|
sl@0
|
354 |
TBufType e(&String[0]);
|
sl@0
|
355 |
d=e;
|
sl@0
|
356 |
d.__DbgTest(&dump);
|
sl@0
|
357 |
TestDes(dump.iNext, dump.iEnd, &String[0]);
|
sl@0
|
358 |
TestDes(dump.iBuf, dump.iEnd, &String[0]);
|
sl@0
|
359 |
TestDes(dump.iMark.iPtr, dump.iEnd, &String[0]);
|
sl@0
|
360 |
test.End();
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
|
sl@0
|
364 |
//*********************************
|
sl@0
|
365 |
// Test supporting methods
|
sl@0
|
366 |
//*********************************
|
sl@0
|
367 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
368 |
GLDEF_C void TestTLex<TDesType, TLexType, TLexMarkType, TBufType, DumpType, MarkDumpType, S>::Test4()
|
sl@0
|
369 |
{
|
sl@0
|
370 |
S String[40];
|
sl@0
|
371 |
DumpType dump1,dump2;
|
sl@0
|
372 |
MarkDumpType mDump;
|
sl@0
|
373 |
|
sl@0
|
374 |
test.Start(_L("Supporting methods"));
|
sl@0
|
375 |
test.Next(_L("Eos()"));
|
sl@0
|
376 |
_LL(&String[0], (TText8*)"GGG");
|
sl@0
|
377 |
TLexType a, b(&String[0]);
|
sl@0
|
378 |
test(a.Eos()==TRUE);
|
sl@0
|
379 |
test(b.Eos()==FALSE);
|
sl@0
|
380 |
|
sl@0
|
381 |
test.Next(_L("Inc()")); // Inc() increments iNext
|
sl@0
|
382 |
_LL(&String[0], (TText8*)"mno");
|
sl@0
|
383 |
TLexType c(&String[0]);
|
sl@0
|
384 |
c.__DbgTest(&dump1);
|
sl@0
|
385 |
|
sl@0
|
386 |
TestDes(dump1.iNext, dump1.iEnd, &String[0]);
|
sl@0
|
387 |
c.Inc();
|
sl@0
|
388 |
test((S)c.Peek()==String[1]);
|
sl@0
|
389 |
c.Inc();
|
sl@0
|
390 |
test((S)c.Peek()==String[2]);
|
sl@0
|
391 |
|
sl@0
|
392 |
test.Next(_L("Mark()")); // Mark() sets iMark=iNext
|
sl@0
|
393 |
_LL(&String[0], (TText8*)"pqr");
|
sl@0
|
394 |
TLexType d(&String[0]);
|
sl@0
|
395 |
d.Inc();
|
sl@0
|
396 |
d.__DbgTest(&dump1);
|
sl@0
|
397 |
d.Mark();
|
sl@0
|
398 |
d.__DbgTest(&dump2);
|
sl@0
|
399 |
TestDes(dump2.iMark.iPtr, dump1.iNext, dump2.iEnd, dump1.iEnd);
|
sl@0
|
400 |
|
sl@0
|
401 |
test.Next(_L("Mark(mark)")); // Mark(aMark) sets aMark=iNext
|
sl@0
|
402 |
_LL(&String[0], (TText8*)"pqr");
|
sl@0
|
403 |
TLexType d1(&String[0]);
|
sl@0
|
404 |
TLexMarkType dm;
|
sl@0
|
405 |
d1.Inc();
|
sl@0
|
406 |
d1.__DbgTest(&dump1);
|
sl@0
|
407 |
d1.Mark(dm);
|
sl@0
|
408 |
dm.__DbgTest(&mDump);
|
sl@0
|
409 |
TestDes(mDump.iPtr, dump1.iNext, dump1.iEnd, dump1.iEnd);
|
sl@0
|
410 |
|
sl@0
|
411 |
|
sl@0
|
412 |
test.Next(_L("Get()")); // Get() is {TChar c(*iNext);Inc(); return(c);}
|
sl@0
|
413 |
_LL(&String[0], (TText8*)"s");
|
sl@0
|
414 |
TLexType e(&String[0]);
|
sl@0
|
415 |
TChar temp=e.Get();
|
sl@0
|
416 |
test(temp=='s');
|
sl@0
|
417 |
e.Inc();
|
sl@0
|
418 |
temp=e.Get();
|
sl@0
|
419 |
test(temp==0);
|
sl@0
|
420 |
|
sl@0
|
421 |
|
sl@0
|
422 |
test.Next(_L("Peek()")); // Peek() returns *iNext
|
sl@0
|
423 |
TLexType f;
|
sl@0
|
424 |
test(f.Peek()==0);
|
sl@0
|
425 |
_LL(&String[0], (TText8*)"ab");
|
sl@0
|
426 |
TLexType g(&String[0]);
|
sl@0
|
427 |
test((S)g.Peek()==String[0]);
|
sl@0
|
428 |
|
sl@0
|
429 |
test.Next(_L("UnGet()")); // UnGet() is effectively if(iNext!=iBuf) iNext--;
|
sl@0
|
430 |
_LL(&String[0], (TText8*)"abc");
|
sl@0
|
431 |
TLexType h(&String[0]);
|
sl@0
|
432 |
h.Inc();
|
sl@0
|
433 |
test((S)h.Peek()==String[1]);
|
sl@0
|
434 |
h.UnGet();
|
sl@0
|
435 |
test((S)h.Peek()==String[0]);
|
sl@0
|
436 |
|
sl@0
|
437 |
test.Next(_L("SkipSpace()")); // SkipSpace() is while(Peek.IsSpace()) iNext++;
|
sl@0
|
438 |
_LL(&String[0], (TText8*)" j kl");
|
sl@0
|
439 |
TLexType i(&String[0]);
|
sl@0
|
440 |
i.SkipSpace();
|
sl@0
|
441 |
test((S)i.Peek()==String[2]);
|
sl@0
|
442 |
i.Inc();
|
sl@0
|
443 |
i.SkipSpace();
|
sl@0
|
444 |
test((S)i.Peek()==String[5]);
|
sl@0
|
445 |
|
sl@0
|
446 |
test.Next(_L("SkipSpaceAndMark()")); // while(Peek.IsSpace()) iNext++; iMark=iNext;
|
sl@0
|
447 |
_LL(&String[0], (TText8*)" aaa");
|
sl@0
|
448 |
TLexType j(&String[0]);
|
sl@0
|
449 |
j.SkipSpaceAndMark();
|
sl@0
|
450 |
j.__DbgTest(&dump1);
|
sl@0
|
451 |
_LL(&String[0], (TText8*)"aaa");
|
sl@0
|
452 |
TestDes(dump1.iNext, dump1.iEnd, &String[0]);
|
sl@0
|
453 |
TestDes(dump1.iMark.iPtr, dump1.iEnd, &String[0]);
|
sl@0
|
454 |
|
sl@0
|
455 |
test.Next(_L("SkipSpaceAndMark(aMark)")); // while(Peek.IsSpace()) iNext++; iMark=iNext;
|
sl@0
|
456 |
_LL(&String[0], (TText8*)" aaa");
|
sl@0
|
457 |
TLexType j1(&String[0]);
|
sl@0
|
458 |
TLexMarkType jm;
|
sl@0
|
459 |
j1.SkipSpaceAndMark(jm);
|
sl@0
|
460 |
j1.__DbgTest(&dump1);
|
sl@0
|
461 |
jm.__DbgTest(&mDump);
|
sl@0
|
462 |
_LL(&String[0], (TText8*)"aaa");
|
sl@0
|
463 |
TestDes(dump1.iNext, dump1.iEnd, &String[0]);
|
sl@0
|
464 |
TestDes(mDump.iPtr, dump1.iEnd, &String[0]);
|
sl@0
|
465 |
|
sl@0
|
466 |
test.Next(_L("SkipCharacters()")); // Skips non whitespace characters
|
sl@0
|
467 |
_LL(&String[0], (TText8*)"abc ");
|
sl@0
|
468 |
TLexType k(&String[0]);
|
sl@0
|
469 |
k.SkipCharacters();
|
sl@0
|
470 |
test((S)k.Peek()==String[3]);
|
sl@0
|
471 |
|
sl@0
|
472 |
test.Next(_L("TokenLength()")); // returns iNext-iMark
|
sl@0
|
473 |
_LL(&String[0], (TText8*)"GGG");
|
sl@0
|
474 |
TLexType l(&String[0]);
|
sl@0
|
475 |
test(l.TokenLength()==0);
|
sl@0
|
476 |
l.Inc();
|
sl@0
|
477 |
test(l.TokenLength()==1);
|
sl@0
|
478 |
|
sl@0
|
479 |
test.Next(_L("MarkedToken()")); // Extract a marked token
|
sl@0
|
480 |
_LL(&String[0], (TText8*)"ABCD");
|
sl@0
|
481 |
TLexType m(&String[0]);
|
sl@0
|
482 |
TBufType Buf;
|
sl@0
|
483 |
TLexMarkType mm;
|
sl@0
|
484 |
m.Inc();
|
sl@0
|
485 |
m.Mark();
|
sl@0
|
486 |
m.Inc();
|
sl@0
|
487 |
m.Mark(mm);
|
sl@0
|
488 |
m.Inc();
|
sl@0
|
489 |
Buf=m.MarkedToken();
|
sl@0
|
490 |
S String2[4];
|
sl@0
|
491 |
_LL(&String2[0], (TText8*)"BC");
|
sl@0
|
492 |
test(TDesType(&String2[0])==Buf);
|
sl@0
|
493 |
_LL(&String2[0], (TText8*)"C");
|
sl@0
|
494 |
Buf=m.MarkedToken(mm);
|
sl@0
|
495 |
test(TDesType(&String2[0])==Buf);
|
sl@0
|
496 |
|
sl@0
|
497 |
test.End();
|
sl@0
|
498 |
}
|
sl@0
|
499 |
|
sl@0
|
500 |
|
sl@0
|
501 |
//*********************************
|
sl@0
|
502 |
// Test Val()
|
sl@0
|
503 |
//*********************************
|
sl@0
|
504 |
template<class TDesType, class TLexType, class TLexMarkType, class TBufType, class DumpType, class MarkDumpType, class S>
|
sl@0
|
505 |
GLDEF_C void TestTLex<TDesType, TLexType, TLexMarkType, TBufType, DumpType, MarkDumpType, S>::Test5()
|
sl@0
|
506 |
{
|
sl@0
|
507 |
S String[66];
|
sl@0
|
508 |
TInt ret;
|
sl@0
|
509 |
TLexType Lex;
|
sl@0
|
510 |
test.Start(_L("Val()"));
|
sl@0
|
511 |
|
sl@0
|
512 |
//////////////////
|
sl@0
|
513 |
// Test Val(TInt8)
|
sl@0
|
514 |
/////////////////
|
sl@0
|
515 |
test.Next(_L("Val(TInt8)"));
|
sl@0
|
516 |
TInt8 T8;
|
sl@0
|
517 |
_LL(&String[0], (TText8*)"");
|
sl@0
|
518 |
Lex=&String[0];
|
sl@0
|
519 |
test((ret=Lex.Val(T8))==KErrGeneral);
|
sl@0
|
520 |
|
sl@0
|
521 |
_LL(&String[0], (TText8*)"abc");
|
sl@0
|
522 |
Lex=&String[0];
|
sl@0
|
523 |
test((ret=Lex.Val(T8))==KErrGeneral);
|
sl@0
|
524 |
|
sl@0
|
525 |
_LL(&String[0], (TText8*)"-abc-");
|
sl@0
|
526 |
Lex=&String[0];
|
sl@0
|
527 |
test((ret=Lex.Val(T8))==KErrGeneral);
|
sl@0
|
528 |
|
sl@0
|
529 |
_LL(&String[0], (TText8*)"+abc+");
|
sl@0
|
530 |
Lex=&String[0];
|
sl@0
|
531 |
test((ret=Lex.Val(T8))==KErrGeneral);
|
sl@0
|
532 |
|
sl@0
|
533 |
_LL(&String[0], (TText8*)"0000000123abc");
|
sl@0
|
534 |
Lex=&String[0];
|
sl@0
|
535 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
536 |
test(T8==123);
|
sl@0
|
537 |
|
sl@0
|
538 |
_LL(&String[0], (TText8*)"000");
|
sl@0
|
539 |
Lex=&String[0];
|
sl@0
|
540 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
541 |
test(T8==0);
|
sl@0
|
542 |
|
sl@0
|
543 |
_LL(&String[0], (TText8*)"+0");
|
sl@0
|
544 |
Lex=&String[0];
|
sl@0
|
545 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
546 |
test(T8==0);
|
sl@0
|
547 |
|
sl@0
|
548 |
_LL(&String[0], (TText8*)"-0");
|
sl@0
|
549 |
Lex=&String[0];
|
sl@0
|
550 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
551 |
test(T8==0);
|
sl@0
|
552 |
|
sl@0
|
553 |
_LL(&String[0], (TText8*)"+1 ");
|
sl@0
|
554 |
Lex=&String[0];
|
sl@0
|
555 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
556 |
test(T8==1);
|
sl@0
|
557 |
|
sl@0
|
558 |
_LL(&String[0], (TText8*)"-1 ");
|
sl@0
|
559 |
Lex=&String[0];
|
sl@0
|
560 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
561 |
test(T8==-1);
|
sl@0
|
562 |
|
sl@0
|
563 |
_LL(&String[0], (TText8*)"127");
|
sl@0
|
564 |
Lex=&String[0];
|
sl@0
|
565 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
566 |
test(T8==127);
|
sl@0
|
567 |
|
sl@0
|
568 |
_LL(&String[0], (TText8*)"128");
|
sl@0
|
569 |
Lex=&String[0];
|
sl@0
|
570 |
test((ret=Lex.Val(T8))==KErrOverflow);
|
sl@0
|
571 |
|
sl@0
|
572 |
_LL(&String[0], (TText8*)"-128");
|
sl@0
|
573 |
Lex=&String[0];
|
sl@0
|
574 |
test((ret=Lex.Val(T8))==KErrNone);
|
sl@0
|
575 |
test(T8==-128);
|
sl@0
|
576 |
|
sl@0
|
577 |
_LL(&String[0], (TText8*)"-129");
|
sl@0
|
578 |
Lex=&String[0];
|
sl@0
|
579 |
test((ret=Lex.Val(T8))==KErrOverflow);
|
sl@0
|
580 |
|
sl@0
|
581 |
|
sl@0
|
582 |
///////////////////
|
sl@0
|
583 |
// Test Val(TInt16)
|
sl@0
|
584 |
///////////////////
|
sl@0
|
585 |
test.Next(_L("Val(TInt16)"));
|
sl@0
|
586 |
TInt16 T16;
|
sl@0
|
587 |
_LL(&String[0], (TText8*)"");
|
sl@0
|
588 |
Lex=&String[0];
|
sl@0
|
589 |
test((ret=Lex.Val(T16))==KErrGeneral);
|
sl@0
|
590 |
|
sl@0
|
591 |
_LL(&String[0], (TText8*)"32767");
|
sl@0
|
592 |
Lex=&String[0];
|
sl@0
|
593 |
test((ret=Lex.Val(T16))==KErrNone);
|
sl@0
|
594 |
test(T16==32767);
|
sl@0
|
595 |
|
sl@0
|
596 |
_LL(&String[0], (TText8*)"32768");
|
sl@0
|
597 |
Lex=&String[0];
|
sl@0
|
598 |
test((ret=Lex.Val(T16))==KErrOverflow);
|
sl@0
|
599 |
|
sl@0
|
600 |
_LL(&String[0], (TText8*)"-32768");
|
sl@0
|
601 |
Lex=&String[0];
|
sl@0
|
602 |
test((ret=Lex.Val(T16))==KErrNone);
|
sl@0
|
603 |
test(T16==-32768);
|
sl@0
|
604 |
|
sl@0
|
605 |
_LL(&String[0], (TText8*)"-32769");
|
sl@0
|
606 |
Lex=&String[0];
|
sl@0
|
607 |
test((ret=Lex.Val(T16))==KErrOverflow);
|
sl@0
|
608 |
|
sl@0
|
609 |
|
sl@0
|
610 |
///////////////////
|
sl@0
|
611 |
// Test Val(TInt32)
|
sl@0
|
612 |
///////////////////
|
sl@0
|
613 |
test.Next(_L("Val(TInt32)"));
|
sl@0
|
614 |
TInt32 T32;
|
sl@0
|
615 |
_LL(&String[0], (TText8*)"");
|
sl@0
|
616 |
Lex=&String[0];
|
sl@0
|
617 |
test((ret=Lex.Val(T32))==KErrGeneral);
|
sl@0
|
618 |
|
sl@0
|
619 |
_LL(&String[0], (TText8*)"2147483647");
|
sl@0
|
620 |
Lex=&String[0];
|
sl@0
|
621 |
test((ret=Lex.Val(T32))==KErrNone);
|
sl@0
|
622 |
test(T32==2147483647L);
|
sl@0
|
623 |
|
sl@0
|
624 |
_LL(&String[0], (TText8*)"2147483648");
|
sl@0
|
625 |
Lex=&String[0];
|
sl@0
|
626 |
test((ret=Lex.Val(T32))==KErrOverflow);
|
sl@0
|
627 |
|
sl@0
|
628 |
_LL(&String[0], (TText8*)"-2147483648");
|
sl@0
|
629 |
Lex=&String[0];
|
sl@0
|
630 |
test((ret=Lex.Val(T32))==KErrNone);
|
sl@0
|
631 |
test(T32==-2147483647-1); // the -1 prevents a (bug?) warning
|
sl@0
|
632 |
|
sl@0
|
633 |
_LL(&String[0], (TText8*)"-2147483649");
|
sl@0
|
634 |
Lex=&String[0];
|
sl@0
|
635 |
test((ret=Lex.Val(T32))==KErrOverflow);
|
sl@0
|
636 |
|
sl@0
|
637 |
|
sl@0
|
638 |
/////////////////
|
sl@0
|
639 |
// Test Val(TInt)
|
sl@0
|
640 |
/////////////////
|
sl@0
|
641 |
test.Next(_L("Val(TInt)"));
|
sl@0
|
642 |
TInt T;
|
sl@0
|
643 |
_LL(&String[0], (TText8*)"");
|
sl@0
|
644 |
Lex=&String[0];
|
sl@0
|
645 |
test((ret=Lex.Val(T))==KErrGeneral);
|
sl@0
|
646 |
|
sl@0
|
647 |
_LL(&String[0], (TText8*)"2147483647");
|
sl@0
|
648 |
Lex=&String[0];
|
sl@0
|
649 |
test((ret=Lex.Val(T))==KErrNone);
|
sl@0
|
650 |
test(T==2147483647L);
|
sl@0
|
651 |
|
sl@0
|
652 |
_LL(&String[0], (TText8*)"2147483648");
|
sl@0
|
653 |
Lex=&String[0];
|
sl@0
|
654 |
test((ret=Lex.Val(T))==KErrOverflow);
|
sl@0
|
655 |
|
sl@0
|
656 |
_LL(&String[0], (TText8*)"-2147483648");
|
sl@0
|
657 |
Lex=&String[0];
|
sl@0
|
658 |
test((ret=Lex.Val(T))==KErrNone);
|
sl@0
|
659 |
test(T==-2147483647-1); // the -1 prevents a (bug?) warning
|
sl@0
|
660 |
|
sl@0
|
661 |
_LL(&String[0], (TText8*)"-2147483649");
|
sl@0
|
662 |
Lex=&String[0];
|
sl@0
|
663 |
test((ret=Lex.Val(T))==KErrOverflow);
|
sl@0
|
664 |
|
sl@0
|
665 |
/////////////////
|
sl@0
|
666 |
// Test Val(TInt64)
|
sl@0
|
667 |
/////////////////
|
sl@0
|
668 |
test.Next(_L("Val(TInt64)"));
|
sl@0
|
669 |
TInt64 T64;
|
sl@0
|
670 |
_LL(&String[0], (TText8*)"");
|
sl@0
|
671 |
Lex=&String[0];
|
sl@0
|
672 |
test((ret=Lex.Val(T64))==KErrGeneral);
|
sl@0
|
673 |
|
sl@0
|
674 |
_LL(&String[0], (TText8*)"2147483647");
|
sl@0
|
675 |
Lex=&String[0];
|
sl@0
|
676 |
test((ret=Lex.Val(T64))==KErrNone);
|
sl@0
|
677 |
test(T64==TInt(2147483647L));
|
sl@0
|
678 |
|
sl@0
|
679 |
_LL(&String[0], (TText8*)"2147483648");
|
sl@0
|
680 |
Lex=&String[0];
|
sl@0
|
681 |
test((ret=Lex.Val(T64))==KErrNone);
|
sl@0
|
682 |
test(T64==MAKE_TINT64(0,0x80000000u));
|
sl@0
|
683 |
|
sl@0
|
684 |
_LL(&String[0], (TText8*)"-2147483648");
|
sl@0
|
685 |
Lex=&String[0];
|
sl@0
|
686 |
test((ret=Lex.Val(T64))==KErrNone);
|
sl@0
|
687 |
test(T64==-2147483647-1); // the -1 prevents a (bug?) warning
|
sl@0
|
688 |
|
sl@0
|
689 |
_LL(&String[0], (TText8*)"-2147483649");
|
sl@0
|
690 |
Lex=&String[0];
|
sl@0
|
691 |
test((ret=Lex.Val(T64))==KErrNone);
|
sl@0
|
692 |
test(T64==MAKE_TINT64(0xffffffffu,0x7fffffffu));
|
sl@0
|
693 |
|
sl@0
|
694 |
_LL(&String[0], (TText8*)"9223372036854775807");
|
sl@0
|
695 |
Lex=&String[0];
|
sl@0
|
696 |
ret=Lex.Val(T64);
|
sl@0
|
697 |
test.Printf(_L("ret=%d\n"),ret);
|
sl@0
|
698 |
test(ret==KErrNone);
|
sl@0
|
699 |
test.Printf(_L("%lx\n"),T64);
|
sl@0
|
700 |
test(T64==MAKE_TINT64(0x7fffffffu,0xffffffffu));
|
sl@0
|
701 |
|
sl@0
|
702 |
_LL(&String[0], (TText8*)"9223372036854775808");
|
sl@0
|
703 |
Lex=&String[0];
|
sl@0
|
704 |
test((ret=Lex.Val(T64))==KErrOverflow);
|
sl@0
|
705 |
|
sl@0
|
706 |
_LL(&String[0], (TText8*)"-9223372036854775808");
|
sl@0
|
707 |
Lex=&String[0];
|
sl@0
|
708 |
test((ret=Lex.Val(T64))==KErrNone);
|
sl@0
|
709 |
test(T64==MAKE_TINT64(0x80000000u,0x0));
|
sl@0
|
710 |
|
sl@0
|
711 |
_LL(&String[0], (TText8*)"-9223372036854775809");
|
sl@0
|
712 |
Lex=&String[0];
|
sl@0
|
713 |
test((ret=Lex.Val(T64))==KErrOverflow);
|
sl@0
|
714 |
|
sl@0
|
715 |
////////////////////
|
sl@0
|
716 |
// Test Val(TReal32)
|
sl@0
|
717 |
/////////////////////
|
sl@0
|
718 |
// test.Next(_L("Val(TReal32)"));
|
sl@0
|
719 |
// TReal32 TR32;
|
sl@0
|
720 |
// test((ret=Lex.Val(TR32))==KErrNotSupported);
|
sl@0
|
721 |
|
sl@0
|
722 |
|
sl@0
|
723 |
////////////////////
|
sl@0
|
724 |
// Test Val(TReal64)
|
sl@0
|
725 |
///////////////////
|
sl@0
|
726 |
// test.Next(_L("Val(TReal64)"));
|
sl@0
|
727 |
// TReal64 TR64;
|
sl@0
|
728 |
// test((ret=Lex.Val(TR64))==KErrNotSupported);
|
sl@0
|
729 |
|
sl@0
|
730 |
|
sl@0
|
731 |
///////////////////////////
|
sl@0
|
732 |
// Test Val(TUint8, TRadix)
|
sl@0
|
733 |
///////////////////////////
|
sl@0
|
734 |
test.Next(_L("Val(TUint8, TRadix)"));
|
sl@0
|
735 |
TUint8 TU8;
|
sl@0
|
736 |
|
sl@0
|
737 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
738 |
Lex=&String[0];
|
sl@0
|
739 |
test((ret=Lex.Val(TU8, (TRadix)EBinary))==KErrNone);
|
sl@0
|
740 |
test(TU8==0);
|
sl@0
|
741 |
|
sl@0
|
742 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
743 |
Lex=&String[0];
|
sl@0
|
744 |
test((ret=Lex.Val(TU8, (TRadix)EBinary))==KErrNone);
|
sl@0
|
745 |
test(TU8==1);
|
sl@0
|
746 |
|
sl@0
|
747 |
_LL(&String[0], (TText8*)"11111111");
|
sl@0
|
748 |
Lex=&String[0];
|
sl@0
|
749 |
test((ret=Lex.Val(TU8, (TRadix)EBinary))==KErrNone);
|
sl@0
|
750 |
test(TU8==255);
|
sl@0
|
751 |
|
sl@0
|
752 |
_LL(&String[0], (TText8*)"100000000");
|
sl@0
|
753 |
Lex=&String[0];
|
sl@0
|
754 |
test((ret=Lex.Val(TU8, (TRadix)EBinary))==KErrOverflow);
|
sl@0
|
755 |
|
sl@0
|
756 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
757 |
Lex=&String[0];
|
sl@0
|
758 |
test((ret=Lex.Val(TU8, (TRadix)EOctal))==KErrNone);
|
sl@0
|
759 |
test(TU8==0);
|
sl@0
|
760 |
|
sl@0
|
761 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
762 |
Lex=&String[0];
|
sl@0
|
763 |
test((ret=Lex.Val(TU8, (TRadix)EOctal))==KErrNone);
|
sl@0
|
764 |
test(TU8==1);
|
sl@0
|
765 |
|
sl@0
|
766 |
_LL(&String[0], (TText8*)"377");
|
sl@0
|
767 |
Lex=&String[0];
|
sl@0
|
768 |
test((ret=Lex.Val(TU8, (TRadix)EOctal))==KErrNone);
|
sl@0
|
769 |
test(TU8==255);
|
sl@0
|
770 |
|
sl@0
|
771 |
_LL(&String[0], (TText8*)"400");
|
sl@0
|
772 |
Lex=&String[0];
|
sl@0
|
773 |
test((ret=Lex.Val(TU8, (TRadix)EOctal))==KErrOverflow);
|
sl@0
|
774 |
|
sl@0
|
775 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
776 |
Lex=&String[0];
|
sl@0
|
777 |
test((ret=Lex.Val(TU8, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
778 |
test(TU8==0);
|
sl@0
|
779 |
|
sl@0
|
780 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
781 |
Lex=&String[0];
|
sl@0
|
782 |
test((ret=Lex.Val(TU8, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
783 |
test(TU8==1);
|
sl@0
|
784 |
|
sl@0
|
785 |
_LL(&String[0], (TText8*)"255");
|
sl@0
|
786 |
Lex=&String[0];
|
sl@0
|
787 |
test((ret=Lex.Val(TU8, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
788 |
test(TU8==255);
|
sl@0
|
789 |
|
sl@0
|
790 |
_LL(&String[0], (TText8*)"256");
|
sl@0
|
791 |
Lex=&String[0];
|
sl@0
|
792 |
test((ret=Lex.Val(TU8, (TRadix)EDecimal))==KErrOverflow);
|
sl@0
|
793 |
|
sl@0
|
794 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
795 |
Lex=&String[0];
|
sl@0
|
796 |
test((ret=Lex.Val(TU8, (TRadix)EHex))==KErrNone);
|
sl@0
|
797 |
test(TU8==0);
|
sl@0
|
798 |
|
sl@0
|
799 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
800 |
Lex=&String[0];
|
sl@0
|
801 |
test((ret=Lex.Val(TU8, (TRadix)EHex))==KErrNone);
|
sl@0
|
802 |
test(TU8==1);
|
sl@0
|
803 |
|
sl@0
|
804 |
_LL(&String[0], (TText8*)"Ff");
|
sl@0
|
805 |
Lex=&String[0];
|
sl@0
|
806 |
test((ret=Lex.Val(TU8, (TRadix)EHex))==KErrNone);
|
sl@0
|
807 |
test(TU8==255);
|
sl@0
|
808 |
|
sl@0
|
809 |
_LL(&String[0], (TText8*)"100");
|
sl@0
|
810 |
Lex=&String[0];
|
sl@0
|
811 |
test((ret=Lex.Val(TU8, (TRadix)EHex))==KErrOverflow);
|
sl@0
|
812 |
|
sl@0
|
813 |
|
sl@0
|
814 |
|
sl@0
|
815 |
////////////////////////////
|
sl@0
|
816 |
// Test Val(TUint16, TRadix)
|
sl@0
|
817 |
////////////////////////////
|
sl@0
|
818 |
test.Next(_L("Val(TUint16, TRadix)"));
|
sl@0
|
819 |
TUint16 TU16;
|
sl@0
|
820 |
|
sl@0
|
821 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
822 |
Lex=&String[0];
|
sl@0
|
823 |
test((ret=Lex.Val(TU16, (TRadix)EBinary))==KErrNone);
|
sl@0
|
824 |
test(TU16==0);
|
sl@0
|
825 |
|
sl@0
|
826 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
827 |
Lex=&String[0];
|
sl@0
|
828 |
test((ret=Lex.Val(TU16, (TRadix)EBinary))==KErrNone);
|
sl@0
|
829 |
test(TU16==1);
|
sl@0
|
830 |
|
sl@0
|
831 |
_LL(&String[0], (TText8*)"1111111111111111");
|
sl@0
|
832 |
Lex=&String[0];
|
sl@0
|
833 |
test((ret=Lex.Val(TU16, (TRadix)EBinary))==KErrNone);
|
sl@0
|
834 |
test(TU16==65535);
|
sl@0
|
835 |
|
sl@0
|
836 |
_LL(&String[0], (TText8*)"10000000000000000");
|
sl@0
|
837 |
Lex=&String[0];
|
sl@0
|
838 |
test((ret=Lex.Val(TU16, (TRadix)EBinary))==KErrOverflow);
|
sl@0
|
839 |
|
sl@0
|
840 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
841 |
Lex=&String[0];
|
sl@0
|
842 |
test((ret=Lex.Val(TU16, (TRadix)EOctal))==KErrNone);
|
sl@0
|
843 |
test(TU16==0);
|
sl@0
|
844 |
|
sl@0
|
845 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
846 |
Lex=&String[0];
|
sl@0
|
847 |
test((ret=Lex.Val(TU16, (TRadix)EOctal))==KErrNone);
|
sl@0
|
848 |
test(TU16==1);
|
sl@0
|
849 |
|
sl@0
|
850 |
_LL(&String[0], (TText8*)"177777");
|
sl@0
|
851 |
Lex=&String[0];
|
sl@0
|
852 |
test((ret=Lex.Val(TU16, (TRadix)EOctal))==KErrNone);
|
sl@0
|
853 |
test(TU16==65535);
|
sl@0
|
854 |
|
sl@0
|
855 |
_LL(&String[0], (TText8*)"200000");
|
sl@0
|
856 |
Lex=&String[0];
|
sl@0
|
857 |
test((ret=Lex.Val(TU16, (TRadix)EOctal))==KErrOverflow);
|
sl@0
|
858 |
|
sl@0
|
859 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
860 |
Lex=&String[0];
|
sl@0
|
861 |
test((ret=Lex.Val(TU16, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
862 |
test(TU16==0);
|
sl@0
|
863 |
|
sl@0
|
864 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
865 |
Lex=&String[0];
|
sl@0
|
866 |
test((ret=Lex.Val(TU16, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
867 |
test(TU16==1);
|
sl@0
|
868 |
|
sl@0
|
869 |
_LL(&String[0], (TText8*)"65535");
|
sl@0
|
870 |
Lex=&String[0];
|
sl@0
|
871 |
test((ret=Lex.Val(TU16, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
872 |
test(TU16==65535);
|
sl@0
|
873 |
|
sl@0
|
874 |
_LL(&String[0], (TText8*)"65536");
|
sl@0
|
875 |
Lex=&String[0];
|
sl@0
|
876 |
test((ret=Lex.Val(TU16, (TRadix)EDecimal))==KErrOverflow);
|
sl@0
|
877 |
|
sl@0
|
878 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
879 |
Lex=&String[0];
|
sl@0
|
880 |
test((ret=Lex.Val(TU16, (TRadix)EHex))==KErrNone);
|
sl@0
|
881 |
test(TU16==0);
|
sl@0
|
882 |
|
sl@0
|
883 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
884 |
Lex=&String[0];
|
sl@0
|
885 |
test((ret=Lex.Val(TU16, (TRadix)EHex))==KErrNone);
|
sl@0
|
886 |
test(TU16==1);
|
sl@0
|
887 |
|
sl@0
|
888 |
_LL(&String[0], (TText8*)"ffFf");
|
sl@0
|
889 |
Lex=&String[0];
|
sl@0
|
890 |
test((ret=Lex.Val(TU16, (TRadix)EHex))==KErrNone);
|
sl@0
|
891 |
test(TU16==65535);
|
sl@0
|
892 |
|
sl@0
|
893 |
_LL(&String[0], (TText8*)"10000");
|
sl@0
|
894 |
Lex=&String[0];
|
sl@0
|
895 |
test((ret=Lex.Val(TU16, (TRadix)EHex))==KErrOverflow);
|
sl@0
|
896 |
|
sl@0
|
897 |
|
sl@0
|
898 |
|
sl@0
|
899 |
////////////////////////////
|
sl@0
|
900 |
// Test Val(TUint32, TRadix)
|
sl@0
|
901 |
////////////////////////////
|
sl@0
|
902 |
test.Next(_L("Val(TUint32, TRadix)"));
|
sl@0
|
903 |
TUint32 TU32;
|
sl@0
|
904 |
|
sl@0
|
905 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
906 |
Lex=&String[0];
|
sl@0
|
907 |
test((ret=Lex.Val(TU32, (TRadix)EBinary))==KErrNone);
|
sl@0
|
908 |
test(TU32==0);
|
sl@0
|
909 |
|
sl@0
|
910 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
911 |
Lex=&String[0];
|
sl@0
|
912 |
test((ret=Lex.Val(TU32, (TRadix)EBinary))==KErrNone);
|
sl@0
|
913 |
test(TU32==1);
|
sl@0
|
914 |
|
sl@0
|
915 |
_LL(&String[0], (TText8*)"11111111111111111111111111111111");
|
sl@0
|
916 |
Lex=&String[0];
|
sl@0
|
917 |
test((ret=Lex.Val(TU32, (TRadix)EBinary))==KErrNone);
|
sl@0
|
918 |
test(TU32==4294967295u);
|
sl@0
|
919 |
|
sl@0
|
920 |
_LL(&String[0], (TText8*)"100000000000000000000000000000000");
|
sl@0
|
921 |
Lex=&String[0];
|
sl@0
|
922 |
test((ret=Lex.Val(TU32, (TRadix)EBinary))==KErrOverflow);
|
sl@0
|
923 |
|
sl@0
|
924 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
925 |
Lex=&String[0];
|
sl@0
|
926 |
test((ret=Lex.Val(TU32, (TRadix)EOctal))==KErrNone);
|
sl@0
|
927 |
test(TU32==0);
|
sl@0
|
928 |
|
sl@0
|
929 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
930 |
Lex=&String[0];
|
sl@0
|
931 |
test((ret=Lex.Val(TU32, (TRadix)EOctal))==KErrNone);
|
sl@0
|
932 |
test(TU32==1);
|
sl@0
|
933 |
|
sl@0
|
934 |
_LL(&String[0], (TText8*)"37777777777");
|
sl@0
|
935 |
Lex=&String[0];
|
sl@0
|
936 |
test((ret=Lex.Val(TU32, (TRadix)EOctal))==KErrNone);
|
sl@0
|
937 |
test(TU32==4294967295u);
|
sl@0
|
938 |
|
sl@0
|
939 |
_LL(&String[0], (TText8*)"40000000000");
|
sl@0
|
940 |
Lex=&String[0];
|
sl@0
|
941 |
test((ret=Lex.Val(TU32, (TRadix)EOctal))==KErrOverflow);
|
sl@0
|
942 |
|
sl@0
|
943 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
944 |
Lex=&String[0];
|
sl@0
|
945 |
test((ret=Lex.Val(TU32, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
946 |
test(TU32==0);
|
sl@0
|
947 |
|
sl@0
|
948 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
949 |
Lex=&String[0];
|
sl@0
|
950 |
test((ret=Lex.Val(TU32, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
951 |
test(TU32==1);
|
sl@0
|
952 |
|
sl@0
|
953 |
_LL(&String[0], (TText8*)"4294967295");
|
sl@0
|
954 |
Lex=&String[0];
|
sl@0
|
955 |
test((ret=Lex.Val(TU32, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
956 |
test(TU32==4294967295u);
|
sl@0
|
957 |
|
sl@0
|
958 |
_LL(&String[0], (TText8*)"4294967296");
|
sl@0
|
959 |
Lex=&String[0];
|
sl@0
|
960 |
test((ret=Lex.Val(TU32, (TRadix)EDecimal))==KErrOverflow);
|
sl@0
|
961 |
|
sl@0
|
962 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
963 |
Lex=&String[0];
|
sl@0
|
964 |
test((ret=Lex.Val(TU32, (TRadix)EHex))==KErrNone);
|
sl@0
|
965 |
test(TU32==0);
|
sl@0
|
966 |
|
sl@0
|
967 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
968 |
Lex=&String[0];
|
sl@0
|
969 |
test((ret=Lex.Val(TU32, (TRadix)EHex))==KErrNone);
|
sl@0
|
970 |
test(TU32==1);
|
sl@0
|
971 |
|
sl@0
|
972 |
_LL(&String[0], (TText8*)"FFFFFFFF");
|
sl@0
|
973 |
Lex=&String[0];
|
sl@0
|
974 |
test((ret=Lex.Val(TU32, (TRadix)EHex))==KErrNone);
|
sl@0
|
975 |
test(TU32==4294967295u);
|
sl@0
|
976 |
|
sl@0
|
977 |
_LL(&String[0], (TText8*)"100000000");
|
sl@0
|
978 |
Lex=&String[0];
|
sl@0
|
979 |
test((ret=Lex.Val(TU32, (TRadix)EHex))==KErrOverflow);
|
sl@0
|
980 |
|
sl@0
|
981 |
///////////////////////////////////
|
sl@0
|
982 |
// Test Val(TInt64, TRadix)
|
sl@0
|
983 |
///////////////////////////////////
|
sl@0
|
984 |
test.Next(_L("Val(TInt64,TRadix)"));
|
sl@0
|
985 |
TInt64 TI64;
|
sl@0
|
986 |
|
sl@0
|
987 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
988 |
Lex=&String[0];
|
sl@0
|
989 |
test((ret=Lex.Val(TI64, (TRadix)EBinary))==KErrNone);
|
sl@0
|
990 |
test(TI64==0);
|
sl@0
|
991 |
|
sl@0
|
992 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
993 |
Lex=&String[0];
|
sl@0
|
994 |
test((ret=Lex.Val(TI64, (TRadix)EBinary))==KErrNone);
|
sl@0
|
995 |
test(TI64==1);
|
sl@0
|
996 |
|
sl@0
|
997 |
_LL(&String[0], (TText8*)"11111111111111111111111111111111");
|
sl@0
|
998 |
Lex=&String[0];
|
sl@0
|
999 |
test((ret=Lex.Val(TI64, (TRadix)EBinary))==KErrNone);
|
sl@0
|
1000 |
test(TI64==TInt64(0xffffffffu));
|
sl@0
|
1001 |
|
sl@0
|
1002 |
_LL(&String[0], (TText8*)"100000000000000000000000000000000");
|
sl@0
|
1003 |
Lex=&String[0];
|
sl@0
|
1004 |
test((ret=Lex.Val(TI64, (TRadix)EBinary))==KErrNone);
|
sl@0
|
1005 |
test(TI64==MAKE_TINT64(0x1,0x0));
|
sl@0
|
1006 |
|
sl@0
|
1007 |
_LL(&String[0], (TText8*)"1111111111111111111111111111111111111111111111111111111111111111");
|
sl@0
|
1008 |
Lex=&String[0];
|
sl@0
|
1009 |
test((ret=Lex.Val(TI64, (TRadix)EBinary))==KErrNone);
|
sl@0
|
1010 |
test(TI64==MAKE_TINT64(0xffffffffu,0xffffffffu));
|
sl@0
|
1011 |
|
sl@0
|
1012 |
_LL(&String[0], (TText8*)"10000000000000000000000000000000000000000000000000000000000000000");
|
sl@0
|
1013 |
Lex=&String[0];
|
sl@0
|
1014 |
test((ret=Lex.Val(TI64, (TRadix)EBinary))==KErrOverflow);
|
sl@0
|
1015 |
|
sl@0
|
1016 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1017 |
Lex=&String[0];
|
sl@0
|
1018 |
test((ret=Lex.Val(TI64, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1019 |
test(TI64==0);
|
sl@0
|
1020 |
|
sl@0
|
1021 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1022 |
Lex=&String[0];
|
sl@0
|
1023 |
test((ret=Lex.Val(TI64, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1024 |
test(TI64==1);
|
sl@0
|
1025 |
|
sl@0
|
1026 |
_LL(&String[0], (TText8*)"37777777777");
|
sl@0
|
1027 |
Lex=&String[0];
|
sl@0
|
1028 |
test((ret=Lex.Val(TI64, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1029 |
test(TI64==TInt64(0xffffffffu));
|
sl@0
|
1030 |
|
sl@0
|
1031 |
_LL(&String[0], (TText8*)"40000000000");
|
sl@0
|
1032 |
Lex=&String[0];
|
sl@0
|
1033 |
test((ret=Lex.Val(TI64, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1034 |
test(TI64==MAKE_TINT64(0x1,0x0));
|
sl@0
|
1035 |
|
sl@0
|
1036 |
_LL(&String[0], (TText8*)"1777777777777777777777");
|
sl@0
|
1037 |
Lex=&String[0];
|
sl@0
|
1038 |
test((ret=Lex.Val(TI64, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1039 |
test(TI64==MAKE_TINT64(0xffffffffu,0xffffffffu));
|
sl@0
|
1040 |
|
sl@0
|
1041 |
_LL(&String[0], (TText8*)"2000000000000000000000");
|
sl@0
|
1042 |
Lex=&String[0];
|
sl@0
|
1043 |
test((ret=Lex.Val(TI64, (TRadix)EOctal))==KErrOverflow);
|
sl@0
|
1044 |
|
sl@0
|
1045 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1046 |
Lex=&String[0];
|
sl@0
|
1047 |
test((ret=Lex.Val(TI64, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1048 |
test(TI64==0);
|
sl@0
|
1049 |
|
sl@0
|
1050 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1051 |
Lex=&String[0]; //************** iNext is set to "" by Val
|
sl@0
|
1052 |
test((ret=Lex.Val(TI64))==KErrNone);
|
sl@0
|
1053 |
test(TI64==0);
|
sl@0
|
1054 |
|
sl@0
|
1055 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1056 |
Lex=&String[0];
|
sl@0
|
1057 |
test((ret=Lex.Val(TI64, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1058 |
test(TI64==1);
|
sl@0
|
1059 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1060 |
Lex=&String[0];
|
sl@0
|
1061 |
test((ret=Lex.Val(TI64))==KErrNone);
|
sl@0
|
1062 |
test(TI64==1);
|
sl@0
|
1063 |
|
sl@0
|
1064 |
_LL(&String[0], (TText8*)"4294967295");
|
sl@0
|
1065 |
Lex=&String[0];
|
sl@0
|
1066 |
test((ret=Lex.Val(TI64, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1067 |
test(TI64==TInt64(0xffffffffu));
|
sl@0
|
1068 |
_LL(&String[0], (TText8*)"4294967295");
|
sl@0
|
1069 |
Lex=&String[0];
|
sl@0
|
1070 |
test((ret=Lex.Val(TI64))==KErrNone);
|
sl@0
|
1071 |
test(TI64==TInt64(0xffffffffu));
|
sl@0
|
1072 |
|
sl@0
|
1073 |
_LL(&String[0], (TText8*)"4294967296");
|
sl@0
|
1074 |
Lex=&String[0];
|
sl@0
|
1075 |
test((ret=Lex.Val(TI64, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1076 |
test(TI64==MAKE_TINT64(1,0));
|
sl@0
|
1077 |
_LL(&String[0], (TText8*)"4294967296");
|
sl@0
|
1078 |
Lex=&String[0];
|
sl@0
|
1079 |
test((ret=Lex.Val(TI64))==KErrNone);
|
sl@0
|
1080 |
test(TI64==MAKE_TINT64(1,0));
|
sl@0
|
1081 |
|
sl@0
|
1082 |
_LL(&String[0], (TText8*)"18446744073709551615");
|
sl@0
|
1083 |
Lex=&String[0];
|
sl@0
|
1084 |
test((ret=Lex.Val(TI64, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1085 |
test(TI64==MAKE_TINT64(0xffffffffu,0xffffffffu));
|
sl@0
|
1086 |
_LL(&String[0], (TText8*)"18446744073709551616");
|
sl@0
|
1087 |
Lex=&String[0];
|
sl@0
|
1088 |
test((ret=Lex.Val(TI64))==KErrOverflow);
|
sl@0
|
1089 |
|
sl@0
|
1090 |
_LL(&String[0], (TText8*)"-1");
|
sl@0
|
1091 |
Lex=&String[0];
|
sl@0
|
1092 |
test((ret=Lex.Val(TI64, (TRadix)EDecimal))==KErrGeneral);
|
sl@0
|
1093 |
|
sl@0
|
1094 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1095 |
Lex=&String[0];
|
sl@0
|
1096 |
test((ret=Lex.Val(TI64, (TRadix)EHex))==KErrNone);
|
sl@0
|
1097 |
test(TI64==0);
|
sl@0
|
1098 |
|
sl@0
|
1099 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1100 |
Lex=&String[0];
|
sl@0
|
1101 |
test((ret=Lex.Val(TI64, (TRadix)EHex))==KErrNone);
|
sl@0
|
1102 |
test(TI64==1);
|
sl@0
|
1103 |
|
sl@0
|
1104 |
_LL(&String[0], (TText8*)"FFFFFFFF");
|
sl@0
|
1105 |
Lex=&String[0];
|
sl@0
|
1106 |
test((ret=Lex.Val(TI64, (TRadix)EHex))==KErrNone);
|
sl@0
|
1107 |
test(TI64==TInt64(0xffffffffu));
|
sl@0
|
1108 |
|
sl@0
|
1109 |
_LL(&String[0], (TText8*)"100000000");
|
sl@0
|
1110 |
Lex=&String[0];
|
sl@0
|
1111 |
test((ret=Lex.Val(TI64, (TRadix)EHex))==KErrNone);
|
sl@0
|
1112 |
test(TI64==MAKE_TINT64(1,0));
|
sl@0
|
1113 |
|
sl@0
|
1114 |
_LL(&String[0], (TText8*)"FFFFFFFFffffffff");
|
sl@0
|
1115 |
Lex=&String[0];
|
sl@0
|
1116 |
test((ret=Lex.Val(TI64, (TRadix)EHex))==KErrNone);
|
sl@0
|
1117 |
test(TI64==MAKE_TINT64(0xffffffffu,0xffffffffu));
|
sl@0
|
1118 |
|
sl@0
|
1119 |
_LL(&String[0], (TText8*)"10000000000000000");
|
sl@0
|
1120 |
Lex=&String[0];
|
sl@0
|
1121 |
test((ret=Lex.Val(TI64, (TRadix)EHex))==KErrOverflow);
|
sl@0
|
1122 |
|
sl@0
|
1123 |
|
sl@0
|
1124 |
///////////////////////////////////
|
sl@0
|
1125 |
// Test Val(TUint, TRadix=(TRadix)EDecimal)
|
sl@0
|
1126 |
///////////////////////////////////
|
sl@0
|
1127 |
test.Next(_L("Val(TUint, TRadix=(TRadix)EDecimal)"));
|
sl@0
|
1128 |
TUint TU;
|
sl@0
|
1129 |
|
sl@0
|
1130 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1131 |
Lex=&String[0];
|
sl@0
|
1132 |
test((ret=Lex.Val(TU, (TRadix)EBinary))==KErrNone);
|
sl@0
|
1133 |
test(TU==0);
|
sl@0
|
1134 |
|
sl@0
|
1135 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1136 |
Lex=&String[0];
|
sl@0
|
1137 |
test((ret=Lex.Val(TU, (TRadix)EBinary))==KErrNone);
|
sl@0
|
1138 |
test(TU==1);
|
sl@0
|
1139 |
|
sl@0
|
1140 |
_LL(&String[0], (TText8*)"11111111111111111111111111111111");
|
sl@0
|
1141 |
Lex=&String[0];
|
sl@0
|
1142 |
test((ret=Lex.Val(TU, (TRadix)EBinary))==KErrNone);
|
sl@0
|
1143 |
test(TU==4294967295u);
|
sl@0
|
1144 |
|
sl@0
|
1145 |
_LL(&String[0], (TText8*)"100000000000000000000000000000000");
|
sl@0
|
1146 |
Lex=&String[0];
|
sl@0
|
1147 |
test((ret=Lex.Val(TU, (TRadix)EBinary))==KErrOverflow);
|
sl@0
|
1148 |
|
sl@0
|
1149 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1150 |
Lex=&String[0];
|
sl@0
|
1151 |
test((ret=Lex.Val(TU, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1152 |
test(TU==0);
|
sl@0
|
1153 |
|
sl@0
|
1154 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1155 |
Lex=&String[0];
|
sl@0
|
1156 |
test((ret=Lex.Val(TU, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1157 |
test(TU==1);
|
sl@0
|
1158 |
|
sl@0
|
1159 |
_LL(&String[0], (TText8*)"37777777777");
|
sl@0
|
1160 |
Lex=&String[0];
|
sl@0
|
1161 |
test((ret=Lex.Val(TU, (TRadix)EOctal))==KErrNone);
|
sl@0
|
1162 |
test(TU==4294967295u);
|
sl@0
|
1163 |
|
sl@0
|
1164 |
_LL(&String[0], (TText8*)"40000000000");
|
sl@0
|
1165 |
Lex=&String[0];
|
sl@0
|
1166 |
test((ret=Lex.Val(TU, (TRadix)EOctal))==KErrOverflow);
|
sl@0
|
1167 |
|
sl@0
|
1168 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1169 |
Lex=&String[0];
|
sl@0
|
1170 |
test((ret=Lex.Val(TU, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1171 |
test(TU==0);
|
sl@0
|
1172 |
|
sl@0
|
1173 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1174 |
Lex=&String[0]; //************** iNext is set to "" by Val
|
sl@0
|
1175 |
test((ret=Lex.Val(TU))==KErrNone);
|
sl@0
|
1176 |
test(TU==0);
|
sl@0
|
1177 |
|
sl@0
|
1178 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1179 |
Lex=&String[0];
|
sl@0
|
1180 |
test((ret=Lex.Val(TU, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1181 |
test(TU==1);
|
sl@0
|
1182 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1183 |
Lex=&String[0];
|
sl@0
|
1184 |
test((ret=Lex.Val(TU))==KErrNone);
|
sl@0
|
1185 |
test(TU==1);
|
sl@0
|
1186 |
|
sl@0
|
1187 |
_LL(&String[0], (TText8*)"4294967295");
|
sl@0
|
1188 |
Lex=&String[0];
|
sl@0
|
1189 |
test((ret=Lex.Val(TU, (TRadix)EDecimal))==KErrNone);
|
sl@0
|
1190 |
test(TU==4294967295u);
|
sl@0
|
1191 |
_LL(&String[0], (TText8*)"4294967295");
|
sl@0
|
1192 |
Lex=&String[0];
|
sl@0
|
1193 |
test((ret=Lex.Val(TU))==KErrNone);
|
sl@0
|
1194 |
test(TU==4294967295u);
|
sl@0
|
1195 |
|
sl@0
|
1196 |
_LL(&String[0], (TText8*)"4294967296");
|
sl@0
|
1197 |
Lex=&String[0];
|
sl@0
|
1198 |
test((ret=Lex.Val(TU, (TRadix)EDecimal))==KErrOverflow);
|
sl@0
|
1199 |
_LL(&String[0], (TText8*)"4294967296");
|
sl@0
|
1200 |
Lex=&String[0];
|
sl@0
|
1201 |
test((ret=Lex.Val(TU))==KErrOverflow);
|
sl@0
|
1202 |
|
sl@0
|
1203 |
_LL(&String[0], (TText8*)"00");
|
sl@0
|
1204 |
Lex=&String[0];
|
sl@0
|
1205 |
test((ret=Lex.Val(TU, (TRadix)EHex))==KErrNone);
|
sl@0
|
1206 |
test(TU==0);
|
sl@0
|
1207 |
|
sl@0
|
1208 |
_LL(&String[0], (TText8*)"01");
|
sl@0
|
1209 |
Lex=&String[0];
|
sl@0
|
1210 |
test((ret=Lex.Val(TU, (TRadix)EHex))==KErrNone);
|
sl@0
|
1211 |
test(TU==1);
|
sl@0
|
1212 |
|
sl@0
|
1213 |
_LL(&String[0], (TText8*)"FFFFFFFF");
|
sl@0
|
1214 |
Lex=&String[0];
|
sl@0
|
1215 |
test((ret=Lex.Val(TU, (TRadix)EHex))==KErrNone);
|
sl@0
|
1216 |
test(TU==4294967295u);
|
sl@0
|
1217 |
|
sl@0
|
1218 |
_LL(&String[0], (TText8*)"100000000");
|
sl@0
|
1219 |
Lex=&String[0];
|
sl@0
|
1220 |
test((ret=Lex.Val(TU, (TRadix)EHex))==KErrOverflow);
|
sl@0
|
1221 |
|
sl@0
|
1222 |
|
sl@0
|
1223 |
/////////////////////////////////
|
sl@0
|
1224 |
// Test Val(TInt32, TUint aLimit)
|
sl@0
|
1225 |
/////////////////////////////////
|
sl@0
|
1226 |
// This is called by several of the other Val methods and so has been indirectly tested already
|
sl@0
|
1227 |
test.Next(_L("Val(TInt32, TUint aLimit"));
|
sl@0
|
1228 |
|
sl@0
|
1229 |
_LL(&String[0], (TText8*)"1000");
|
sl@0
|
1230 |
Lex=&String[0];
|
sl@0
|
1231 |
test((ret=Lex.BoundedVal(T32,1000))==KErrNone);
|
sl@0
|
1232 |
test(T32==1000);
|
sl@0
|
1233 |
|
sl@0
|
1234 |
_LL(&String[0], (TText8*)"1001");
|
sl@0
|
1235 |
Lex=&String[0];
|
sl@0
|
1236 |
test((ret=Lex.BoundedVal(T32, 1000))==KErrOverflow);
|
sl@0
|
1237 |
|
sl@0
|
1238 |
_LL(&String[0], (TText8*)"-1000");
|
sl@0
|
1239 |
Lex=&String[0];
|
sl@0
|
1240 |
test((ret=Lex.BoundedVal(T32, 1000))==KErrNone);
|
sl@0
|
1241 |
test(T32==-1000);
|
sl@0
|
1242 |
|
sl@0
|
1243 |
_LL(&String[0], (TText8*)"-1001");
|
sl@0
|
1244 |
Lex=&String[0];
|
sl@0
|
1245 |
test((ret=Lex.BoundedVal(T32, 1000))==KErrNone);
|
sl@0
|
1246 |
test(T32==-1001);
|
sl@0
|
1247 |
|
sl@0
|
1248 |
_LL(&String[0], (TText8*)"-1002");
|
sl@0
|
1249 |
Lex=&String[0];
|
sl@0
|
1250 |
test((ret=Lex.BoundedVal(T32, 1000))==KErrOverflow);
|
sl@0
|
1251 |
|
sl@0
|
1252 |
_LL(&String[0], (TText8*)"0");
|
sl@0
|
1253 |
Lex=&String[0];
|
sl@0
|
1254 |
test((ret=Lex.BoundedVal(T32, 0))==KErrNone);
|
sl@0
|
1255 |
test(T32==0);
|
sl@0
|
1256 |
|
sl@0
|
1257 |
_LL(&String[0], (TText8*)"1");
|
sl@0
|
1258 |
Lex=&String[0];
|
sl@0
|
1259 |
test((ret=Lex.BoundedVal(T32, 0))==KErrOverflow);
|
sl@0
|
1260 |
|
sl@0
|
1261 |
|
sl@0
|
1262 |
/////////////////////////////////////////////////
|
sl@0
|
1263 |
// Test Val(TUInt32, TRadix aRadix, TUint aLimit)
|
sl@0
|
1264 |
////////////////////////////////////////////////
|
sl@0
|
1265 |
// This is called by several of the other Val methods and so has been indirectly tested already
|
sl@0
|
1266 |
test.Next(_L("Val(TUInt32, TRadix, TUint)"));
|
sl@0
|
1267 |
|
sl@0
|
1268 |
// Test bug found during previous testing
|
sl@0
|
1269 |
_LL(&String[0], (TText8*)"10");
|
sl@0
|
1270 |
Lex=&String[0];
|
sl@0
|
1271 |
test((ret=Lex.BoundedVal(TU32, (TRadix)EDecimal, 10))==KErrNone);
|
sl@0
|
1272 |
test(TU32==10);
|
sl@0
|
1273 |
|
sl@0
|
1274 |
_LL(&String[0], (TText8*)"11");
|
sl@0
|
1275 |
Lex=&String[0];
|
sl@0
|
1276 |
test((ret=Lex.BoundedVal(TU32, (TRadix)EDecimal, 10))==KErrOverflow);
|
sl@0
|
1277 |
|
sl@0
|
1278 |
_LL(&String[0], (TText8*)"19");
|
sl@0
|
1279 |
Lex=&String[0];
|
sl@0
|
1280 |
test((ret=Lex.BoundedVal(TU32, (TRadix)EDecimal, 10))==KErrOverflow);
|
sl@0
|
1281 |
|
sl@0
|
1282 |
_LL(&String[0], (TText8*)"20");
|
sl@0
|
1283 |
Lex=&String[0];
|
sl@0
|
1284 |
test((ret=Lex.BoundedVal(TU32, (TRadix)EDecimal, 10))==KErrOverflow);
|
sl@0
|
1285 |
|
sl@0
|
1286 |
/////////////////////////////////////////////////
|
sl@0
|
1287 |
// Test Val(TInt64, TRadix aRadix, TInt64 aLimit)
|
sl@0
|
1288 |
////////////////////////////////////////////////
|
sl@0
|
1289 |
test.Next(_L("Val(TInt64, TRadix, TInt64)"));
|
sl@0
|
1290 |
|
sl@0
|
1291 |
_LL(&String[0], (TText8*)"10");
|
sl@0
|
1292 |
Lex=&String[0];
|
sl@0
|
1293 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, 10))==KErrNone);
|
sl@0
|
1294 |
test(TI64==TInt64(10));
|
sl@0
|
1295 |
|
sl@0
|
1296 |
_LL(&String[0], (TText8*)"11");
|
sl@0
|
1297 |
Lex=&String[0];
|
sl@0
|
1298 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, 10))==KErrOverflow);
|
sl@0
|
1299 |
|
sl@0
|
1300 |
_LL(&String[0], (TText8*)"19");
|
sl@0
|
1301 |
Lex=&String[0];
|
sl@0
|
1302 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, 10))==KErrOverflow);
|
sl@0
|
1303 |
|
sl@0
|
1304 |
_LL(&String[0], (TText8*)"20");
|
sl@0
|
1305 |
Lex=&String[0];
|
sl@0
|
1306 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, 10))==KErrOverflow);
|
sl@0
|
1307 |
|
sl@0
|
1308 |
_LL(&String[0], (TText8*)"34532739886900");
|
sl@0
|
1309 |
Lex=&String[0];
|
sl@0
|
1310 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrNone);
|
sl@0
|
1311 |
test(TI64==MAKE_TINT64(0x1f68u,0x47b1af34u));
|
sl@0
|
1312 |
|
sl@0
|
1313 |
_LL(&String[0], (TText8*)"34532739886901");
|
sl@0
|
1314 |
Lex=&String[0];
|
sl@0
|
1315 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrOverflow);
|
sl@0
|
1316 |
|
sl@0
|
1317 |
_LL(&String[0], (TText8*)"74532739886901");
|
sl@0
|
1318 |
Lex=&String[0];
|
sl@0
|
1319 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrOverflow);
|
sl@0
|
1320 |
|
sl@0
|
1321 |
_LL(&String[0], (TText8*)"6901");
|
sl@0
|
1322 |
Lex=&String[0];
|
sl@0
|
1323 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EDecimal, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrNone);
|
sl@0
|
1324 |
test(TI64==TInt64(6901));
|
sl@0
|
1325 |
|
sl@0
|
1326 |
_LL(&String[0], (TText8*)"1f6847b1af34");
|
sl@0
|
1327 |
Lex=&String[0];
|
sl@0
|
1328 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EHex, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrNone);
|
sl@0
|
1329 |
test(TI64==MAKE_TINT64(0x1f68u,0x47b1af34u));
|
sl@0
|
1330 |
|
sl@0
|
1331 |
_LL(&String[0], (TText8*)"1f6847b1af35");
|
sl@0
|
1332 |
Lex=&String[0];
|
sl@0
|
1333 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EHex, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrOverflow);
|
sl@0
|
1334 |
|
sl@0
|
1335 |
_LL(&String[0], (TText8*)"1f6847b1af340");
|
sl@0
|
1336 |
Lex=&String[0];
|
sl@0
|
1337 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EHex, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrOverflow);
|
sl@0
|
1338 |
|
sl@0
|
1339 |
_LL(&String[0], (TText8*)"1e82791aed35");
|
sl@0
|
1340 |
Lex=&String[0];
|
sl@0
|
1341 |
test((ret=Lex.BoundedVal(TI64, (TRadix)EHex, TInt64(0x56fba45u)))==KErrOverflow);
|
sl@0
|
1342 |
|
sl@0
|
1343 |
/////////////////////////////////////////////////
|
sl@0
|
1344 |
// Test Val(TInt64, TInt64 aLimit)
|
sl@0
|
1345 |
////////////////////////////////////////////////
|
sl@0
|
1346 |
test.Next(_L("Val(TInt64, TInt64)"));
|
sl@0
|
1347 |
|
sl@0
|
1348 |
_LL(&String[0], (TText8*)"10");
|
sl@0
|
1349 |
Lex=&String[0];
|
sl@0
|
1350 |
test((ret=Lex.BoundedVal(TI64, 10))==KErrNone);
|
sl@0
|
1351 |
test(TI64==TInt64(10));
|
sl@0
|
1352 |
|
sl@0
|
1353 |
_LL(&String[0], (TText8*)"11");
|
sl@0
|
1354 |
Lex=&String[0];
|
sl@0
|
1355 |
test((ret=Lex.BoundedVal(TI64, 10))==KErrOverflow);
|
sl@0
|
1356 |
|
sl@0
|
1357 |
_LL(&String[0], (TText8*)"19");
|
sl@0
|
1358 |
Lex=&String[0];
|
sl@0
|
1359 |
test((ret=Lex.BoundedVal(TI64, 10))==KErrOverflow);
|
sl@0
|
1360 |
|
sl@0
|
1361 |
_LL(&String[0], (TText8*)"20");
|
sl@0
|
1362 |
Lex=&String[0];
|
sl@0
|
1363 |
test((ret=Lex.BoundedVal(TI64, 10))==KErrOverflow);
|
sl@0
|
1364 |
|
sl@0
|
1365 |
_LL(&String[0], (TText8*)"34532739886900");
|
sl@0
|
1366 |
Lex=&String[0];
|
sl@0
|
1367 |
test((ret=Lex.BoundedVal(TI64, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrNone);
|
sl@0
|
1368 |
test(TI64==MAKE_TINT64(0x1f68u,0x47b1af34u));
|
sl@0
|
1369 |
|
sl@0
|
1370 |
_LL(&String[0], (TText8*)"34532739886901");
|
sl@0
|
1371 |
Lex=&String[0];
|
sl@0
|
1372 |
test((ret=Lex.BoundedVal(TI64, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrOverflow);
|
sl@0
|
1373 |
|
sl@0
|
1374 |
_LL(&String[0], (TText8*)"74532739886901");
|
sl@0
|
1375 |
Lex=&String[0];
|
sl@0
|
1376 |
test((ret=Lex.BoundedVal(TI64, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrOverflow);
|
sl@0
|
1377 |
|
sl@0
|
1378 |
_LL(&String[0], (TText8*)"6901");
|
sl@0
|
1379 |
Lex=&String[0];
|
sl@0
|
1380 |
test((ret=Lex.BoundedVal(TI64, MAKE_TINT64(0x1f68u,0x47b1af34u)))==KErrNone);
|
sl@0
|
1381 |
test(TI64==TInt64(6901));
|
sl@0
|
1382 |
|
sl@0
|
1383 |
test.End();
|
sl@0
|
1384 |
}
|
sl@0
|
1385 |
|
sl@0
|
1386 |
void testLocale()
|
sl@0
|
1387 |
{
|
sl@0
|
1388 |
|
sl@0
|
1389 |
TLocale current;
|
sl@0
|
1390 |
current.Refresh();
|
sl@0
|
1391 |
TLocale loc;
|
sl@0
|
1392 |
loc.Refresh();
|
sl@0
|
1393 |
|
sl@0
|
1394 |
TReal64 v,v8;
|
sl@0
|
1395 |
TLex l;
|
sl@0
|
1396 |
TLex8 l8;
|
sl@0
|
1397 |
TInt r;
|
sl@0
|
1398 |
|
sl@0
|
1399 |
loc.SetDecimalSeparator('.');
|
sl@0
|
1400 |
loc.Set();
|
sl@0
|
1401 |
l=_L("-12.34");
|
sl@0
|
1402 |
l8=_L8("-12.34");
|
sl@0
|
1403 |
r=l.Val(v);
|
sl@0
|
1404 |
r=l8.Val(v8);
|
sl@0
|
1405 |
test(r==KErrNone);
|
sl@0
|
1406 |
test(v==-12.34);
|
sl@0
|
1407 |
test(v==v8);
|
sl@0
|
1408 |
|
sl@0
|
1409 |
l=_L("-12.34");
|
sl@0
|
1410 |
l8=_L8("-12.34");
|
sl@0
|
1411 |
r=l.Val(v,'.');
|
sl@0
|
1412 |
r=l8.Val(v8,'.');
|
sl@0
|
1413 |
test(r==KErrNone);
|
sl@0
|
1414 |
test(v==-12.34);
|
sl@0
|
1415 |
test(v==v8);
|
sl@0
|
1416 |
l=_L("-12.34");
|
sl@0
|
1417 |
l8=_L8("-12.34");
|
sl@0
|
1418 |
r=l.Val(v,',');
|
sl@0
|
1419 |
r=l8.Val(v8,',');
|
sl@0
|
1420 |
test(r==KErrNone);
|
sl@0
|
1421 |
test(v==-12);
|
sl@0
|
1422 |
test(v==v8);
|
sl@0
|
1423 |
|
sl@0
|
1424 |
l=_L("-12,34");
|
sl@0
|
1425 |
l8=_L8("-12,34");
|
sl@0
|
1426 |
r=l.Val(v);
|
sl@0
|
1427 |
r=l8.Val(v8);
|
sl@0
|
1428 |
test(r==KErrNone);
|
sl@0
|
1429 |
test(v==-12);
|
sl@0
|
1430 |
test(v==v8);
|
sl@0
|
1431 |
l=_L("-12,34");
|
sl@0
|
1432 |
l8=_L8("-12,34");
|
sl@0
|
1433 |
r=l.Val(v,'.');
|
sl@0
|
1434 |
r=l8.Val(v8,'.');
|
sl@0
|
1435 |
test(r==KErrNone);
|
sl@0
|
1436 |
test(v==-12);
|
sl@0
|
1437 |
test(v==v8);
|
sl@0
|
1438 |
l=_L("-12,34");
|
sl@0
|
1439 |
l8=_L8("-12,34");
|
sl@0
|
1440 |
r=l.Val(v,',');
|
sl@0
|
1441 |
r=l8.Val(v8,',');
|
sl@0
|
1442 |
test(r==KErrNone);
|
sl@0
|
1443 |
test(v==-12.34);
|
sl@0
|
1444 |
test(v==v8);
|
sl@0
|
1445 |
|
sl@0
|
1446 |
loc.SetDecimalSeparator(',');
|
sl@0
|
1447 |
loc.Set();
|
sl@0
|
1448 |
l=_L("-12.34");
|
sl@0
|
1449 |
l8=_L8("-12.34");
|
sl@0
|
1450 |
r=l.Val(v);
|
sl@0
|
1451 |
r=l8.Val(v8);
|
sl@0
|
1452 |
test(r==KErrNone);
|
sl@0
|
1453 |
test(v==-12);
|
sl@0
|
1454 |
test(v==v8);
|
sl@0
|
1455 |
|
sl@0
|
1456 |
l=_L("-12.34");
|
sl@0
|
1457 |
l8=_L8("-12.34");
|
sl@0
|
1458 |
r=l.Val(v,'.');
|
sl@0
|
1459 |
r=l8.Val(v8,'.');
|
sl@0
|
1460 |
test(r==KErrNone);
|
sl@0
|
1461 |
test(v==-12.34);
|
sl@0
|
1462 |
test(v==v8);
|
sl@0
|
1463 |
l=_L("-12.34");
|
sl@0
|
1464 |
l8=_L8("-12.34");
|
sl@0
|
1465 |
r=l.Val(v,',');
|
sl@0
|
1466 |
r=l8.Val(v8,',');
|
sl@0
|
1467 |
test(r==KErrNone);
|
sl@0
|
1468 |
test(v==-12);
|
sl@0
|
1469 |
test(v==v8);
|
sl@0
|
1470 |
|
sl@0
|
1471 |
l=_L("-12,34");
|
sl@0
|
1472 |
l8=_L8("-12,34");
|
sl@0
|
1473 |
r=l.Val(v);
|
sl@0
|
1474 |
r=l8.Val(v8);
|
sl@0
|
1475 |
test(r==KErrNone);
|
sl@0
|
1476 |
test(v==-12.34);
|
sl@0
|
1477 |
l=_L("-12,34");
|
sl@0
|
1478 |
l8=_L8("-12,34");
|
sl@0
|
1479 |
r=l.Val(v,'.');
|
sl@0
|
1480 |
r=l8.Val(v8,'.');
|
sl@0
|
1481 |
test(r==KErrNone);
|
sl@0
|
1482 |
test(v==-12);
|
sl@0
|
1483 |
test(v==v8);
|
sl@0
|
1484 |
l=_L("-12,34");
|
sl@0
|
1485 |
l8=_L8("-12,34");
|
sl@0
|
1486 |
r=l.Val(v,',');
|
sl@0
|
1487 |
r=l8.Val(v8,',');
|
sl@0
|
1488 |
test(r==KErrNone);
|
sl@0
|
1489 |
test(v==-12.34);
|
sl@0
|
1490 |
test(v==v8);
|
sl@0
|
1491 |
|
sl@0
|
1492 |
loc.Set();
|
sl@0
|
1493 |
current.Set();
|
sl@0
|
1494 |
}
|
sl@0
|
1495 |
|
sl@0
|
1496 |
#pragma warning( disable : 4705 ) // statement has no effect
|
sl@0
|
1497 |
GLDEF_C TInt E32Main()
|
sl@0
|
1498 |
{
|
sl@0
|
1499 |
|
sl@0
|
1500 |
test.Title();
|
sl@0
|
1501 |
|
sl@0
|
1502 |
test.Start(_L("********* TLEX **********"));
|
sl@0
|
1503 |
#if defined(_UNICODE)
|
sl@0
|
1504 |
TestTLex<TPtrC, TLex, TLexMark, TBuf<0x40>, TLex16Dump, TLexMark16Dump, TText> T;
|
sl@0
|
1505 |
#else
|
sl@0
|
1506 |
TestTLex<TPtrC, TLex, TLexMark, TBuf<0x40>, TLex8Dump, TLexMark8Dump, TText> T;
|
sl@0
|
1507 |
#endif
|
sl@0
|
1508 |
test.Next(_L("TText 1"));
|
sl@0
|
1509 |
T.Test1();
|
sl@0
|
1510 |
test.Next(_L("TText 2"));
|
sl@0
|
1511 |
T.Test2();
|
sl@0
|
1512 |
test.Next(_L("TText 3"));
|
sl@0
|
1513 |
T.Test3();
|
sl@0
|
1514 |
test.Next(_L("TText 4"));
|
sl@0
|
1515 |
T.Test4();
|
sl@0
|
1516 |
test.Next(_L("TText 5"));
|
sl@0
|
1517 |
T.Test5();
|
sl@0
|
1518 |
|
sl@0
|
1519 |
TestTLex<TPtrC8, TLex8, TLexMark8, TBuf8<0x40>, TLex8Dump, TLexMark8Dump, TText8> T8;
|
sl@0
|
1520 |
test.Next(_L("TText8 1"));
|
sl@0
|
1521 |
T8.Test1();
|
sl@0
|
1522 |
test.Next(_L("TText8 2"));
|
sl@0
|
1523 |
T8.Test2();
|
sl@0
|
1524 |
test.Next(_L("TText8 3"));
|
sl@0
|
1525 |
T8.Test3();
|
sl@0
|
1526 |
test.Next(_L("TText8 4"));
|
sl@0
|
1527 |
T8.Test4();
|
sl@0
|
1528 |
test.Next(_L("TText8 5"));
|
sl@0
|
1529 |
T8.Test5();
|
sl@0
|
1530 |
|
sl@0
|
1531 |
TestTLex<TPtrC16, TLex16, TLexMark16, TBuf16<0x40>, TLex16Dump, TLexMark16Dump, TText16> T16;
|
sl@0
|
1532 |
test.Next(_L("TText16 1"));
|
sl@0
|
1533 |
T16.Test1();
|
sl@0
|
1534 |
test.Next(_L("TText16 2"));
|
sl@0
|
1535 |
T16.Test2();
|
sl@0
|
1536 |
test.Next(_L("TText16 3"));
|
sl@0
|
1537 |
T16.Test3();
|
sl@0
|
1538 |
test.Next(_L("TText16 4"));
|
sl@0
|
1539 |
T16.Test4();
|
sl@0
|
1540 |
test.Next(_L("TText16 5"));
|
sl@0
|
1541 |
T16.Test5();
|
sl@0
|
1542 |
|
sl@0
|
1543 |
test.Next(_L("Test TLex in different locales"));
|
sl@0
|
1544 |
testLocale();
|
sl@0
|
1545 |
|
sl@0
|
1546 |
test.End();
|
sl@0
|
1547 |
return(KErrNone);
|
sl@0
|
1548 |
}
|
sl@0
|
1549 |
#pragma warning( default : 4705 )
|
sl@0
|
1550 |
|