lowlevellibsandfws/genericusabilitylib/test/src/t_lsformat.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2008-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 "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 // Overview:
       
    15 // Test methods of the LString16, LString8, LString template class.
       
    16 // API Information:
       
    17 // LString16, LString8, LString 
       
    18 // Details :
       
    19 // - Create some 16 bit modifiable descriptors, 8 bit modifiable descriptors
       
    20 // of fixed length, Build-independent modifiable descriptors, initialize 
       
    21 // with different strings and check for
       
    22 // - Comparison operators,
       
    23 // - Property access methods,
       
    24 // - Fill & swap methods,
       
    25 // - Conversion methods,
       
    26 // - Comparison methods,
       
    27 // - Pattern Matching methods,
       
    28 // - Pattern Locating methods,
       
    29 // - Copying methods, 
       
    30 // - Find, FindC, FindF methods,
       
    31 // - Repeat, Trim, TrimLeft, TrimRight, Insert, Delete, Left,
       
    32 // Right, Mid methods,
       
    33 // - Formatting methods,
       
    34 // - Replace methods are as expected.
       
    35 // - Construct some descriptors with buffer length, string and buffer reference and
       
    36 // verify that they are created successfully.
       
    37 // - Test assignment operators and comparison operators for different descriptors.
       
    38 // - Initialize some descriptors and check descriptors' maximum length, length and 
       
    39 // size are as expected. 
       
    40 // - Check Fill and Swap methods are as expected.
       
    41 // - Test Fold, Collate, LowerCase, UpperCase methods are as expected.
       
    42 // - Test Comparison methods are as expected.
       
    43 // - Test pattern matching for simple string, wild cards with collated comparison. Verify that the 
       
    44 // return value is KErrNotFound when pattern doesn't match.
       
    45 // - Check Locating methods by searching character in forward and backward direction and 
       
    46 // verify the return value is KErrNotFound when unavailable character is searched.
       
    47 // - Check copying strings and converting those into lower and upper case strings are
       
    48 // as expected.
       
    49 // - Check Find methods by searching string and verify the return value is KErrNotFound when 
       
    50 // unavailable string is searched.
       
    51 // - Check Repeat, Trim, Insert and Delete methods are as expected.
       
    52 // - Check the formatting operations are as expected.
       
    53 // - Check integer to decimal character representation is as expected.
       
    54 // - Check integer to character representation with different number system is as expected.
       
    55 // - Check string formatting with variable parameter list is as expected
       
    56 // - Check Replace method by replacing string at different places in a string is as expected.
       
    57 // - Check the conversion of real numbers, extended precision real numbers into string
       
    58 // format is as expected.
       
    59 // - Check Format and FormatList methods are as expected.
       
    60 // - Check Format of TReal is as expected.
       
    61 // - Check the non-leaving and leaving descriptors overflow handlers are as expected. 
       
    62 // Platforms/Drives/Compatibility:
       
    63 // All 
       
    64 // Assumptions/Requirement/Pre-requisites:
       
    65 // Failures and causes:
       
    66 // Base Port information:
       
    67 // 
       
    68 //
       
    69 
       
    70 #include <e32test.h>
       
    71 #include <e32math.h>
       
    72 #include <hal.h>
       
    73 #include <hal_data.h>
       
    74 #include <hal_data.h>
       
    75 #include <e32svr.h>
       
    76 #include <estring.h>
       
    77 
       
    78 #ifdef __VC32__
       
    79     // Solve compilation problem caused by non-English locale
       
    80     #pragma setlocale("english")
       
    81 #endif
       
    82 
       
    83 LOCAL_D RTest test(_L("T_LSFORMAT"));
       
    84 
       
    85 #pragma warning(disable: 4127) // disabling warning "conditional expression is constant"
       
    86 #pragma warning(disable: 4310) // disabling warning "cast truncates constant value"
       
    87 
       
    88 #undef _TL
       
    89 #define _TL(a) DESTEMPLATE((S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a)) 
       
    90 #undef _TS
       
    91 #define _TS(a) ((const S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a)) 
       
    92 
       
    93 template<class T,class S,class DESTEMPLATE>	
       
    94 class TestLString
       
    95 	{
       
    96 public:
       
    97 	TestLString(TInt aLength); // Test class constructor.
       
    98 	void Test1L();   // Tests all functions of the class with auto extension
       
    99 	void Test2();   // Tests all constructors.
       
   100 	void Test3();	// Tests all assignment operators
       
   101 	void Test4();	// Tests all comparison operators
       
   102 	void Test7();	// Tests all conversion 
       
   103 	void Test8();	// Tests all comparison
       
   104 	void Test9();	// Tests all matching
       
   105 	void Test10();	// Tests all locating
       
   106 	void Test11L();	// Tests all Copying
       
   107 	void Test12();	// Tests all finding
       
   108 	void Test13L();	// Tests all basic like ops
       
   109 	void Test14L();  // Tests all formating with auto extension 
       
   110 	void Test15L();  // Tests all replacing with auto extension 
       
   111 	void test_TBufL(); // Test all classes
       
   112 protected:
       
   113 	void Test14_ReorderedParameterFormatting(TInt aDummyParameter, ...);
       
   114 	void Test14_ReorderedParameterFormattingL(TInt aDummyParameter, ...);
       
   115 private:
       
   116 	TInt iMaxBufLength;
       
   117 	};
       
   118 
       
   119 template<class T>
       
   120 void TestEq(const T& a, const T& b, TInt aLine)
       
   121 	{
       
   122 	if (a!=b)
       
   123 		{
       
   124 		LString16 buf(256);
       
   125 		test.Printf(_L("LINE %d:\n"),aLine);
       
   126 		buf.CopyL(a);
       
   127 		test.Printf(_L("a=%S\n"),&buf);
       
   128 		buf.CopyL(b);
       
   129 		test.Printf(_L("b=%S\n"),&buf);
       
   130 		test(0);
       
   131 		}
       
   132 	}
       
   133 
       
   134 
       
   135 #define TESTEQ(a,b)	TestEq<T>((a),(b),__LINE__)
       
   136 
       
   137 template <class T,class S,class DESTEMPLATE>
       
   138 GLDEF_C TestLString<T,S,DESTEMPLATE>::TestLString(TInt aLength)
       
   139 // Constructor.
       
   140 	: iMaxBufLength(aLength)
       
   141 	{}
       
   142 
       
   143 /**
       
   144 @SYMTestCaseID SYSLIB-EUSERHL-UT-4011
       
   145 @SYMTestCaseDesc Tests LString Auto-extending functions 
       
   146 @SYMTestPriority High
       
   147 @SYMTestActions Creates LString objects and uses the auto-extending LString 
       
   148 				functions to manipulate the strings.
       
   149 				Verifies that the LStrings are auto-extended as expected.
       
   150 @SYMTestExpectedResults The LString objects should be auto-extended as required to
       
   151 				contain any new data.
       
   152 @SYMREQ	10372-3
       
   153 */
       
   154 template <class T,class S,class DESTEMPLATE>
       
   155 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test1L()
       
   156 	{
       
   157 	
       
   158 	test.Start(_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4011"));
       
   159 	
       
   160 	test.Next(_L("Extending Methods"));
       
   161 
       
   162 	T a(1);
       
   163 	T b(1);
       
   164 
       
   165 	test(a.Length()==0);
       
   166 	test(a.MaxLength() >=1);
       
   167 
       
   168 	test.Next(_L("Setting a bigger length "));
       
   169 	a.SetLengthL(10);
       
   170 	test(a.Length()== 10);
       
   171 	test(a.MaxLength() >= 10);
       
   172 
       
   173 	test.Next(_L("operator+ with memory extension "));
       
   174 	test(b.MaxLength() >=1);
       
   175 	b += a;
       
   176 	test(b.Length()== 10);
       
   177 	test(b.MaxLength() >= 10);
       
   178 	
       
   179 	TChar c('A');
       
   180 	test(b.MaxLength() >=1);
       
   181 	b += c;
       
   182 	test(b.Length()== 11);
       
   183 	test(b.MaxLength() >= 10);
       
   184 
       
   185 	test.Next(_L("Filling past current size "));
       
   186 	a.FillL(' ', 20);
       
   187 	test(a.Length()== 20);
       
   188 	test(a.MaxLength() >= 20);
       
   189 
       
   190 	test.Next(_L("Append filling past current size "));
       
   191 	a.AppendFillL(' ', 10);
       
   192 	test(a.Length()== 30);
       
   193 	test(a.MaxLength() >= 30);
       
   194 
       
   195 	test.Next(_L("Zeroing past current size "));
       
   196 	a.FillZL(40);
       
   197 	test(a.Length()== 40);
       
   198 	test(a.MaxLength() >= 40);
       
   199 
       
   200 	test.Next(_L("Entended Copying"));
       
   201 	a.CopyL(b);
       
   202 	test(a == b);
       
   203 
       
   204 	a.CopyL(_TL("AB"));
       
   205 	test(a == _TL("AB"));
       
   206 
       
   207 	a.CopyFL(b);
       
   208 	
       
   209 	T d(b);
       
   210 	d.Fold();
       
   211 	test(a == d);
       
   212 
       
   213 	a.CopyFL(_TL("AB"));
       
   214 	test(a == _TL("ab"));
       
   215 
       
   216 	a.CopyCL(b);
       
   217 
       
   218 	d = b;
       
   219 	d.Collate();
       
   220 	test(a == d);
       
   221 
       
   222 	a.CopyCL(_TL("AB"));
       
   223 	test(a == _TL("ab"));
       
   224 
       
   225 	a.CopyLCL(b);
       
   226 
       
   227 	d = b;
       
   228 	d.LowerCase();
       
   229 	test(a == d);
       
   230 
       
   231 	a.CopyLCL(_TL("AB"));
       
   232 	test(a == _TL("ab"));
       
   233 
       
   234 	a.CopyUCL(b);
       
   235 
       
   236 	d = b;
       
   237 	d.UpperCase();
       
   238 	test(a == d);
       
   239 
       
   240 	a.CopyUCL(_TL("AB"));
       
   241 	test(a == _TL("AB"));
       
   242 
       
   243 	a.CopyCPL(b);
       
   244 
       
   245 	d = b;
       
   246 	d.Capitalize();
       
   247 	test(a == d);	
       
   248 	
       
   249 	a.CopyCPL(_TL("AB"));
       
   250 	test(a == _TL("Ab"));
       
   251 
       
   252 	test.Next(_L("Basic like ops"));
       
   253 
       
   254 	a.Zero();
       
   255 	b=_TL("AA");
       
   256 	a.InsertL(0,b);
       
   257 	test(a == b);
       
   258 
       
   259 	test.Next(_L("Formating"));
       
   260 	a.JustifyL(_TL("AB"),10,ELeft,' ');
       
   261 	test(a == _TL("AB        "));
       
   262 	
       
   263 	a.JustifyL(b,10,ELeft,' ');
       
   264 	test(a == _TL("AA        "));
       
   265 
       
   266 	b.FillL('A',2);
       
   267 	test(b == _TL("AA"));
       
   268 
       
   269 	a.Zero();
       
   270 	a.AppendJustifyL(_TL("AB"),10,ELeft,' ');
       
   271 	test(a == _TL("AB        "));
       
   272 	
       
   273 	a.AppendJustifyL(b,10,ELeft,' ');
       
   274 	test(a == _TL("AB        AA        "));
       
   275 		
       
   276 	DESTEMPLATE des(b);
       
   277 	a.Zero();
       
   278 	a.AppendJustifyL(des,2,10,ELeft,' ');
       
   279 	test(a == _TL("AA        "));
       
   280 	
       
   281 	a.AppendJustifyL(des,2,KDefaultJustifyWidth ,ELeft,' ');
       
   282 	test(a == _TL("AA        AA"));
       
   283 	
       
   284 	a.Zero();
       
   285 	a.AppendJustifyL(des,10,ELeft,' ');
       
   286 	test(a == _TL("AA        "));
       
   287 	
       
   288 	a.AppendJustifyL(des,KDefaultJustifyWidth ,ELeft,' ');
       
   289 	test(a == _TL("AA        AA"));
       
   290 	
       
   291 	a.Zero();
       
   292 	a.AppendJustifyL(b.PtrZL(),10,ELeft,' ');
       
   293 	test(a == _TL("AA        "));
       
   294 	
       
   295 	a.AppendJustifyL(b.PtrZL(),KDefaultJustifyWidth,ELeft,' ');
       
   296 	test(a == _TL("AA        AA"));
       
   297 	
       
   298 	a.AppendJustifyL(b.PtrZL(),2,KDefaultJustifyWidth,ELeft,' ');
       
   299 	test(a == _TL("AA        AAAA"));
       
   300 	
       
   301 	a.Zero();
       
   302 	a.AppendJustifyL(b.PtrZL(),2,10,ELeft,' ');
       
   303 	test(a == _TL("AA        "));
       
   304 	
       
   305 	a.AppendJustifyL(b.PtrZL(),2,5,ELeft,' ');
       
   306 	test(a == _TL("AA        AA   "));
       
   307 
       
   308 	TInt v1=10;
       
   309 	a.NumL(v1);
       
   310 	test(a == _TL("10"));
       
   311 	a.AppendNumL(v1);
       
   312 	test(a == _TL("1010"));
       
   313 
       
   314 	TInt v2=10;
       
   315 	a.NumL((TUint)v2,EHex);
       
   316 	test(a == _TL("a"));
       
   317 	a.AppendNumL((TUint)v2,EHex);
       
   318 	test(a == _TL("aa"));
       
   319 
       
   320 	a.NumUCL((TUint)v2,EHex);
       
   321 	test(a == _TL("A"));
       
   322 	a.AppendNumUCL((TUint)v2,EHex);
       
   323 	test(a == _TL("AA"));
       
   324 	
       
   325 	a.NumFixedWidthL((TUint)v2,EHex,1);
       
   326 	test(a == _TL("a"));
       
   327 	a.AppendNumFixedWidthL((TUint)v2,EHex,1);
       
   328 	test(a == _TL("aa"));
       
   329 	
       
   330 	a.NumFixedWidthUCL((TUint)v2,EHex,1);
       
   331 	test(a == _TL("A"));
       
   332 	a.AppendNumFixedWidthUCL((TUint)v2,EHex,1);
       
   333 	test(a == _TL("AA"));
       
   334 
       
   335 	TReal v3=10.0;
       
   336 	TRealFormat ff;
       
   337 	ff.iType=KRealFormatFixed;
       
   338 	ff.iWidth=10;
       
   339 	ff.iPlaces=2;
       
   340 	ff.iPoint='.';
       
   341 	ff.iTriad=',';
       
   342 	ff.iTriLen=3;
       
   343 	a.NumL(v3,ff);
       
   344 	test(a == _TL("10.00"));
       
   345 	
       
   346 	a.AppendNumL(v3,ff);
       
   347 	test(a == _TL("10.0010.00"));
       
   348 	
       
   349 	a.FormatL(_TL("%d"),12);
       
   350 	test(a == _TL("12"));
       
   351 	
       
   352 	a.AppendFormatL(_TL("%d"),12);
       
   353 	test(a == _TL("1212"));
       
   354 
       
   355 	b=_TL("%d");
       
   356 	a.FormatL(b,12);
       
   357 	test(a == _TL("12"));
       
   358 	a.AppendFormatL(b,12);
       
   359 	test(a == _TL("1212"));
       
   360 	//*/
       
   361 	
       
   362 	test.Next(_L("Replacing"));
       
   363 	a=_TL("AAC");
       
   364 	b=_TL("B");
       
   365 	a.ReplaceL(1,1,b);
       
   366 	test(a == _TL("ABC"));
       
   367 	
       
   368 	test.End();
       
   369 	}
       
   370 
       
   371 
       
   372 
       
   373 /**
       
   374 @SYMTestCaseID SYSLIB-EUSERHL-UT-4012
       
   375 @SYMTestCaseDesc Tests all LString Constructors
       
   376 @SYMTestPriority High
       
   377 @SYMTestActions Creates LString objects using the different constructors.
       
   378 				Verifies that length and contents are as expected
       
   379 @SYMTestExpectedResults LString objects should be created with the correct 
       
   380 				Length and contents
       
   381 @SYMREQ	10372
       
   382 */
       
   383 template <class T,class S,class DESTEMPLATE>
       
   384 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test2()
       
   385 // Tests all constructors.
       
   386 	{
       
   387 	
       
   388 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4012"));
       
   389 	
       
   390 	test.Next(_L("Default"));
       
   391 	
       
   392 	T a(iMaxBufLength);
       
   393 	test(a.MaxLength() >=iMaxBufLength);
       
   394 	test(a.Length()==0);
       
   395 
       
   396 	test.Next(_L("By string"));
       
   397 	T c(iMaxBufLength);
       
   398 	c = _TL("AB");
       
   399 	test(c.Length()==2);
       
   400 	test(c[0]=='A');
       
   401 	test(c[1]=='B');
       
   402 
       
   403 	test.Next(_L("By buffer reference"));
       
   404 	T d(iMaxBufLength);
       
   405 	d = c;
       
   406 	test(d.Length()==2);
       
   407 	test(d[0]=='A');
       
   408 	test(d[1]=='B');
       
   409 	
       
   410 	test.End();
       
   411 	}
       
   412 
       
   413 /**
       
   414 @SYMTestCaseID SYSLIB-EUSERHL-UT-4013
       
   415 @SYMTestCaseDesc Tests all LString Assignment operators
       
   416 @SYMTestPriority High
       
   417 @SYMTestActions Creates LString objects and uses the different assignment 
       
   418 				operators to change the string contents
       
   419 				Verifies that length and contents are as expected
       
   420 @SYMTestExpectedResults LString data should be assigned as expected
       
   421 @SYMREQ	10372
       
   422 */
       
   423 template <class T,class S,class DESTEMPLATE>
       
   424 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test3()
       
   425 // Tests all assignment operators
       
   426 	{
       
   427 	
       
   428 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4013"));
       
   429 	
       
   430 	test.Next(_L("By String"));
       
   431 	
       
   432 	T a;
       
   433 	a=_TL("AB");
       
   434 	a+=_TL("CD");
       
   435 	test(a.Length()==4);
       
   436 	test(a==_TL("ABCD"));
       
   437 
       
   438 	test.Next(_L("By buffer"));
       
   439 	T b;
       
   440 	b=a;
       
   441 	b+=a;
       
   442 	test(b.Length()==8);
       
   443 	test(b==_TL("ABCDABCD"));
       
   444 //	
       
   445 	test.End();
       
   446 	}
       
   447 
       
   448 /**
       
   449 @SYMTestCaseID SYSLIB-EUSERHL-UT-4014
       
   450 @SYMTestCaseDesc Tests all LString comparison operators
       
   451 @SYMTestPriority High
       
   452 @SYMTestActions Creates LString objects and uses the different comparison 
       
   453 				operators to compare string contents against other strings 
       
   454 				Verifies that comparison operators work as expected
       
   455 @SYMTestExpectedResults LString data comparison should work as expected
       
   456 @SYMREQ	10372
       
   457 */
       
   458 template <class T,class S,class DESTEMPLATE>
       
   459 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test4()
       
   460 // Test all comparison operators
       
   461 	{
       
   462 	
       
   463 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4014"));
       
   464 	
       
   465 	test.Next(_L("By NULL string"));
       
   466 	
       
   467 	T a;
       
   468 	test(a==_TL(""));		// NULL strings
       
   469 	test(!(a!=_TL("")));
       
   470 	test(a<=_TL(""));
       
   471 	test(a>=_TL(""));
       
   472 	test(!(a<_TL("")));
       
   473 	test(!(a>_TL("")));
       
   474 	test(_TL("")==a);
       
   475 	test(!(_TL("")!=a));
       
   476 	test(_TL("")<=a);
       
   477 	test(_TL("")>=a);
       
   478 	test(!(_TL("")<a));
       
   479 	test(!(_TL("")>a));
       
   480 
       
   481 	test.Next(_L("By string or buffer"));
       
   482 	a=_TL("abc");
       
   483 	test(a==_TL("abc"));		// ==
       
   484 	test(!(a==_TL("xyz")));
       
   485 	test(!(a==_TL("aa")));
       
   486 	test(_TL("abc")==a);
       
   487 	test(!(_TL("xyz")==a));
       
   488 	test(!(_TL("aa")==a));
       
   489 	test(a!=_TL("xyz"));		// !=
       
   490 	test(!(a!=_TL("abc")));
       
   491 	test(a!=_TL("aa"));
       
   492 	test(_TL("xyz")!=a);
       
   493 	test(!(_TL("abc")!=a));
       
   494 	test(_TL("aa")!=a);
       
   495 	test(a<_TL("x"));			// <
       
   496 	test(!(a<_TL("abc")));
       
   497 	test(!(a<_TL("aa")));
       
   498 	test(_TL("aa")<a);
       
   499 	test(!(_TL("abc")<a));
       
   500 	test(!(_TL("xyz")<a));
       
   501 	test(a>_TL("aa"));			// >
       
   502 	test(!(a>_TL("abc")));
       
   503 	test(!(a>_TL("xyz")));
       
   504 	test(_TL("xyz")>a);
       
   505 	test(!(_TL("abc")>a));
       
   506 	test(!(_TL("aa")>a));
       
   507 	test(a>=_TL("abc"));		// >=
       
   508 	test(!(a>=_TL("xyz")));
       
   509 	test(a>=_TL("aa"));
       
   510 	test(_TL("abc")>=a);
       
   511 	test(!(_TL("aaa")>=a));
       
   512 	test(_TL("xyz")>=a);
       
   513 	test(a<=_TL("abc"));		// <=
       
   514 	test(!(a<=_TL("aa")));
       
   515 	test(a<=_TL("xyz"));
       
   516 	test(_TL("abc")<=a);
       
   517 	test(!(_TL("xyz")<=a));
       
   518 	test(_TL("aa")<=a);
       
   519 
       
   520 	test.Next(_L("By special characters"));
       
   521 	a=_TL("!@#$%^&*()");
       
   522 	test(a==_TL("!@#$%^&*()"));
       
   523 	
       
   524 	test.End();	
       
   525 	}
       
   526 
       
   527 /**
       
   528 @SYMTestCaseID SYSLIB-EUSERHL-UT-4015
       
   529 @SYMTestCaseDesc Tests all LString conversion methods
       
   530 @SYMTestPriority High
       
   531 @SYMTestActions Creates LString objects and uses the different conversion 
       
   532 				methods to fold, collate and change case.
       
   533 				Verifies that conversion methods work as expected.
       
   534 @SYMTestExpectedResults LString data conversion methods should work as expected
       
   535 @SYMREQ	10372
       
   536 */
       
   537 template <class T,class S,class DESTEMPLATE>
       
   538 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test7()
       
   539 // Conversion operators
       
   540 	{
       
   541 	
       
   542 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4015"));
       
   543 	
       
   544 	test.Next(_L("Fold, collate ..."));
       
   545 	
       
   546 	T a;
       
   547 	T b;
       
   548 	a=_TL("abc AbC");
       
   549 	b=_TL("ABC ABC");
       
   550 	a.Fold();
       
   551 	b.Fold();
       
   552 	test(a==b);
       
   553 	a=_TL("abc AbC");
       
   554 	b=_TL("ABC ABC");
       
   555 	a.Collate();
       
   556 	b.Collate();
       
   557 	test(a==b);
       
   558 	a.LowerCase();
       
   559 	test(a==_TL("abc abc"));
       
   560 	a.Capitalize();
       
   561 	test(a==_TL("Abc abc"));
       
   562 	a.UpperCase();
       
   563 	test(a==_TL("ABC ABC"));
       
   564 	
       
   565 	test.End();
       
   566 	}
       
   567 
       
   568 /**
       
   569 @SYMTestCaseID SYSLIB-EUSERHL-UT-4016
       
   570 @SYMTestCaseDesc Tests LString Compare() method
       
   571 @SYMTestPriority High
       
   572 @SYMTestActions Creates LString objects and uses the Compare()
       
   573 				method to compare string contents against other strings 
       
   574 				Verifies that comparison method works as expected
       
   575 @SYMTestExpectedResults LString Compare() method should return a positive 
       
   576 				value if this LString is greater than the specified descriptor. 
       
   577 				Negative if this LString is less than the specified descriptor. 
       
   578 				Zero if both descriptors have the same length and the their 
       
   579 				contents are the same.
       
   580 @SYMREQ	10372
       
   581 */
       
   582 template <class T,class S,class DESTEMPLATE>
       
   583 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test8()
       
   584 // Comparison
       
   585 	{
       
   586 	
       
   587 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4016"));
       
   588 	
       
   589 	test.Next(_L("By string"));
       
   590 	
       
   591 	T a(iMaxBufLength);
       
   592 	a=_TL("abc AbC");
       
   593 	test(a.Compare(_TL("abc AbC"))==0);
       
   594 	test(a.CompareF(_TL("ABC aBc"))==0);
       
   595 	test(a.Compare(_TL("xyz"))!=0);
       
   596 	test(a.CompareC(_TL("xyz"))!=0);
       
   597 	test(a.CompareF(_TL("xyz"))!=0);
       
   598 
       
   599 	test.Next(_L("By buffer"));
       
   600 	T b;
       
   601 	T c;
       
   602 	a=_TL("abc AbC");
       
   603 	b=_TL("abc AbC");
       
   604 	c=_TL("xyz");
       
   605 	test(a.Compare(b)==0);
       
   606 	test(a.Compare(c)!=0);
       
   607 	b=_TL("ABC aBc");
       
   608 	test(a.CompareC(c)!=0);
       
   609 	test(a.CompareF(b)==0);
       
   610 	test(a.CompareF(c)!=0);
       
   611 
       
   612 	test.End();
       
   613 	}
       
   614 
       
   615 /**
       
   616 @SYMTestCaseID SYSLIB-EUSERHL-UT-4017
       
   617 @SYMTestCaseDesc Tests LString MatchX() methods
       
   618 @SYMTestPriority High
       
   619 @SYMTestActions Creates LString objects and uses the MatchX()
       
   620 				methods to compare string contents against other strings 
       
   621 				Verifies that MatchX methods work as expected
       
   622 @SYMTestExpectedResults LString MatchX() methods should compare string 
       
   623 				contents and return the index of the first match, 
       
   624 				or KErrNotFound if there is no match.
       
   625 @SYMREQ	10372
       
   626 */
       
   627 template <class T,class S,class DESTEMPLATE>
       
   628 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test9()
       
   629 // Matching (need to test explicit result as error KErrNotFound = KMaxTUint
       
   630 // 			 and so registers as TRUE. (test parameter is TUint) )
       
   631 	{
       
   632 	
       
   633 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4017"));
       
   634 	
       
   635 	test.Next(_L("By string"));
       
   636 	
       
   637 	T a(iMaxBufLength);
       
   638 	a=_TL("abc AbC");
       
   639 	test(a.Match(_TL("abc AbC"))==0);
       
   640 	test(a.MatchC(_TL("ABC aBc"))==0);
       
   641 	test(a.MatchF(_TL("ABC aBc"))==0);
       
   642 	test(a.Match(_TL("xyz"))==KErrNotFound);
       
   643 	test(a.MatchC(_TL("xyz"))==KErrNotFound);
       
   644 	test(a.MatchF(_TL("xyz"))==KErrNotFound);
       
   645 
       
   646 	test.Next(_L("By buffer"));
       
   647 	T b;
       
   648 	T c;
       
   649 	a=_TL("abc AbC");
       
   650 	b=_TL("abc AbC");
       
   651 	c=_TL("xyz");
       
   652 	test(a.Match(b)==0);
       
   653 	test(a.Match(c)==KErrNotFound);
       
   654 	b=_TL("ABC aBc");
       
   655 	test(a.MatchC(b)==0);
       
   656 	test(a.MatchC(c)==KErrNotFound);
       
   657 	test(a.MatchF(b)==0);
       
   658 	test(a.MatchF(c)==KErrNotFound);
       
   659 
       
   660 	test.Next(_L("Wildcards"));
       
   661 	a=_TL("abcxyz");
       
   662 	test(a.Match(_TL("abc*"))==0);
       
   663 	test(a.Match(_TL("abw*"))==KErrNotFound);
       
   664 	a=_TL("abcdefg");
       
   665 	test(a.Match(_TL("a*fg"))==0);
       
   666 	test(a.Match(_TL("a*f"))==KErrNotFound);
       
   667 	test(a.Match(_TL("abc*fgh"))==KErrNotFound);
       
   668 	a=_TL("abcdef");
       
   669 	test(a.Match(_TL("abc?ef"))==0);
       
   670 	test(a.Match(_TL("abc?xf"))==KErrNotFound);
       
   671 
       
   672 	a=_TL("a(01)");
       
   673 	test(a.Match(_TL("*(01)"))==1);
       
   674 	test(a.Match(_TL("?(01)"))==0);
       
   675 	test(a.Match(_TL("?(*)"))==0);
       
   676 	test(a.Match(_TL("?(**)"))==0);
       
   677 
       
   678 	test(a.Match(_TL("?(\?\?)"))==0);
       
   679 	test(a.Match(_TL("*(*)"))>=0);
       
   680 	test(a.Match(_TL("*(0?)"))>=0);
       
   681 	test(a.Match(_TL("a(\?\?)"))==0);
       
   682 	test(a.Match(_TL("*(\?\?)"))>=0);
       
   683 
       
   684 	test.Next(_L("wild cards with collated comparison"));
       
   685 	a = _TL("abcdefghijkl");
       
   686 	test(a.MatchC(_TL("abc*")) == 0);
       
   687 	test(a.MatchC(_TL("abc")) == KErrNotFound);
       
   688 	test(a.MatchC(_TL("xyz")) == KErrNotFound);
       
   689 	test(a.MatchC(_TL("*def")) == KErrNotFound);
       
   690 	test(a.MatchC(_TL("*def*")) == 3);
       
   691 	test(a.MatchC(_TL("*d?f*")) == 3);
       
   692 	test(a.MatchC(_TL("a*kl")) == 0);
       
   693 	test(a.MatchC(_TL("*e*?l")) == 4);
       
   694 	test(a.MatchC(_TL("abc*dEf*")) == 0);
       
   695 	
       
   696 	T candidate(_TL(""));
       
   697 	T search(_TL("**"));
       
   698 	
       
   699 	test(candidate.MatchC(search) == 0);
       
   700 	
       
   701 	candidate = _TL("");
       
   702 	search = _TL("*");
       
   703 	test(candidate.MatchC(search) == 0);
       
   704 	
       
   705 	candidate = _TL("abcd");
       
   706 	search = _TL("*abc*cd");
       
   707 	test(candidate.MatchC(search) == KErrNotFound);
       
   708    	
       
   709 	if (sizeof(S) == 2)
       
   710 		{
       
   711 		test.Next(_L("Unicode MatchC and FindC treat base+accent as equal to composed character"));
       
   712 		LString16 p = _L("te\x302te");
       
   713 		test(p.MatchC(_L("t\xeate")) == 0);
       
   714 		test(p.FindC(_L("t\xeate")) == 0);
       
   715 		}
       
   716 
       
   717 	test.End();
       
   718 	}
       
   719 
       
   720 
       
   721 /**
       
   722 @SYMTestCaseID SYSLIB-EUSERHL-UT-4018
       
   723 @SYMTestCaseDesc Tests LString Locate() methods
       
   724 @SYMTestPriority High
       
   725 @SYMTestActions Creates LString objects and uses the LocateX()
       
   726 				methods to search for a character within the LString
       
   727 				Verifies that LocateX() methods works as expected
       
   728 @SYMTestExpectedResults LString LocateX() method should return offset 
       
   729 				of the character position from the beginning of the data or 
       
   730 				KErrNotFound if no matching character can be found.
       
   731 @SYMREQ	10372
       
   732 */
       
   733 template <class T,class S,class DESTEMPLATE>
       
   734 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test10()
       
   735 // Locating
       
   736 	{
       
   737 	
       
   738 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4018"));
       
   739 	
       
   740 	T a(iMaxBufLength);
       
   741 	TChar b;
       
   742 
       
   743 	test.Next(_L("First Char"));
       
   744 	
       
   745 	b='a';
       
   746 	a=_TL("axaxa");
       
   747 	test(a.Locate(b)==0);
       
   748 	test(a.LocateF(b)==0);
       
   749 	test(a.LocateReverse(b)==4);
       
   750 	test(a.LocateReverseF(b)==4);
       
   751 
       
   752 	test.Next(_L("Middle Char"));
       
   753 	a=_TL("xaxa");
       
   754 	test(a.Locate(b)==1);
       
   755 	test(a.LocateF(b)==1);
       
   756 	a=_TL("axax");
       
   757 	test(a.LocateReverse(b)==2);
       
   758 	test(a.LocateReverseF(b)==2);
       
   759 
       
   760 	test.Next(_L("Last Char"));
       
   761 	a=_TL("xxa");
       
   762 	test(a.Locate(b)==2);
       
   763 	test(a.LocateF(b)==2);
       
   764 	a=_TL("axx");
       
   765 	test(a.LocateReverse(b)==0);
       
   766 	test(a.LocateReverseF(b)==0);
       
   767 
       
   768 	test.Next(_L("Test for failure of locate"));
       
   769 	a=_TL("xxx");
       
   770 	test(a.Locate(b)==KErrNotFound);
       
   771 	test(a.LocateF(b)==KErrNotFound);
       
   772 	test(a.LocateReverse(b)==KErrNotFound);
       
   773 	test(a.LocateReverseF(b)==KErrNotFound);
       
   774 
       
   775 	test.End();
       
   776 	}
       
   777 	
       
   778 	
       
   779 /**
       
   780 @SYMTestCaseID SYSLIB-EUSERHL-UT-4019
       
   781 @SYMTestCaseDesc Tests LString CopyX() methods
       
   782 @SYMTestPriority High
       
   783 @SYMTestActions Creates LString objects and uses the CopyX()
       
   784 				methods to copy data into the strings.
       
   785 				Verifies that the length and contents of the LString 
       
   786 				are as expefcted
       
   787 @SYMTestExpectedResults LString CopyX() methods should copy data into 
       
   788 				LString as expected
       
   789 @SYMREQ	10372
       
   790 */
       
   791 template <class T,class S,class DESTEMPLATE>
       
   792 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test11L()
       
   793 // Copying
       
   794 	{
       
   795 	
       
   796 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4019"));
       
   797 	
       
   798 	test.Next(_L("By String"));
       
   799 	
       
   800 	T a(iMaxBufLength);
       
   801 	T b(iMaxBufLength);
       
   802 		
       
   803 	a.CopyL(_TL("abc"));
       
   804 	test(a.Length()==3);
       
   805 	test(a==_TL("abc"));
       
   806 	a.CopyFL(_TL("abc"));
       
   807 	test(a.Length()==3);
       
   808 	b.CopyFL(_TL("ABC"));
       
   809 	test(a==b);
       
   810 	a.CopyLCL(_TL("AbC"));
       
   811 	test(a==_TL("abc"));
       
   812 	test(a.Length()==3);
       
   813 	a.CopyCL(_TL("abc"));
       
   814 	b.CopyCL(_TL("ABC"));
       
   815 	test(a==b);
       
   816 	test(a.Length()==3);
       
   817 	a.CopyCPL(_TL("abc"));
       
   818 	test(a==_TL("Abc"));
       
   819 	test(a.Length()==3);
       
   820 	a.CopyUCL(_TL("aBc"));
       
   821 	test(a==_TL("ABC"));
       
   822 	test(a.Length()==3);
       
   823 
       
   824 	test.Next(_L("By buffer"));
       
   825 	b=_TL("abc");
       
   826 	a.CopyL(b);
       
   827 	test(a==_TL("abc"));
       
   828 	test(a.Length()==3);
       
   829 	a=_TL("");
       
   830 	a.CopyFL(b);
       
   831 	b.CopyFL(_TL("ABC"));
       
   832 	test(a==b);
       
   833 	test(a.Length()==3);
       
   834 	a=_TL("");
       
   835 	b=_TL("AbC");
       
   836 	a.CopyLCL(b);
       
   837 	test(a==_TL("abc"));
       
   838 	test(a.Length()==3);
       
   839 	a=_TL("");
       
   840 	b=_TL("abC");
       
   841 	a.CopyCL(b);
       
   842 	b.CopyCL(_TL("ABC"));
       
   843 	test(a==b);
       
   844 	test(a.Length()==3);
       
   845 	a=_TL("");
       
   846 	b=_TL("abC");
       
   847 	a.CopyCPL(b);
       
   848 	test(a==_TL("Abc"));
       
   849 	test(a.Length()==3);
       
   850 	a=_TL("");
       
   851 	b=_TL("aBc");
       
   852 	a.CopyUCL(b);
       
   853 	test(a.Length()==3);
       
   854 	test(a==_TL("ABC"));
       
   855 
       
   856 	test.End();
       
   857 	}
       
   858 
       
   859 
       
   860 /**
       
   861 @SYMTestCaseID SYSLIB-EUSERHL-UT-4020
       
   862 @SYMTestCaseDesc Tests LString FindX() methods
       
   863 @SYMTestPriority High
       
   864 @SYMTestActions Creates LString objects and uses the FindX()
       
   865 				methods to find substrings.
       
   866 				Verifies that the index of the substring returned is as expected
       
   867 @SYMTestExpectedResults LString FindX() methods should return the index of the first 
       
   868 				character of the substring if it exists in the LString otherwise
       
   869 				return KErrNotFound.
       
   870 @SYMREQ	10372
       
   871 */
       
   872 template <class T,class S,class DESTEMPLATE>
       
   873 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test12()
       
   874 // Finding
       
   875 	{
       
   876 	
       
   877 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4020"));
       
   878 	
       
   879 	test.Next(_L("By String"));
       
   880 	
       
   881 	T a(iMaxBufLength);
       
   882 	T b(iMaxBufLength);
       
   883 	
       
   884 	a=_TL("abccef");
       
   885 	test(a.Find(_TL(""))==0);
       
   886 	test(a.Find(_TL("abc"))==0);
       
   887 	test(a.Find(_TL("cce"))==2);
       
   888 	test(a.Find(_TL("cef"))==3);
       
   889 	test(a.Find(_TL("efg"))==KErrNotFound);
       
   890 	test(a.Find(_TL("xxx"))==KErrNotFound);
       
   891 	test(a.FindF(_TL(""))==0);
       
   892 	test(a.FindF(_TL("AbC"))==0);
       
   893 	test(a.FindF(_TL("CcE"))==2);
       
   894 	test(a.FindF(_TL("CeF"))==3);
       
   895 	test(a.FindF(_TL("efg"))==KErrNotFound);
       
   896 	test(a.FindF(_TL("xxx"))==KErrNotFound);
       
   897 	test(a.FindC(_TL(""))==0);
       
   898 	test(a.FindC(_TL("aBc"))==0);
       
   899 	test(a.FindC(_TL("cce"))==2);
       
   900 	test(a.FindC(_TL("cEf"))==3);
       
   901 	test(a.FindC(_TL("efg"))==KErrNotFound);
       
   902 	test(a.FindC(_TL("xxx"))==KErrNotFound);
       
   903 
       
   904 	test.Next(_L("By buffer"));
       
   905 	test(a.Find(b)==0);
       
   906 	test(a.FindF(b)==0);
       
   907 	test(a.FindC(b)==0);
       
   908 	b=_TL("xxx");
       
   909 	test(a.Find(b)==KErrNotFound);
       
   910 	test(a.FindF(b)==KErrNotFound);
       
   911 	test(a.FindC(b)==KErrNotFound);
       
   912 	b=_TL("efg");
       
   913 	test(a.Find(b)==KErrNotFound);
       
   914 	test(a.FindF(b)==KErrNotFound);
       
   915 	test(a.FindC(b)==KErrNotFound);
       
   916 	b=_TL("abc");
       
   917 	test(a.Find(b)==0);
       
   918 	b=_TL("cce");
       
   919 	test(a.Find(b)==2);
       
   920 	b=_TL("cef");
       
   921 	test(a.Find(b)==3);
       
   922 	b=_TL("AbC");
       
   923 	test(a.FindF(b)==0);
       
   924 	b=_TL("CcE");
       
   925 	test(a.FindF(b)==2);
       
   926 	b=_TL("CeF");
       
   927 	test(a.FindF(b)==3);
       
   928 	b=_TL("aBc");
       
   929 	test(a.FindC(b)==0);
       
   930 	b=_TL("cCe");
       
   931 	test(a.FindC(b)==2);
       
   932 	b=_TL("cEf");
       
   933 	test(a.FindC(b)==3);
       
   934 
       
   935 	test.End();
       
   936 	}
       
   937 
       
   938 
       
   939 /**
       
   940 @SYMTestCaseID SYSLIB-EUSERHL-UT-4021
       
   941 @SYMTestCaseDesc Tests LString modification methods
       
   942 @SYMTestPriority High
       
   943 @SYMTestActions Creates LString objects and uses the Repeat(),
       
   944 				TrimX(), InsertL(), Delete(), Left(), Right() and Mid() methods
       
   945 				to modify the string.
       
   946 				Verifies that the LString is modified as expected
       
   947 @SYMTestExpectedResults LString modification methods should modify the LString 
       
   948 				data as expected.
       
   949 @SYMREQ	10372
       
   950 */
       
   951 template <class T,class S,class DESTEMPLATE>
       
   952 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test13L()
       
   953 // Basic like ops
       
   954 	{
       
   955 	
       
   956 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4021"));
       
   957 	
       
   958 	test.Next(_L("Repeat, trim, insert and delete"));
       
   959 	
       
   960 	T a(iMaxBufLength);
       
   961 	T b(iMaxBufLength);
       
   962 	TInt max=a.MaxLength(); 
       
   963 	b=_TL("abc");
       
   964 	a.Repeat(_TL("abc"));
       
   965 	test(a==_TL(""));
       
   966 	a.Repeat(b);
       
   967 	test(a==_TL(""));
       
   968 	for (TInt j=1;j<max;j++) // ?? Cannot SetLength = MaxLength
       
   969 		{
       
   970 		a.SetLengthL(j);
       
   971 		a.Repeat(_TL("abc"));
       
   972         TInt i;
       
   973 		for (i=0;i<j;i++)
       
   974 			test(a[i]==b[i%3]);
       
   975 		a=_TL("");
       
   976 		a.SetLengthL(j);
       
   977 		a.Repeat(b);
       
   978 		for (i=0;i<j;i++)
       
   979 			test(a[i]==b[i%3]);
       
   980 		a=_TL("");
       
   981 		}
       
   982 	a=_TL("\t\n  ab \t\n ");
       
   983 	a.TrimLeft();
       
   984 	test(a==_TL("ab \t\n "));
       
   985 	test(a.Length()==6);
       
   986 	a=_TL("\t\n  ab \t\n ");
       
   987 	a.TrimRight();
       
   988 	test(a==_TL("\t\n  ab"));
       
   989 	test(a.Length()==6);
       
   990 	a=_TL(" \t\n ab \t \n");
       
   991 	a.Trim();
       
   992 	test(a==_TL("ab"));
       
   993 	a.Trim();
       
   994 	test(a==_TL("ab"));
       
   995 	a=_TL("abc");
       
   996 	b=_TL("123");
       
   997 	a.InsertL(1,b);
       
   998 	test(a==_TL("a123bc"));
       
   999 	test(a.Length()==6);
       
  1000 	b=_TL("");
       
  1001 	a.InsertL(4,b);
       
  1002 	test(a==_TL("a123bc"));
       
  1003 	test(a.Length()==6);
       
  1004 	a.InsertL(0,b);
       
  1005 	test(a==_TL("a123bc"));
       
  1006 	test(a.Length()==6);
       
  1007 	a.Delete(1,3);
       
  1008 	test(a==_TL("abc"));
       
  1009 	test(a.Length()==3);
       
  1010 	a.Delete(0,3);
       
  1011 	test(a==_TL(""));
       
  1012 	test(a.Length()==0);
       
  1013 
       
  1014 	test.Next(_L("TrimAll"));
       
  1015 	a=_TL("");
       
  1016 	a.TrimAll();
       
  1017 	test(a==_TL(""));
       
  1018 	a=_TL(" ");
       
  1019 	a.TrimAll();
       
  1020 	test(a==_TL(""));
       
  1021 	a=_TL("   ");
       
  1022 	a.TrimAll();
       
  1023 	test(a==_TL(""));
       
  1024 	a=_TL("    ab cd  ef    g");
       
  1025 	a.TrimAll();
       
  1026 	test(a==_TL("ab cd ef g"));
       
  1027 	a=_TL("abcdef");
       
  1028 	a.TrimAll();
       
  1029 	test(a==_TL("abcdef"));
       
  1030 	a=_TL("a  b\t cd\t\tef");
       
  1031 	a.TrimAll();
       
  1032 	test(a==_TL("a b\tcd\tef"));
       
  1033 	a=_TL("abcdef \t ghijk");
       
  1034 	a.TrimAll();
       
  1035 	test(a==_TL("abcdef ghijk"));
       
  1036 	a=_TL("abcdef g");
       
  1037 	a.TrimAll();
       
  1038 	test(a==_TL("abcdef g"));
       
  1039 	a=_TL("ab  cd  ef  gh  ij");
       
  1040 	a.TrimAll();
       
  1041 	test(a==_TL("ab cd ef gh ij"));
       
  1042 	a=_TL("a        b          c     defg h     i  jk l     mno pqr stu  vw   xyz");
       
  1043 	a.TrimAll();
       
  1044 	test(a==_TL("a b c defg h i jk l mno pqr stu vw xyz"));
       
  1045 
       
  1046 	test.Next(_L("Right, Left and Mid"));
       
  1047 	a=_TL("abcdef");
       
  1048 	b = a.Left(3);
       
  1049 	test(b==_TL("abc"));
       
  1050 	test(b.Length()==3);
       
  1051 	b = a.Right(3);
       
  1052 	test(b==_TL("def"));
       
  1053 	b = a.Mid(2);
       
  1054 	test(b==_TL("cdef"));
       
  1055 	test(b.Length()==4);
       
  1056 	b = a.Left(2);
       
  1057 	test(b==_TL("ab"));
       
  1058 	test(b.Length()==2);
       
  1059 	b = a.Right(2);
       
  1060 	test(b==_TL("ef"));
       
  1061 	b = a.Mid(2,1);
       
  1062 	test(b==_TL("c"));
       
  1063 	test(b.Length()==1);
       
  1064 	b = a.Left(6);
       
  1065 	test(b==_TL("abcdef"));
       
  1066 	test(b.Length()==6);
       
  1067 	b=_TL("");
       
  1068 	b.SetLengthL(4);
       
  1069 	b = a.Right(6);
       
  1070 	test(b==_TL("abcdef"));
       
  1071 	test(b.Length()==6);
       
  1072 	a = a.Left(6);
       
  1073 	test(a==_TL("abcdef"));
       
  1074 	b=_TL("");
       
  1075 	b = a.Mid(0,6);
       
  1076 	test(b==_TL("abcdef")); 
       
  1077 	test.End();
       
  1078 	}
       
  1079 
       
  1080 /**
       
  1081 @SYMTestCaseID SYSLIB-EUSERHL-UT-4022
       
  1082 @SYMTestCaseDesc Tests LString formatting methods
       
  1083 @SYMTestPriority High
       
  1084 @SYMTestActions Creates LString objects and uses the LString formatting methods
       
  1085 				to format the string.
       
  1086 				Verifies that the LString is formatted as expected
       
  1087 @SYMTestExpectedResults LString formatting methods should fromta the LString as expected
       
  1088 @SYMREQ	10372
       
  1089 */
       
  1090 template <class T,class S,class DESTEMPLATE>
       
  1091 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test14L()
       
  1092 // Formating operations
       
  1093 	{
       
  1094 	
       
  1095 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4022"));
       
  1096 	
       
  1097 	test.Next(_L("Justify"));
       
  1098 	//---------------------------Apepend+Justify-----------------------------------
       
  1099 	T a(1);
       
  1100 	T b(1);
       
  1101 	T d(1);
       
  1102 
       
  1103 	TInt aWidth;
       
  1104 	TChar c;
       
  1105 	a=_TL("wxyz");
       
  1106 	b=_TL("abc");
       
  1107 	d=_TL("linearisation");
       
  1108 	const S* pD=_TS("299792458");
       
  1109 	c='x';
       
  1110 	aWidth=KDefaultJustifyWidth; // Left justified, Default width
       
  1111 	a.JustifyL(b,aWidth,ELeft,c);
       
  1112 	test(a==b);
       
  1113 	test(a.Length()==3);
       
  1114 	a.AppendJustifyL(b,aWidth,ELeft,c);
       
  1115 	test(a==_TL("abcabc"));
       
  1116 	test(a.Length()==6);
       
  1117 	aWidth=1;	// Width < String length
       
  1118 	a.JustifyL(b,aWidth,ELeft,c);
       
  1119 	test(a==_TL("a"));
       
  1120 	test(a.Length()==1);
       
  1121 	a.AppendJustifyL(b,aWidth,ELeft,c);
       
  1122 	test(a==_TL("aa"));
       
  1123 	test(a.Length()==2);
       
  1124 	aWidth=5; // Width > String length
       
  1125 	a.JustifyL(b,aWidth,ELeft,c);
       
  1126 	test(a==_TL("abcxx"));
       
  1127 	test(a.Length()==5);
       
  1128 	a.AppendJustifyL(b,aWidth,ELeft,c);
       
  1129 	test(a==_TL("abcxxabcxx"));
       
  1130 	test(a.Length()==10);
       
  1131 
       
  1132 	aWidth=KDefaultJustifyWidth; // Right justified, Default width
       
  1133 	a.JustifyL(b,aWidth,ERight,c);
       
  1134 	test(a==b);
       
  1135 	test(a.Length()==3);
       
  1136 	a.AppendJustifyL(b,aWidth,ERight,c);
       
  1137 	test(a==_TL("abcabc"));
       
  1138 	test(a.Length()==6);
       
  1139 
       
  1140 	aWidth=1; // Right justified, Width < String length
       
  1141 	a.JustifyL(b,aWidth,ERight,c);
       
  1142 	test(a==_TL("a"));
       
  1143 	test(a.Length()==1);
       
  1144 	a.AppendJustifyL(b,aWidth,ERight,c);
       
  1145 	test(a==_TL("aa"));
       
  1146 	test(a.Length()==2);
       
  1147 
       
  1148 	aWidth=5; // Right justified, width > String length
       
  1149 	a.JustifyL(b,aWidth,ERight,c);
       
  1150 	test(a==_TL("xxabc"));
       
  1151 	test(a.Length()==5);
       
  1152 	a.AppendJustifyL(b,aWidth,ERight,c);
       
  1153 	test(a==_TL("xxabcxxabc"));
       
  1154 	test(a.Length()==10);
       
  1155 
       
  1156 	aWidth=KDefaultJustifyWidth; // Center justified, Default width
       
  1157 	a.JustifyL(b,aWidth,ECenter,c);
       
  1158 	test(a==b);
       
  1159 	test(a.Length()==3);
       
  1160 	a.AppendJustifyL(b,aWidth,ECenter,c);
       
  1161 	test(a==_TL("abcabc"));
       
  1162 	test(a.Length()==6);
       
  1163 
       
  1164 	aWidth=1; // Centre justified, width < String length
       
  1165 	a.JustifyL(b,aWidth,ECenter,c);
       
  1166 	test(a==_TL("a"));
       
  1167 	test(a.Length()==1);
       
  1168 	a.AppendJustifyL(b,aWidth,ECenter,c);
       
  1169 	test(a==_TL("aa"));
       
  1170 	test(a.Length()==2);
       
  1171 
       
  1172 	aWidth=5; // Centre justified, width > String length
       
  1173 	a.JustifyL(b,aWidth,ECenter,c);
       
  1174 	test(a==_TL("xabcx"));
       
  1175 	test(a.Length()==5);
       
  1176 	a.AppendJustifyL(b,aWidth,ECenter,c);
       
  1177 	test(a==_TL("xabcxxabcx"));
       
  1178 	test(a.Length()==10);
       
  1179 
       
  1180 	//----------------------Num----------------------------------------------------
       
  1181 	test.Next(_L("Num"));
       
  1182 	TInt j=-2147483647-1; 
       
  1183 	a.NumL(j);
       
  1184 	test(a==_TL("-2147483648"));
       
  1185 	test(a.Length()==11);
       
  1186 	TUint i=2147483648u;
       
  1187 	a.NumL(i);
       
  1188 	test(a==_TL("2147483648"));
       
  1189 	test(a.Length()==10);
       
  1190 	if (a.MaxLength()>31)
       
  1191 		{
       
  1192 		a.NumL(i,EBinary);
       
  1193 		test(a==_TL("10000000000000000000000000000000"));
       
  1194 		test(a.Length()==32);
       
  1195 		a=_TL("");
       
  1196 		a.NumUCL(i,EBinary);
       
  1197 		test(a==_TL("10000000000000000000000000000000"));
       
  1198 		test(a.Length()==32);
       
  1199 		}
       
  1200 	i=31;
       
  1201 	a.NumL(i,EBinary);
       
  1202 	test(a==_TL("11111"));
       
  1203 	test(a.Length()==5);
       
  1204 	a=_TL("");
       
  1205 	a.NumUCL(i,EBinary);
       
  1206 	test(a==_TL("11111"));
       
  1207 	test(a.Length()==5);
       
  1208 	i=2147483648u;
       
  1209 	a.NumL(i,EOctal);
       
  1210 	test(a==_TL("20000000000"));
       
  1211 	test(a.Length()==11);
       
  1212 	a=_TL("");
       
  1213 	a.NumUCL(i,EOctal);
       
  1214 	test(a==_TL("20000000000"));
       
  1215 	test(a.Length()==11);
       
  1216 	a.NumL(i,EDecimal);
       
  1217 	test(a==_TL("2147483648"));
       
  1218 	test(a.Length()==10);
       
  1219 	a=_TL("");
       
  1220 	a.NumUCL(i,EDecimal);
       
  1221 	test(a==_TL("2147483648"));
       
  1222 	test(a.Length()==10);
       
  1223 	a.NumL(i,EHex);
       
  1224 	test(a==_TL("80000000"));
       
  1225 	test(a.Length()==8);
       
  1226 	a=_TL("");
       
  1227 	a.NumUCL(i,EHex);
       
  1228 	test(a==_TL("80000000"));
       
  1229 	test(a.Length()==8);
       
  1230 	i=0;
       
  1231 	a.NumL(i);
       
  1232 	test(a==_TL("0"));
       
  1233 	test(a.Length()==1);
       
  1234 	a=_TL("abc");
       
  1235 	a.NumL(i,EBinary);
       
  1236 	test(a==_TL("0"));
       
  1237 	test(a.Length()==1);
       
  1238 	a=_TL("abc");
       
  1239 	a.NumUCL(i,EBinary);
       
  1240 	test(a==_TL("0"));
       
  1241 	test(a.Length()==1);
       
  1242 	a=_TL("abc");
       
  1243 	a.NumL(i,EOctal);
       
  1244 	test(a==_TL("0"));
       
  1245 	test(a.Length()==1);
       
  1246 	a=_TL("");
       
  1247 	a.NumUCL(i,EOctal);
       
  1248 	test(a==_TL("0"));
       
  1249 	test(a.Length()==1);
       
  1250 	a=_TL("abc");
       
  1251 	a.NumL(i,EDecimal);
       
  1252 	test(a==_TL("0"));
       
  1253 	test(a.Length()==1);
       
  1254 	a=_TL("");
       
  1255 	a.NumUCL(i,EDecimal);
       
  1256 	test(a==_TL("0"));
       
  1257 	test(a.Length()==1);
       
  1258 	a=_TL("abc");
       
  1259 	a.NumL(i,EHex);
       
  1260 	test(a==_TL("0"));
       
  1261 	test(a.Length()==1);
       
  1262 	a=_TL("");
       
  1263 	a.NumUCL(i,EHex);
       
  1264 	test(a==_TL("0"));
       
  1265 	test(a.Length()==1);
       
  1266 
       
  1267 	//	TInt i=a.Num(6.2,format); NOT IMPLEMENTED
       
  1268 	//----------------------AppendNum----------------------------------------------------
       
  1269 	test.Next(_L("AppendNum"));
       
  1270 	a=_TL("0");
       
  1271 	a.AppendNumL(j);
       
  1272 	test(a==_TL("0-2147483648"));
       
  1273 	test(a.Length()==12);
       
  1274 
       
  1275 	a=_TL("abc");
       
  1276 	i=4294967295u;
       
  1277 	a.AppendNumL(i);
       
  1278 	test(a==_TL("abc4294967295"));
       
  1279 	test(a.Length()==13);
       
  1280 
       
  1281 	j=2147483647;
       
  1282 	a=_TL("abc");
       
  1283 	a.AppendNumL(j);
       
  1284 	test(a==_TL("abc2147483647"));
       
  1285 	test(a.Length()==13);
       
  1286 
       
  1287 	a=_TL("a");
       
  1288 	i=180150000;
       
  1289 	if (a.MaxLength()>28)
       
  1290 		{
       
  1291 		a.AppendNumL(i,EBinary);
       
  1292 		test(a==_TL("a1010101111001101111011110000"));
       
  1293 		test(a.Length()==29);
       
  1294 		}
       
  1295 	a=_TL("a");
       
  1296 	a.AppendNumL(15,EBinary);
       
  1297 	test(a==_TL("a1111"));
       
  1298 	test(a.Length()==5);
       
  1299 
       
  1300 	a=_TL("a");
       
  1301 	a.AppendNumL(i,EDecimal);
       
  1302 	test(a==_TL("a180150000"));
       
  1303 	test(a.Length()==10);
       
  1304 
       
  1305 	a=_TL("a");
       
  1306 	a.AppendNumL(i,EOctal);
       
  1307 	test(a==_TL("a1257157360"));
       
  1308 	test(a.Length()==11);
       
  1309 
       
  1310 	a=_TL("a");
       
  1311 	a.AppendNumUCL(i,EHex);
       
  1312 	test(a==_TL("aABCDEF0"));
       
  1313 	test(a.Length()==8);
       
  1314 
       
  1315 	
       
  1316 	a=_TL("a");
       
  1317 	a.AppendNumFixedWidthL(i,EHex,3);
       
  1318 	test(a==_TL("aabc"));
       
  1319 	test(a.Length()==4);
       
  1320 	
       
  1321 	a=_TL("a");
       
  1322 	a.AppendNumFixedWidthUCL(i,EHex,4);
       
  1323 	test(a==_TL("aABCD"));
       
  1324 	test(a.Length()==5);
       
  1325 	
       
  1326 
       
  1327 	//----------------------Format----------------------------------------------------
       
  1328 	test.Next(_L("Format"));
       
  1329 	a=_TL("");
       
  1330 	b=_TL("cde");
       
  1331 	a.FormatL(_TL("%S"),&b);
       
  1332 	test(a==b);
       
  1333 	test(a.Length()==3);
       
  1334 
       
  1335     DESTEMPLATE xyz=_TL("xyzwpq");
       
  1336 	a.FormatL(_TL("%S"),&xyz);
       
  1337 	test(a==_TL("xyzwpq"));
       
  1338 	test(a.Length()==6);
       
  1339 
       
  1340     DESTEMPLATE cde=_TL("cde");
       
  1341 	a.FormatL(_TL("ab %-x5S"),&cde);
       
  1342 	test(a==_TL("ab cdexx"));
       
  1343 	test(a.Length()==8);
       
  1344 
       
  1345 	a.FormatL(_TL("ab %=x5S"),&cde);
       
  1346 	test(a==_TL("ab xcdex"));
       
  1347 	test(a.Length()==8);
       
  1348 
       
  1349 	a.FormatL(_TL("ab %+x5S"),&cde);
       
  1350 	test(a==_TL("ab xxcde"));
       
  1351 	test(a.Length()==8);
       
  1352 
       
  1353 	a.FormatL(_TL("ab %5S"),&cde);
       
  1354 	test(a==_TL("ab   cde"));
       
  1355 	test(a.Length()==8);
       
  1356 
       
  1357 	a.FormatL(_TL("ab %-**S"),'x',5,&cde);
       
  1358 	test(a==_TL("ab cdexx"));
       
  1359 	test(a.Length()==8);
       
  1360 
       
  1361 	a.FormatL(_TL("ab %*S"),5,&cde);
       
  1362 	test(a==_TL("ab   cde"));
       
  1363 	test(a.Length()==8);
       
  1364 
       
  1365 	a=_TL("xyz");
       
  1366 	a.FormatL(_TL("ab %-x5S"),&b);
       
  1367 	test(a==_TL("ab cdexx"));
       
  1368 	test(a.Length()==8);
       
  1369 
       
  1370 	a=_TL("xyz");
       
  1371 	a.FormatL(_TL("ab %-**S"),'x',5,&b);
       
  1372 	test(a==_TL("ab cdexx"));
       
  1373 	test(a.Length()==8);
       
  1374 
       
  1375 	a=_TL("xyz");
       
  1376 	a.FormatL(_TL("ab %*S"),5,&b);
       
  1377 	test(a==_TL("ab   cde"));
       
  1378 	test(a.Length()==8);
       
  1379 
       
  1380 	DESTEMPLATE fred=_TL("fred");
       
  1381 	a.FormatL(_TL("%+0*S"),10,&fred);
       
  1382 	test(a==_TL("000000fred"));
       
  1383 	test(a.Length()==10);
       
  1384 
       
  1385 	a.FormatL(_TL("%-0*S"),7,&fred);
       
  1386 	test(a==_TL("fred000"));
       
  1387 	test(a.Length()==7);
       
  1388 
       
  1389 	a.FormatL(_TL("%0*S"),11,&fred);
       
  1390 	test(a==_TL("0000000fred"));
       
  1391 	test(a.Length()==11);
       
  1392 
       
  1393 	a.FormatL(_TL("c=%s"),pD);
       
  1394 	TESTEQ(a,_TL("c=299792458"));
       
  1395 
       
  1396 	a.FormatL(_TL("c=%10.6s"),pD);
       
  1397 	test(a==_TL("c=    299792"));
       
  1398 
       
  1399 	a.FormatL(_TL("c=%*.*s"),5,4,pD);
       
  1400 	test(a==_TL("c= 2997"));
       
  1401 
       
  1402 	a.FormatL(_TL("%S"),&d);
       
  1403 	test(a==_TL("linearisation"));
       
  1404 
       
  1405 	a.FormatL(_TL("%10.6S"),&d);
       
  1406 	test(a==_TL("    linear"));
       
  1407 
       
  1408 	a.FormatL(_TL("%*.*S"),5,4,&d);
       
  1409 	test(a==_TL(" line"));
       
  1410 
       
  1411 	a.FormatL(_TL("%*.*Sed"),10,8,&d);
       
  1412 	test(a==_TL("  linearised"));
       
  1413 
       
  1414 	a.FormatL(_TL("%*.*S"),14,20,&d);
       
  1415 	test(a==_TL(" linearisation"));
       
  1416 
       
  1417 	a.FormatL(_TL("ab %-,5b"),7);
       
  1418 	test(a==_TL("ab 111,,"));
       
  1419 	test(a.Length()==8);
       
  1420 
       
  1421 	a.FormatL(_TL("ab %=,5O"),31);
       
  1422 	test(a==_TL("ab ,37,,"));
       
  1423 	test(a.Length()==8);
       
  1424 
       
  1425 	a.FormatL(_TL("ab %+xlx"),TInt64(171));
       
  1426 	test(a==_TL("ab ab"));
       
  1427 	test(a.Length()==5);
       
  1428 
       
  1429 	a.FormatL(_TL("ab %+xlX %+xlx"),TInt64(171),TInt64(171));
       
  1430 	TESTEQ(a,_TL("ab AB ab"));
       
  1431 	test(a.Length()==8);
       
  1432 
       
  1433 	a.FormatL(_TL("ab %lu"),MAKE_TINT64((TUint)(KMinTInt),0));
       
  1434 	test(a==_TL("ab 9223372036854775808"));
       
  1435 	test(a.Length()==22);
       
  1436 
       
  1437 	a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),1));
       
  1438 	test(a==_TL("ab -9223372036854775807"));
       
  1439 	test(a.Length()==23);
       
  1440 
       
  1441 	a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),0));
       
  1442 	test(a==_TL("ab -9223372036854775808"));
       
  1443 	test(a.Length()==23);
       
  1444 
       
  1445 	a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
       
  1446 	test(a==_TL("ab 9223372036854775807"));
       
  1447 	test(a.Length()==22);
       
  1448 
       
  1449 	a.FormatL(_TL("ab %ld"),MAKE_TINT64(KMaxTUint,KMaxTUint));
       
  1450 	test(a==_TL("ab -1"));
       
  1451 	test(a.Length()==5);
       
  1452 
       
  1453 	a.FormatL(_TL("ab %lu"),MAKE_TINT64(KMaxTUint,KMaxTUint));
       
  1454 	test(a==_TL("ab 18446744073709551615"));
       
  1455 	test(a.Length()==23);
       
  1456 
       
  1457 	a.FormatL(_TL("ab %ld"),TInt64(0));
       
  1458 	test(a==_TL("ab 0"));
       
  1459 	test(a.Length()==4);
       
  1460 
       
  1461 	a.FormatL(_TL("ab %lb"),TInt64(0));
       
  1462 	test(a==_TL("ab 0"));
       
  1463 	test(a.Length()==4);
       
  1464 
       
  1465 	a.FormatL(_TL("ab %lx"),TInt64(0));
       
  1466 	test(a==_TL("ab 0"));
       
  1467 	test(a.Length()==4);
       
  1468 
       
  1469 	a.FormatL(_TL("ab %lo"),TInt64(0));
       
  1470 	test(a==_TL("ab 0"));
       
  1471 	test(a.Length()==4);
       
  1472 
       
  1473 	a.FormatL(_TL("ab %lu"),TInt64(0));
       
  1474 	test(a==_TL("ab 0"));
       
  1475 	test(a.Length()==4);
       
  1476 
       
  1477 	a.FormatL(_TL("ab %lb"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
       
  1478 	test(a==_TL("ab 111111111111111111111111111111111111111111111111111111111111111"));
       
  1479 	test(a.Length()==66);
       
  1480 
       
  1481 	a.FormatL(_TL("ab %lb"),MAKE_TINT64(KMaxTUint,KMaxTUint));
       
  1482 	test(a==_TL("ab 1111111111111111111111111111111111111111111111111111111111111111"));
       
  1483 	test(a.Length()==67);
       
  1484 
       
  1485 	a.FormatL(_TL("ab %lx"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
       
  1486 	test(a==_TL("ab 7fffffffffffffff"));
       
  1487 	test(a.Length()==19);
       
  1488 
       
  1489 	a.FormatL(_TL("ab %lx"),MAKE_TINT64(KMaxTUint,KMaxTUint));
       
  1490 	test(a==_TL("ab ffffffffffffffff"));
       
  1491 	test(a.Length()==19);
       
  1492 
       
  1493 	a.FormatL(_TL("ab %lo"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
       
  1494 	test(a==_TL("ab 777777777777777777777"));
       
  1495 	test(a.Length()==24);
       
  1496 
       
  1497 	// tests which excercise any 8 byte alignment requirement on 64bit integers
       
  1498 	a.FormatL(_TL("%li%S"),MAKE_TINT64(1,2),&fred);
       
  1499 	test(a==_TL("4294967298fred"));
       
  1500 
       
  1501 	a.FormatL(_TL("%S%li%S"),&fred,MAKE_TINT64(1,2),&fred);
       
  1502 	test(a==_TL("fred4294967298fred"));
       
  1503 
       
  1504 	a.FormatL(_TL("%lu%S"),MAKE_TINT64(1,2),&fred);
       
  1505 	test(a==_TL("4294967298fred"));
       
  1506 
       
  1507 	a.FormatL(_TL("%S%lu%S"),&fred,MAKE_TINT64(1,2),&fred);
       
  1508 	test(a==_TL("fred4294967298fred"));
       
  1509 
       
  1510 	a.FormatL(_TL("ab %U"),233);
       
  1511 	test(a==_TL("ab 233"));
       
  1512 	test(a.Length()==6);
       
  1513 
       
  1514 	a.FormatL(_TL("ab %*d"),5,-131);
       
  1515 	test(a==_TL("ab  -131"));
       
  1516 	test(a.Length()==8);
       
  1517 
       
  1518 	a.FormatL(_TL("ab%c"),'x');
       
  1519 	test(a==_TL("abx"));
       
  1520 	test(a.Length()==3);
       
  1521 
       
  1522 	a.FormatL(_TL("%W"),-131);
       
  1523 	test(*(TInt32*)a.Ptr()==-131);
       
  1524 
       
  1525 	a.FormatL(_TL("%M"),-131);
       
  1526 	test(*(TInt32*)a.Ptr()==2113929215);
       
  1527 
       
  1528 	a.FormatL(_TL("%w"),-131);
       
  1529 	test(*(TInt16*)a.Ptr()==-131);
       
  1530 
       
  1531 	a.FormatL(_TL("%m"),-131);
       
  1532 	test(*(TInt16*)a.Ptr()==32255);
       
  1533 
       
  1534 	//----------------------AppendFormat----------------------------------------------------
       
  1535 	a=_TL("xyz");
       
  1536 	a.AppendFormatL(_TL("ab %+xlx"),TInt64(171));
       
  1537 	test(a==_TL("xyzab ab"));
       
  1538 	test(a.Length()==8);
       
  1539 
       
  1540 	a=_TL("xyz");
       
  1541 	a.AppendFormatL(_TL("ab %5S"),&b);
       
  1542 	test(a==_TL("xyzab   cde"));
       
  1543 	test(a.Length()==11);
       
  1544 
       
  1545 	a=_TL("xyz");
       
  1546 	a.AppendFormatL(_TL("%W"),-131);
       
  1547 //	test(*(TInt32*)(a.Ptr()+3)==-131); // Alignment-safe version:
       
  1548     TInt val;
       
  1549     Mem::Copy(&val,&a[3],4);
       
  1550 	test(val==-131);
       
  1551 
       
  1552 // Cannot do this on GCCE or ARMv5 because of 
       
  1553 // "Cannot pass objects of non-POD type through '...'. 
       
  1554 // Call will abort at runtime".
       
  1555 
       
  1556 #ifdef __WINSCW__
       
  1557 	const TAny* const zeroTerminatedString=(sizeof(S)==2)? (const TAny*)_S16(":-)E"): (const TAny*)_S8(":-)E");
       
  1558 	const TInt dummyParameter=0;
       
  1559 	b=_TL("ebdb");
       
  1560 	Test14_ReorderedParameterFormattingL(dummyParameter, 0x20ac, 11, 3, 13.89543, zeroTerminatedString, '!', TInt64(199), 2, &b, 6, 30005, TRealX(0.125), 0x8bdd);
       
  1561 #endif
       
  1562 
       
  1563 	test.End();
       
  1564 	}
       
  1565 
       
  1566 /**
       
  1567 @SYMTestCaseID SYSLIB-EUSERHL-UT-4024
       
  1568 @SYMTestCaseDesc Tests LString leaving variant FormatListL() method
       
  1569 @SYMTestPriority High
       
  1570 @SYMTestActions Creates LString objects and uses the LString FormatListL() method
       
  1571 				to format the string.
       
  1572 				Verifies that the LString is formatted as expected
       
  1573 @SYMTestExpectedResults LString FormatListL() method should work as expected
       
  1574 @SYMREQ	10372
       
  1575 */
       
  1576 template <class T,class S,class DESTEMPLATE>
       
  1577 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test14_ReorderedParameterFormattingL(TInt aDummyParameter, ...)
       
  1578 	{
       
  1579 	
       
  1580 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4024"));
       
  1581 	
       
  1582 	VA_LIST parameterList;
       
  1583 	T generated(1);
       
  1584 	T expected(1);
       
  1585 
       
  1586 	VA_START(parameterList, aDummyParameter);
       
  1587 	generated.FormatListL(_TL("\t%-**.*fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%.3Fyyyyyyy%c"), parameterList);
       
  1588 	test(generated.Length()==61);
       
  1589 	expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeeeebrrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1590 	test(generated.Left(generated.Length()-1)==expected);
       
  1591 	test(generated[generated.Length()-1]==(S)0x8bdd);
       
  1592 
       
  1593 	VA_START(parameterList, aDummyParameter);
       
  1594 	generated.FormatListL(_TL("\t%$1$-**.*fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%$6$.3Fyyyyyyy%c"), parameterList);
       
  1595 	test(generated.Length()==61);
       
  1596 	expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeeeebrrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1597 	test(generated.Left(generated.Length()-1)==expected);
       
  1598 	test(generated[generated.Length()-1]==(S)0x8bdd);
       
  1599 
       
  1600 	VA_START(parameterList, aDummyParameter);
       
  1601 	generated.FormatListL(_TL("\t%$6$.3Fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%$1$-**.*fyyyyyyy%c"), parameterList);
       
  1602 	test(generated.Length()==61);
       
  1603 	expected.FormatL(_TL("\t0.125qq:-)www!!199eeeeebrrrrr007535tttttt13.895%c%c%c%c%cyyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1604 	test(generated.Left(generated.Length()-1)==expected);
       
  1605 	test(generated[generated.Length()-1]==(S)0x8bdd);
       
  1606 
       
  1607 	VA_START(parameterList, aDummyParameter);
       
  1608 	generated.FormatListL(_TL("\t%-**.*fqq%.3swww%$5$0*xeeee%.*Srrrrr%$3$+*5Ldtttttt%.3Fyyyyyyy%c"), parameterList);
       
  1609 	test(generated.Length()==61);
       
  1610 	expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www007535eeeeebrrrrr!!199tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1611 	test(generated.Left(generated.Length()-1)==expected);
       
  1612 	test(generated[generated.Length()-1]==(S)0x8bdd);
       
  1613 
       
  1614 	VA_START(parameterList, aDummyParameter);
       
  1615 	generated.FormatListL(_TL("\t%-**.*fqq%$4$.*Swww%+*5Ldeeee%$2$.3srrrrr%0*xtttttt%.3Fyyyyyyy%c"), parameterList);
       
  1616 	test(generated.Length()==61);
       
  1617 	expected.FormatL(_TL("\t13.895%c%c%c%c%cqqebwww!!199eeee:-)rrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1618 	test(generated.Left(generated.Length()-1)==expected);
       
  1619 	test(generated[generated.Length()-1]==(S)0x8bdd);
       
  1620 
       
  1621 	VA_START(parameterList, aDummyParameter);
       
  1622 	generated.FormatListL(_TL("\t%-**.*fqq%.3swww%+*5Ldeeee%$7$crrrrr%0*xtttttt%.3Fyyyyyyy%$4$.*S"), parameterList);
       
  1623 	test(generated.Length()==61);
       
  1624 	expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeee"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1625 	test(generated.Left(29)==expected);
       
  1626 	test(generated[29]==(S)0x8bdd);
       
  1627 	test(generated.Mid(29+1)==_TL("rrrrr007535tttttt0.125yyyyyyyeb"));
       
  1628 
       
  1629 	VA_START(parameterList, aDummyParameter);
       
  1630 	generated.FormatListL(_TL("\t%$4$.*Sqq%.3swww%+*5Ldeeee%$6$.3Frrrrr%0*xtttttt%$1$-**.*fyyyyyyy%c"), parameterList);
       
  1631 	test(generated.Length()==61);
       
  1632 	expected.FormatL(_TL("\tebqq:-)www!!199eeee0.125rrrrr007535tttttt13.895%c%c%c%c%cyyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1633 	test(generated.Left(generated.Length()-1)==expected);
       
  1634 	test(generated[generated.Length()-1]==(S)0x8bdd);
       
  1635 
       
  1636 	VA_START(parameterList, aDummyParameter);
       
  1637 	generated.FormatListL(_TL("\t%$7$cqq%$6$.3Fwww%$5$0*xeeee%.*Srrrrr%$3$+*5Ldtttttt%$2$.3syyyyyyy%$1$-**.*f"), parameterList);
       
  1638 	test(generated.Length()==61);
       
  1639 	test(generated.Left(1)==_TL("\t"));
       
  1640 	test(generated[1]==(S)0x8bdd);
       
  1641 	expected.FormatL(_TL("qq0.125www007535eeeeebrrrrr!!199tttttt:-)yyyyyyy13.895%c%c%c%c%c"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1642 	test(generated.Mid(2)==expected);
       
  1643 
       
  1644 	VA_START(parameterList, aDummyParameter);
       
  1645 	generated.FormatListL(_TL("\t%$7$cqq%$6$.3Fwww%$5$0*xeeee%$4$.*Srrrrr%$3$+*5Ldtttttt%$2$.3syyyyyyy%$1$-**.*f"), parameterList);
       
  1646 	test(generated.Length()==61);
       
  1647 	test(generated.Left(1)==_TL("\t"));
       
  1648 	test(generated[1]==(S)0x8bdd);
       
  1649 	expected.FormatL(_TL("qq0.125www007535eeeeebrrrrr!!199tttttt:-)yyyyyyy13.895%c%c%c%c%c"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
       
  1650 	test(generated.Mid(2)==expected);
       
  1651 	
       
  1652 	test.End();
       
  1653 	}
       
  1654 
       
  1655 
       
  1656 /**
       
  1657 @SYMTestCaseID SYSLIB-EUSERHL-UT-4025
       
  1658 @SYMTestCaseDesc Tests LString ReplaceL() method
       
  1659 @SYMTestPriority High
       
  1660 @SYMTestActions Creates LString objects and uses the ReplaceL() method
       
  1661 				to replace the string data.
       
  1662 				Verifies that the LString data is replaced as expected
       
  1663 @SYMTestExpectedResults LString ReplaceL() method should replace data 
       
  1664 				in the LString as expected.
       
  1665 @SYMREQ	10372
       
  1666 */
       
  1667 template <class T,class S,class DESTEMPLATE>
       
  1668 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test15L()
       
  1669 // Replacing
       
  1670 	{
       
  1671 	
       
  1672 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4025"));
       
  1673 	
       
  1674 	test.Next(_L("Replace"));
       
  1675 	T a(1);
       
  1676 	T b(1);
       
  1677 	test(a.MaxLength()>=1);
       
  1678 	a=_TL("abccccc");
       
  1679 	b=_TL("def");
       
  1680 	a.ReplaceL(3,4,b); // Replace with smaller in middle (insert and delete)
       
  1681 	test(a==_TL("abcdef"));
       
  1682 	a.ReplaceL(1,1,b); // Replace with larger in middle (insert and delete)
       
  1683 	test(a==_TL("adefcdef"));
       
  1684 	a.ReplaceL(0,8,_TL("")); // Replace complete string (delete)
       
  1685 	test(a==_TL(""));
       
  1686 	a.ReplaceL(0,0,b); // Replace at beginning (insert)
       
  1687 	test(a==b);
       
  1688 	a.ReplaceL(3,0,_TL("xyz")); // Replace at end (append)
       
  1689 	test(a==_TL("defxyz"));
       
  1690 	a.ReplaceL(0,0,_TL("")); // Replace nothing at beginning (do nothing)
       
  1691 	test(a==_TL("defxyz"));
       
  1692 	a.ReplaceL(6,0,_TL("")); // Replace nothing at end (do nothing)
       
  1693 	test(a==_TL("defxyz"));
       
  1694 	test.End();
       
  1695 	}
       
  1696 
       
  1697 
       
  1698 template<class T,class S,class DESTEMPLATE>
       
  1699 GLDEF_C void TestLString<T,S,DESTEMPLATE>::test_TBufL()
       
  1700 // Test the TBuf class.
       
  1701 	{
       
  1702 	test.Start(_L("All operations"));
       
  1703 	Test1L();
       
  1704 	test.Next(_L("Constructors"));
       
  1705 	Test2();
       
  1706 	test.Next(_L("Additional tests"));
       
  1707 	Test3();
       
  1708 	test.Next(_L("Comparison operators"));
       
  1709 	Test4();
       
  1710 	test.Next(_L("Conversion operators"));
       
  1711 	Test7();
       
  1712 	test.Next(_L("Comparison"));
       
  1713 	Test8();
       
  1714 	test.Next(_L("Matching"));
       
  1715 	Test9();
       
  1716 	test.Next(_L("Locating"));
       
  1717 	Test10();
       
  1718 	test.Next(_L("Copying"));
       
  1719 	Test11L();
       
  1720 	test.Next(_L("Finding"));
       
  1721 	Test12();
       
  1722 	test.Next(_L("Basic like ops"));
       
  1723 	Test13L();
       
  1724 	test.Next(_L("Leaving variants of Formating"));
       
  1725 	Test14L();
       
  1726 	
       
  1727 	test.Next(_L("Leaving variants of Replacing"));
       
  1728 	Test15L();
       
  1729 	test.End();
       
  1730 	}
       
  1731 
       
  1732 /**
       
  1733 @SYMTestCaseID SYSLIB-EUSERHL-UT-4026
       
  1734 @SYMTestCaseDesc Tests LString FormatL() method
       
  1735 @SYMTestPriority High
       
  1736 @SYMTestActions Creates LString objects and uses the FormatL() method
       
  1737 				to format the string data.
       
  1738 				Verifies that the LString data is formatted as expected
       
  1739 @SYMTestExpectedResults LString FormatL() method should format data 
       
  1740 				in the LString as expected.
       
  1741 @SYMREQ	10372
       
  1742 */
       
  1743 template <class T,class S,class DESTEMPLATE>
       
  1744 LOCAL_C void testFormatL()
       
  1745 	{
       
  1746 	
       
  1747 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4026"));
       
  1748 	
       
  1749 	//TBuf<0x100> aa;
       
  1750 	T aa(1);
       
  1751 	aa.FormatL(_TL("x%- 5fx"), 6.2345678);
       
  1752 	test(aa==_TL("x6.234568x"));
       
  1753 	aa.FormatL(_TL("x%+ 5fx"), 6.2345678);
       
  1754 	test(aa==_TL("x6.234568x"));
       
  1755 	aa.FormatL(_TL("x% 5fx"), 6.2345678);
       
  1756 	test(aa==_TL("x6.234568x"));
       
  1757 	aa.FormatL(_TL("x%= 5fx"), 6.2345678);
       
  1758 	test(aa==_TL("x6.234568x"));
       
  1759 	aa.FormatL(_TL("x%- 10fx"), 6.2345);
       
  1760 	test(aa==_TL("x6.234500  x"));
       
  1761 	aa.FormatL(_TL("x%+ 10fx"), 6.2345);
       
  1762 	test(aa==_TL("x  6.234500x"));
       
  1763 	aa.FormatL(_TL("x% 10fx"), 6.2345);
       
  1764 	test(aa==_TL("x  6.234500x"));
       
  1765 	aa.FormatL(_TL("x%= 10fx"), 6.2345);
       
  1766 	test(aa==_TL("x 6.234500 x"));
       
  1767 	aa.FormatL(_TL("x%10fx"), 12345352342.545);
       
  1768 	test(aa==_TL("x12,345,352,342.545000x"));
       
  1769 	aa.FormatL(_TL("x%20.9fx"), 1.0123456789);
       
  1770 	test(aa==_TL("x         1.012345679x"));
       
  1771 	aa.FormatL(_TL("x%5.1fx"), 1.99);
       
  1772 	test(aa==_TL("x  2.0x"));
       
  1773 
       
  1774 // Cannot do these on GCCE or ARMv5 because of 
       
  1775 // "Cannot pass objects of non-POD type through '...'. 
       
  1776 // Call will abort at runtime".
       
  1777 #ifdef __WINSCW__
       
  1778 	aa.FormatL(_TL("x%- 5Fx"), TRealX(6.2345678));
       
  1779 	test(aa==_TL("x6.234568x"));
       
  1780 	aa.FormatL(_TL("x%+ 5Fx"), TRealX(6.2345678));
       
  1781 	test(aa==_TL("x6.234568x"));
       
  1782 	aa.FormatL(_TL("x% 5Fx"), TRealX(6.2345678));
       
  1783 	test(aa==_TL("x6.234568x"));
       
  1784 	aa.FormatL(_TL("x%= 5Fx"), TRealX(6.2345678));
       
  1785 	test(aa==_TL("x6.234568x"));
       
  1786 	aa.FormatL(_TL("x%- 10Fx"), TRealX(6.2345));
       
  1787 	test(aa==_TL("x6.234500  x"));
       
  1788 	aa.FormatL(_TL("x%+ 10Fx"), TRealX(6.2345));
       
  1789 	test(aa==_TL("x  6.234500x"));
       
  1790 	aa.FormatL(_TL("x% 10Fx"), TRealX(6.2345));
       
  1791 	test(aa==_TL("x  6.234500x"));
       
  1792 	aa.FormatL(_TL("x%+010Fx"), TRealX(6.2345));
       
  1793 	test(aa==_TL("x006.234500x"));
       
  1794 	aa.FormatL(_TL("x%+10Fx"), TRealX(6.2345));
       
  1795 	test(aa==_TL("x  6.234500x"));
       
  1796 	aa.FormatL(_TL("x%10Fx"), TRealX(6.2345));
       
  1797 	test(aa==_TL("x  6.234500x"));
       
  1798 	aa.FormatL(_TL("x%010Fx"), TRealX(6.2345));
       
  1799 	test(aa==_TL("x006.234500x"));
       
  1800 	aa.FormatL(_TL("x%= 10Fx"), TRealX(6.2345));
       
  1801 	test(aa==_TL("x 6.234500 x"));
       
  1802 	aa.FormatL(_TL("x%10Fx"), TRealX(12345352342.545));
       
  1803 	test(aa==_TL("x12,345,352,342.545000x"));
       
  1804 	aa.FormatL(_TL("x%20.9Fx"), TRealX(1.0123456789));
       
  1805 	test(aa==_TL("x         1.012345679x"));
       
  1806 	aa.FormatL(_TL("x%5.1Fx"), TRealX(1.99));
       
  1807 	test(aa==_TL("x  2.0x"));
       
  1808 #endif
       
  1809 
       
  1810 	aa.FormatL(_TL("x%- 5ex"), 6.2345678);
       
  1811 	test(aa==_TL("x6.234568E+00x"));
       
  1812 	aa.FormatL(_TL("x%+ 5ex"), 6.2345678);
       
  1813 	test(aa==_TL("x6.234568E+00x"));
       
  1814 	aa.FormatL(_TL("x% 5ex"), 6.2345678);
       
  1815 	test(aa==_TL("x6.234568E+00x"));
       
  1816 	aa.FormatL(_TL("x%= 5ex"), 6.2345678);
       
  1817 	test(aa==_TL("x6.234568E+00x"));
       
  1818 	aa.FormatL(_TL("x%- 14ex"), 6.2345);
       
  1819 	test(aa==_TL("x6.234500E+00  x"));
       
  1820 	aa.FormatL(_TL("x%+ 14ex"), 6.2345);
       
  1821 	test(aa==_TL("x  6.234500E+00x"));
       
  1822 	aa.FormatL(_TL("x% 14ex"), 6.2345);
       
  1823 	test(aa==_TL("x  6.234500E+00x"));
       
  1824 	aa.FormatL(_TL("x%= 14ex"), 6.2345);
       
  1825 	test(aa==_TL("x 6.234500E+00 x"));
       
  1826 	aa.FormatL(_TL("x%10ex"), 12345352342.545);
       
  1827 	test(aa==_TL("x1.234535E+10x"));
       
  1828 	aa.FormatL(_TL("x%20.9ex"), 1.0123456789);
       
  1829 	test(aa==_TL("x     1.012345679E+00x"));
       
  1830 	aa.FormatL(_TL("x%5.1ex"), 1.99);
       
  1831 	test(aa==_TL("x2.0E+00x"));
       
  1832 	
       
  1833 	test.End();
       
  1834 	}
       
  1835 
       
  1836 /**
       
  1837 @SYMTestCaseID SYSLIB-EUSERHL-UT-4027
       
  1838 @SYMTestCaseDesc Tests LString AppendFormatL() method
       
  1839 @SYMTestPriority High
       
  1840 @SYMTestActions Creates LString objects and uses the AppendFormatL() method
       
  1841 				to format the string data with and without an overflow handler.
       
  1842 				Verifies that the LString data is formatted as expected when using an
       
  1843 				overflow handler.
       
  1844 @SYMTestExpectedResults LString AppendFormatL() method should format data 
       
  1845 				in the LString as expected with and without an overflow handler
       
  1846 @SYMREQ	10372
       
  1847 */
       
  1848 template <class T,class S,class DESTEMPLATE>
       
  1849 void testAppendFormatIgnoreOverflowL()
       
  1850 	{
       
  1851 	
       
  1852 	test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4027"));
       
  1853 	
       
  1854 	test.Next(_L("Test no overflow"));
       
  1855 		
       
  1856 	T buf(1);
       
  1857 	buf.AppendFormatL(_TL("A Descriptor"));	
       
  1858 	test(buf==_TL("A Descriptor"));
       
  1859 	
       
  1860 	test.Next(_L("Test overflow with no conversions"));
       
  1861 	buf.AppendFormatL(_TL("123456789"));
       
  1862 	test(buf==_TL("A Descriptor123456789"));
       
  1863 	
       
  1864 	test.Next(_L("Force overflow with descriptor conversion"));
       
  1865 	buf = _TL("Symbian OS");
       
  1866 	buf.Compress();
       
  1867 	
       
  1868 	T buf2;
       
  1869 	buf2 = _TL(" - This descriptor should cause overflow");
       
  1870 	buf.AppendFormatL(_TL("%S"),&buf2);
       
  1871 	test(buf==_TL("Symbian OS - This descriptor should cause overflow"));
       
  1872 
       
  1873 	test.End();
       
  1874 
       
  1875 	}
       
  1876 	
       
  1877 #ifndef _DEBUG
       
  1878 #pragma warning( disable : 4702) //Unreachable code
       
  1879 #pragma warning( disable : 4710) //Function not expanded
       
  1880 #endif
       
  1881 
       
  1882 
       
  1883 void RunTestsL()
       
  1884 	{
       
  1885 	test.Next(_L("class LString8"));
       
  1886 	TestLString<LString8, TText8, TPtrC8> a(0x50);
       
  1887 	a.test_TBufL();
       
  1888 
       
  1889 	test.Next(_L("TReal formating with auto LString8 extension "));
       
  1890 	testFormatL<LString8, TText8, TPtrC8>();
       
  1891 		
       
  1892 	test.Next(_L("class LString16"));
       
  1893 	TestLString<LString16, TText,TPtrC> b(0x50);
       
  1894 	b.test_TBufL();
       
  1895 
       
  1896 	test.Next(_L("TReal formating with auto LString16 extension "));
       
  1897 	testFormatL<LString16, TText,TPtrC>();
       
  1898 	
       
  1899 	testAppendFormatIgnoreOverflowL<LString8,TText8,TPtrC8>();
       
  1900 	testAppendFormatIgnoreOverflowL<LString16,TText,TPtrC>();
       
  1901 	}
       
  1902 
       
  1903 GLDEF_C TInt E32Main()
       
  1904 // Test the TBuf type.
       
  1905     {
       
  1906       
       
  1907 	CTrapCleanup* trapHandler=CTrapCleanup::New();
       
  1908 	test(trapHandler!=NULL);
       
  1909 	
       
  1910 	
       
  1911 	test.Title();
       
  1912  	test.Start(_L("Test Formating Functions"));
       
  1913 
       
  1914  	TRAPD(err, RunTestsL());
       
  1915  	
       
  1916  	test.End();
       
  1917  	
       
  1918  	delete trapHandler;
       
  1919 
       
  1920     return(err);
       
  1921     
       
  1922     }
       
  1923 
       
  1924 //#pragma warning( default : 4702)
       
  1925 //#pragma warning( default : 4710)
       
  1926 
       
  1927