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