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