Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // Test methods of the LString16, LString8, LString template class.
17 // LString16, LString8, LString
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,
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
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:
64 // Assumptions/Requirement/Pre-requisites:
65 // Failures and causes:
66 // Base Port information:
79 // Solve compilation problem caused by non-English locale
80 #pragma setlocale("english")
83 LOCAL_D RTest test(_L("T_LSFORMAT"));
85 #pragma warning(disable: 4127) // disabling warning "conditional expression is constant"
86 #pragma warning(disable: 4310) // disabling warning "cast truncates constant value"
89 #define _TL(a) DESTEMPLATE((S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a))
91 #define _TS(a) ((const S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a))
93 template<class T,class S,class DESTEMPLATE>
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
113 void Test14_ReorderedParameterFormatting(TInt aDummyParameter, ...);
114 void Test14_ReorderedParameterFormattingL(TInt aDummyParameter, ...);
120 void TestEq(const T& a, const T& b, TInt aLine)
125 test.Printf(_L("LINE %d:\n"),aLine);
127 test.Printf(_L("a=%S\n"),&buf);
129 test.Printf(_L("b=%S\n"),&buf);
135 #define TESTEQ(a,b) TestEq<T>((a),(b),__LINE__)
137 template <class T,class S,class DESTEMPLATE>
138 GLDEF_C TestLString<T,S,DESTEMPLATE>::TestLString(TInt aLength)
140 : iMaxBufLength(aLength)
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.
154 template <class T,class S,class DESTEMPLATE>
155 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test1L()
158 test.Start(_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4011"));
160 test.Next(_L("Extending Methods"));
166 test(a.MaxLength() >=1);
168 test.Next(_L("Setting a bigger length "));
170 test(a.Length()== 10);
171 test(a.MaxLength() >= 10);
173 test.Next(_L("operator+ with memory extension "));
174 test(b.MaxLength() >=1);
176 test(b.Length()== 10);
177 test(b.MaxLength() >= 10);
180 test(b.MaxLength() >=1);
182 test(b.Length()== 11);
183 test(b.MaxLength() >= 10);
185 test.Next(_L("Filling past current size "));
187 test(a.Length()== 20);
188 test(a.MaxLength() >= 20);
190 test.Next(_L("Append filling past current size "));
191 a.AppendFillL(' ', 10);
192 test(a.Length()== 30);
193 test(a.MaxLength() >= 30);
195 test.Next(_L("Zeroing past current size "));
197 test(a.Length()== 40);
198 test(a.MaxLength() >= 40);
200 test.Next(_L("Entended Copying"));
205 test(a == _TL("AB"));
214 test(a == _TL("ab"));
223 test(a == _TL("ab"));
231 a.CopyLCL(_TL("AB"));
232 test(a == _TL("ab"));
240 a.CopyUCL(_TL("AB"));
241 test(a == _TL("AB"));
249 a.CopyCPL(_TL("AB"));
250 test(a == _TL("Ab"));
252 test.Next(_L("Basic like ops"));
259 test.Next(_L("Formating"));
260 a.JustifyL(_TL("AB"),10,ELeft,' ');
261 test(a == _TL("AB "));
263 a.JustifyL(b,10,ELeft,' ');
264 test(a == _TL("AA "));
267 test(b == _TL("AA"));
270 a.AppendJustifyL(_TL("AB"),10,ELeft,' ');
271 test(a == _TL("AB "));
273 a.AppendJustifyL(b,10,ELeft,' ');
274 test(a == _TL("AB AA "));
278 a.AppendJustifyL(des,2,10,ELeft,' ');
279 test(a == _TL("AA "));
281 a.AppendJustifyL(des,2,KDefaultJustifyWidth ,ELeft,' ');
282 test(a == _TL("AA AA"));
285 a.AppendJustifyL(des,10,ELeft,' ');
286 test(a == _TL("AA "));
288 a.AppendJustifyL(des,KDefaultJustifyWidth ,ELeft,' ');
289 test(a == _TL("AA AA"));
292 a.AppendJustifyL(b.PtrZL(),10,ELeft,' ');
293 test(a == _TL("AA "));
295 a.AppendJustifyL(b.PtrZL(),KDefaultJustifyWidth,ELeft,' ');
296 test(a == _TL("AA AA"));
298 a.AppendJustifyL(b.PtrZL(),2,KDefaultJustifyWidth,ELeft,' ');
299 test(a == _TL("AA AAAA"));
302 a.AppendJustifyL(b.PtrZL(),2,10,ELeft,' ');
303 test(a == _TL("AA "));
305 a.AppendJustifyL(b.PtrZL(),2,5,ELeft,' ');
306 test(a == _TL("AA AA "));
310 test(a == _TL("10"));
312 test(a == _TL("1010"));
315 a.NumL((TUint)v2,EHex);
317 a.AppendNumL((TUint)v2,EHex);
318 test(a == _TL("aa"));
320 a.NumUCL((TUint)v2,EHex);
322 a.AppendNumUCL((TUint)v2,EHex);
323 test(a == _TL("AA"));
325 a.NumFixedWidthL((TUint)v2,EHex,1);
327 a.AppendNumFixedWidthL((TUint)v2,EHex,1);
328 test(a == _TL("aa"));
330 a.NumFixedWidthUCL((TUint)v2,EHex,1);
332 a.AppendNumFixedWidthUCL((TUint)v2,EHex,1);
333 test(a == _TL("AA"));
337 ff.iType=KRealFormatFixed;
344 test(a == _TL("10.00"));
347 test(a == _TL("10.0010.00"));
349 a.FormatL(_TL("%d"),12);
350 test(a == _TL("12"));
352 a.AppendFormatL(_TL("%d"),12);
353 test(a == _TL("1212"));
357 test(a == _TL("12"));
358 a.AppendFormatL(b,12);
359 test(a == _TL("1212"));
362 test.Next(_L("Replacing"));
366 test(a == _TL("ABC"));
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
383 template <class T,class S,class DESTEMPLATE>
384 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test2()
385 // Tests all constructors.
388 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4012"));
390 test.Next(_L("Default"));
393 test(a.MaxLength() >=iMaxBufLength);
396 test.Next(_L("By string"));
403 test.Next(_L("By buffer reference"));
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
423 template <class T,class S,class DESTEMPLATE>
424 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test3()
425 // Tests all assignment operators
428 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4013"));
430 test.Next(_L("By String"));
436 test(a==_TL("ABCD"));
438 test.Next(_L("By buffer"));
443 test(b==_TL("ABCDABCD"));
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
458 template <class T,class S,class DESTEMPLATE>
459 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test4()
460 // Test all comparison operators
463 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4014"));
465 test.Next(_L("By NULL string"));
468 test(a==_TL("")); // NULL strings
481 test.Next(_L("By string or buffer"));
483 test(a==_TL("abc")); // ==
484 test(!(a==_TL("xyz")));
485 test(!(a==_TL("aa")));
487 test(!(_TL("xyz")==a));
488 test(!(_TL("aa")==a));
489 test(a!=_TL("xyz")); // !=
490 test(!(a!=_TL("abc")));
493 test(!(_TL("abc")!=a));
495 test(a<_TL("x")); // <
496 test(!(a<_TL("abc")));
497 test(!(a<_TL("aa")));
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")));
505 test(!(_TL("abc")>a));
506 test(!(_TL("aa")>a));
507 test(a>=_TL("abc")); // >=
508 test(!(a>=_TL("xyz")));
511 test(!(_TL("aaa")>=a));
513 test(a<=_TL("abc")); // <=
514 test(!(a<=_TL("aa")));
517 test(!(_TL("xyz")<=a));
520 test.Next(_L("By special characters"));
522 test(a==_TL("!@#$%^&*()"));
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
537 template <class T,class S,class DESTEMPLATE>
538 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test7()
539 // Conversion operators
542 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4015"));
544 test.Next(_L("Fold, collate ..."));
559 test(a==_TL("abc abc"));
561 test(a==_TL("Abc abc"));
563 test(a==_TL("ABC ABC"));
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.
582 template <class T,class S,class DESTEMPLATE>
583 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test8()
587 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4016"));
589 test.Next(_L("By string"));
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);
599 test.Next(_L("By buffer"));
605 test(a.Compare(b)==0);
606 test(a.Compare(c)!=0);
608 test(a.CompareC(c)!=0);
609 test(a.CompareF(b)==0);
610 test(a.CompareF(c)!=0);
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.
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) )
633 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4017"));
635 test.Next(_L("By string"));
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);
646 test.Next(_L("By buffer"));
653 test(a.Match(c)==KErrNotFound);
655 test(a.MatchC(b)==0);
656 test(a.MatchC(c)==KErrNotFound);
657 test(a.MatchF(b)==0);
658 test(a.MatchF(c)==KErrNotFound);
660 test.Next(_L("Wildcards"));
662 test(a.Match(_TL("abc*"))==0);
663 test(a.Match(_TL("abw*"))==KErrNotFound);
665 test(a.Match(_TL("a*fg"))==0);
666 test(a.Match(_TL("a*f"))==KErrNotFound);
667 test(a.Match(_TL("abc*fgh"))==KErrNotFound);
669 test(a.Match(_TL("abc?ef"))==0);
670 test(a.Match(_TL("abc?xf"))==KErrNotFound);
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);
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);
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);
696 T candidate(_TL(""));
699 test(candidate.MatchC(search) == 0);
703 test(candidate.MatchC(search) == 0);
705 candidate = _TL("abcd");
706 search = _TL("*abc*cd");
707 test(candidate.MatchC(search) == KErrNotFound);
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);
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.
733 template <class T,class S,class DESTEMPLATE>
734 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test10()
738 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4018"));
743 test.Next(_L("First Char"));
747 test(a.Locate(b)==0);
748 test(a.LocateF(b)==0);
749 test(a.LocateReverse(b)==4);
750 test(a.LocateReverseF(b)==4);
752 test.Next(_L("Middle Char"));
754 test(a.Locate(b)==1);
755 test(a.LocateF(b)==1);
757 test(a.LocateReverse(b)==2);
758 test(a.LocateReverseF(b)==2);
760 test.Next(_L("Last Char"));
762 test(a.Locate(b)==2);
763 test(a.LocateF(b)==2);
765 test(a.LocateReverse(b)==0);
766 test(a.LocateReverseF(b)==0);
768 test.Next(_L("Test for failure of locate"));
770 test(a.Locate(b)==KErrNotFound);
771 test(a.LocateF(b)==KErrNotFound);
772 test(a.LocateReverse(b)==KErrNotFound);
773 test(a.LocateReverseF(b)==KErrNotFound);
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
787 @SYMTestExpectedResults LString CopyX() methods should copy data into
791 template <class T,class S,class DESTEMPLATE>
792 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test11L()
796 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4019"));
798 test.Next(_L("By String"));
806 a.CopyFL(_TL("abc"));
808 b.CopyFL(_TL("ABC"));
810 a.CopyLCL(_TL("AbC"));
813 a.CopyCL(_TL("abc"));
814 b.CopyCL(_TL("ABC"));
817 a.CopyCPL(_TL("abc"));
820 a.CopyUCL(_TL("aBc"));
824 test.Next(_L("By buffer"));
831 b.CopyFL(_TL("ABC"));
842 b.CopyCL(_TL("ABC"));
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
872 template <class T,class S,class DESTEMPLATE>
873 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test12()
877 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4020"));
879 test.Next(_L("By String"));
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);
904 test.Next(_L("By buffer"));
909 test(a.Find(b)==KErrNotFound);
910 test(a.FindF(b)==KErrNotFound);
911 test(a.FindC(b)==KErrNotFound);
913 test(a.Find(b)==KErrNotFound);
914 test(a.FindF(b)==KErrNotFound);
915 test(a.FindC(b)==KErrNotFound);
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
951 template <class T,class S,class DESTEMPLATE>
952 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test13L()
956 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4021"));
958 test.Next(_L("Repeat, trim, insert and delete"));
962 TInt max=a.MaxLength();
964 a.Repeat(_TL("abc"));
968 for (TInt j=1;j<max;j++) // ?? Cannot SetLength = MaxLength
971 a.Repeat(_TL("abc"));
982 a=_TL("\t\n ab \t\n ");
984 test(a==_TL("ab \t\n "));
986 a=_TL("\t\n ab \t\n ");
988 test(a==_TL("\t\n ab"));
990 a=_TL(" \t\n ab \t \n");
998 test(a==_TL("a123bc"));
1002 test(a==_TL("a123bc"));
1003 test(a.Length()==6);
1005 test(a==_TL("a123bc"));
1006 test(a.Length()==6);
1008 test(a==_TL("abc"));
1009 test(a.Length()==3);
1012 test(a.Length()==0);
1014 test.Next(_L("TrimAll"));
1024 a=_TL(" ab cd ef g");
1026 test(a==_TL("ab cd ef g"));
1029 test(a==_TL("abcdef"));
1030 a=_TL("a b\t cd\t\tef");
1032 test(a==_TL("a b\tcd\tef"));
1033 a=_TL("abcdef \t ghijk");
1035 test(a==_TL("abcdef ghijk"));
1038 test(a==_TL("abcdef g"));
1039 a=_TL("ab cd ef gh ij");
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");
1044 test(a==_TL("a b c defg h i jk l mno pqr stu vw xyz"));
1046 test.Next(_L("Right, Left and Mid"));
1049 test(b==_TL("abc"));
1050 test(b.Length()==3);
1052 test(b==_TL("def"));
1054 test(b==_TL("cdef"));
1055 test(b.Length()==4);
1058 test(b.Length()==2);
1063 test(b.Length()==1);
1065 test(b==_TL("abcdef"));
1066 test(b.Length()==6);
1070 test(b==_TL("abcdef"));
1071 test(b.Length()==6);
1073 test(a==_TL("abcdef"));
1076 test(b==_TL("abcdef"));
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
1090 template <class T,class S,class DESTEMPLATE>
1091 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test14L()
1092 // Formating operations
1095 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4022"));
1097 test.Next(_L("Justify"));
1098 //---------------------------Apepend+Justify-----------------------------------
1107 d=_TL("linearisation");
1108 const S* pD=_TS("299792458");
1110 aWidth=KDefaultJustifyWidth; // Left justified, Default width
1111 a.JustifyL(b,aWidth,ELeft,c);
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);
1120 test(a.Length()==1);
1121 a.AppendJustifyL(b,aWidth,ELeft,c);
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);
1132 aWidth=KDefaultJustifyWidth; // Right justified, Default width
1133 a.JustifyL(b,aWidth,ERight,c);
1135 test(a.Length()==3);
1136 a.AppendJustifyL(b,aWidth,ERight,c);
1137 test(a==_TL("abcabc"));
1138 test(a.Length()==6);
1140 aWidth=1; // Right justified, Width < String length
1141 a.JustifyL(b,aWidth,ERight,c);
1143 test(a.Length()==1);
1144 a.AppendJustifyL(b,aWidth,ERight,c);
1146 test(a.Length()==2);
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);
1156 aWidth=KDefaultJustifyWidth; // Center justified, Default width
1157 a.JustifyL(b,aWidth,ECenter,c);
1159 test(a.Length()==3);
1160 a.AppendJustifyL(b,aWidth,ECenter,c);
1161 test(a==_TL("abcabc"));
1162 test(a.Length()==6);
1164 aWidth=1; // Centre justified, width < String length
1165 a.JustifyL(b,aWidth,ECenter,c);
1167 test(a.Length()==1);
1168 a.AppendJustifyL(b,aWidth,ECenter,c);
1170 test(a.Length()==2);
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);
1180 //----------------------Num----------------------------------------------------
1181 test.Next(_L("Num"));
1182 TInt j=-2147483647-1;
1184 test(a==_TL("-2147483648"));
1185 test(a.Length()==11);
1186 TUint i=2147483648u;
1188 test(a==_TL("2147483648"));
1189 test(a.Length()==10);
1190 if (a.MaxLength()>31)
1193 test(a==_TL("10000000000000000000000000000000"));
1194 test(a.Length()==32);
1196 a.NumUCL(i,EBinary);
1197 test(a==_TL("10000000000000000000000000000000"));
1198 test(a.Length()==32);
1202 test(a==_TL("11111"));
1203 test(a.Length()==5);
1205 a.NumUCL(i,EBinary);
1206 test(a==_TL("11111"));
1207 test(a.Length()==5);
1210 test(a==_TL("20000000000"));
1211 test(a.Length()==11);
1214 test(a==_TL("20000000000"));
1215 test(a.Length()==11);
1217 test(a==_TL("2147483648"));
1218 test(a.Length()==10);
1220 a.NumUCL(i,EDecimal);
1221 test(a==_TL("2147483648"));
1222 test(a.Length()==10);
1224 test(a==_TL("80000000"));
1225 test(a.Length()==8);
1228 test(a==_TL("80000000"));
1229 test(a.Length()==8);
1233 test(a.Length()==1);
1237 test(a.Length()==1);
1239 a.NumUCL(i,EBinary);
1241 test(a.Length()==1);
1245 test(a.Length()==1);
1249 test(a.Length()==1);
1253 test(a.Length()==1);
1255 a.NumUCL(i,EDecimal);
1257 test(a.Length()==1);
1261 test(a.Length()==1);
1265 test(a.Length()==1);
1267 // TInt i=a.Num(6.2,format); NOT IMPLEMENTED
1268 //----------------------AppendNum----------------------------------------------------
1269 test.Next(_L("AppendNum"));
1272 test(a==_TL("0-2147483648"));
1273 test(a.Length()==12);
1278 test(a==_TL("abc4294967295"));
1279 test(a.Length()==13);
1284 test(a==_TL("abc2147483647"));
1285 test(a.Length()==13);
1289 if (a.MaxLength()>28)
1291 a.AppendNumL(i,EBinary);
1292 test(a==_TL("a1010101111001101111011110000"));
1293 test(a.Length()==29);
1296 a.AppendNumL(15,EBinary);
1297 test(a==_TL("a1111"));
1298 test(a.Length()==5);
1301 a.AppendNumL(i,EDecimal);
1302 test(a==_TL("a180150000"));
1303 test(a.Length()==10);
1306 a.AppendNumL(i,EOctal);
1307 test(a==_TL("a1257157360"));
1308 test(a.Length()==11);
1311 a.AppendNumUCL(i,EHex);
1312 test(a==_TL("aABCDEF0"));
1313 test(a.Length()==8);
1317 a.AppendNumFixedWidthL(i,EHex,3);
1318 test(a==_TL("aabc"));
1319 test(a.Length()==4);
1322 a.AppendNumFixedWidthUCL(i,EHex,4);
1323 test(a==_TL("aABCD"));
1324 test(a.Length()==5);
1327 //----------------------Format----------------------------------------------------
1328 test.Next(_L("Format"));
1331 a.FormatL(_TL("%S"),&b);
1333 test(a.Length()==3);
1335 DESTEMPLATE xyz=_TL("xyzwpq");
1336 a.FormatL(_TL("%S"),&xyz);
1337 test(a==_TL("xyzwpq"));
1338 test(a.Length()==6);
1340 DESTEMPLATE cde=_TL("cde");
1341 a.FormatL(_TL("ab %-x5S"),&cde);
1342 test(a==_TL("ab cdexx"));
1343 test(a.Length()==8);
1345 a.FormatL(_TL("ab %=x5S"),&cde);
1346 test(a==_TL("ab xcdex"));
1347 test(a.Length()==8);
1349 a.FormatL(_TL("ab %+x5S"),&cde);
1350 test(a==_TL("ab xxcde"));
1351 test(a.Length()==8);
1353 a.FormatL(_TL("ab %5S"),&cde);
1354 test(a==_TL("ab cde"));
1355 test(a.Length()==8);
1357 a.FormatL(_TL("ab %-**S"),'x',5,&cde);
1358 test(a==_TL("ab cdexx"));
1359 test(a.Length()==8);
1361 a.FormatL(_TL("ab %*S"),5,&cde);
1362 test(a==_TL("ab cde"));
1363 test(a.Length()==8);
1366 a.FormatL(_TL("ab %-x5S"),&b);
1367 test(a==_TL("ab cdexx"));
1368 test(a.Length()==8);
1371 a.FormatL(_TL("ab %-**S"),'x',5,&b);
1372 test(a==_TL("ab cdexx"));
1373 test(a.Length()==8);
1376 a.FormatL(_TL("ab %*S"),5,&b);
1377 test(a==_TL("ab cde"));
1378 test(a.Length()==8);
1380 DESTEMPLATE fred=_TL("fred");
1381 a.FormatL(_TL("%+0*S"),10,&fred);
1382 test(a==_TL("000000fred"));
1383 test(a.Length()==10);
1385 a.FormatL(_TL("%-0*S"),7,&fred);
1386 test(a==_TL("fred000"));
1387 test(a.Length()==7);
1389 a.FormatL(_TL("%0*S"),11,&fred);
1390 test(a==_TL("0000000fred"));
1391 test(a.Length()==11);
1393 a.FormatL(_TL("c=%s"),pD);
1394 TESTEQ(a,_TL("c=299792458"));
1396 a.FormatL(_TL("c=%10.6s"),pD);
1397 test(a==_TL("c= 299792"));
1399 a.FormatL(_TL("c=%*.*s"),5,4,pD);
1400 test(a==_TL("c= 2997"));
1402 a.FormatL(_TL("%S"),&d);
1403 test(a==_TL("linearisation"));
1405 a.FormatL(_TL("%10.6S"),&d);
1406 test(a==_TL(" linear"));
1408 a.FormatL(_TL("%*.*S"),5,4,&d);
1409 test(a==_TL(" line"));
1411 a.FormatL(_TL("%*.*Sed"),10,8,&d);
1412 test(a==_TL(" linearised"));
1414 a.FormatL(_TL("%*.*S"),14,20,&d);
1415 test(a==_TL(" linearisation"));
1417 a.FormatL(_TL("ab %-,5b"),7);
1418 test(a==_TL("ab 111,,"));
1419 test(a.Length()==8);
1421 a.FormatL(_TL("ab %=,5O"),31);
1422 test(a==_TL("ab ,37,,"));
1423 test(a.Length()==8);
1425 a.FormatL(_TL("ab %+xlx"),TInt64(171));
1426 test(a==_TL("ab ab"));
1427 test(a.Length()==5);
1429 a.FormatL(_TL("ab %+xlX %+xlx"),TInt64(171),TInt64(171));
1430 TESTEQ(a,_TL("ab AB ab"));
1431 test(a.Length()==8);
1433 a.FormatL(_TL("ab %lu"),MAKE_TINT64((TUint)(KMinTInt),0));
1434 test(a==_TL("ab 9223372036854775808"));
1435 test(a.Length()==22);
1437 a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),1));
1438 test(a==_TL("ab -9223372036854775807"));
1439 test(a.Length()==23);
1441 a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),0));
1442 test(a==_TL("ab -9223372036854775808"));
1443 test(a.Length()==23);
1445 a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
1446 test(a==_TL("ab 9223372036854775807"));
1447 test(a.Length()==22);
1449 a.FormatL(_TL("ab %ld"),MAKE_TINT64(KMaxTUint,KMaxTUint));
1450 test(a==_TL("ab -1"));
1451 test(a.Length()==5);
1453 a.FormatL(_TL("ab %lu"),MAKE_TINT64(KMaxTUint,KMaxTUint));
1454 test(a==_TL("ab 18446744073709551615"));
1455 test(a.Length()==23);
1457 a.FormatL(_TL("ab %ld"),TInt64(0));
1458 test(a==_TL("ab 0"));
1459 test(a.Length()==4);
1461 a.FormatL(_TL("ab %lb"),TInt64(0));
1462 test(a==_TL("ab 0"));
1463 test(a.Length()==4);
1465 a.FormatL(_TL("ab %lx"),TInt64(0));
1466 test(a==_TL("ab 0"));
1467 test(a.Length()==4);
1469 a.FormatL(_TL("ab %lo"),TInt64(0));
1470 test(a==_TL("ab 0"));
1471 test(a.Length()==4);
1473 a.FormatL(_TL("ab %lu"),TInt64(0));
1474 test(a==_TL("ab 0"));
1475 test(a.Length()==4);
1477 a.FormatL(_TL("ab %lb"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
1478 test(a==_TL("ab 111111111111111111111111111111111111111111111111111111111111111"));
1479 test(a.Length()==66);
1481 a.FormatL(_TL("ab %lb"),MAKE_TINT64(KMaxTUint,KMaxTUint));
1482 test(a==_TL("ab 1111111111111111111111111111111111111111111111111111111111111111"));
1483 test(a.Length()==67);
1485 a.FormatL(_TL("ab %lx"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
1486 test(a==_TL("ab 7fffffffffffffff"));
1487 test(a.Length()==19);
1489 a.FormatL(_TL("ab %lx"),MAKE_TINT64(KMaxTUint,KMaxTUint));
1490 test(a==_TL("ab ffffffffffffffff"));
1491 test(a.Length()==19);
1493 a.FormatL(_TL("ab %lo"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
1494 test(a==_TL("ab 777777777777777777777"));
1495 test(a.Length()==24);
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"));
1501 a.FormatL(_TL("%S%li%S"),&fred,MAKE_TINT64(1,2),&fred);
1502 test(a==_TL("fred4294967298fred"));
1504 a.FormatL(_TL("%lu%S"),MAKE_TINT64(1,2),&fred);
1505 test(a==_TL("4294967298fred"));
1507 a.FormatL(_TL("%S%lu%S"),&fred,MAKE_TINT64(1,2),&fred);
1508 test(a==_TL("fred4294967298fred"));
1510 a.FormatL(_TL("ab %U"),233);
1511 test(a==_TL("ab 233"));
1512 test(a.Length()==6);
1514 a.FormatL(_TL("ab %*d"),5,-131);
1515 test(a==_TL("ab -131"));
1516 test(a.Length()==8);
1518 a.FormatL(_TL("ab%c"),'x');
1519 test(a==_TL("abx"));
1520 test(a.Length()==3);
1522 a.FormatL(_TL("%W"),-131);
1523 test(*(TInt32*)a.Ptr()==-131);
1525 a.FormatL(_TL("%M"),-131);
1526 test(*(TInt32*)a.Ptr()==2113929215);
1528 a.FormatL(_TL("%w"),-131);
1529 test(*(TInt16*)a.Ptr()==-131);
1531 a.FormatL(_TL("%m"),-131);
1532 test(*(TInt16*)a.Ptr()==32255);
1534 //----------------------AppendFormat----------------------------------------------------
1536 a.AppendFormatL(_TL("ab %+xlx"),TInt64(171));
1537 test(a==_TL("xyzab ab"));
1538 test(a.Length()==8);
1541 a.AppendFormatL(_TL("ab %5S"),&b);
1542 test(a==_TL("xyzab cde"));
1543 test(a.Length()==11);
1546 a.AppendFormatL(_TL("%W"),-131);
1547 // test(*(TInt32*)(a.Ptr()+3)==-131); // Alignment-safe version:
1549 Mem::Copy(&val,&a[3],4);
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".
1557 const TAny* const zeroTerminatedString=(sizeof(S)==2)? (const TAny*)_S16(":-)E"): (const TAny*)_S8(":-)E");
1558 const TInt dummyParameter=0;
1560 Test14_ReorderedParameterFormattingL(dummyParameter, 0x20ac, 11, 3, 13.89543, zeroTerminatedString, '!', TInt64(199), 2, &b, 6, 30005, TRealX(0.125), 0x8bdd);
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
1576 template <class T,class S,class DESTEMPLATE>
1577 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test14_ReorderedParameterFormattingL(TInt aDummyParameter, ...)
1580 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4024"));
1582 VA_LIST parameterList;
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);
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);
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);
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);
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);
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"));
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);
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);
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);
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.
1667 template <class T,class S,class DESTEMPLATE>
1668 GLDEF_C void TestLString<T,S,DESTEMPLATE>::Test15L()
1672 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4025"));
1674 test.Next(_L("Replace"));
1677 test(a.MaxLength()>=1);
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)
1686 a.ReplaceL(0,0,b); // Replace at beginning (insert)
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"));
1698 template<class T,class S,class DESTEMPLATE>
1699 GLDEF_C void TestLString<T,S,DESTEMPLATE>::test_TBufL()
1700 // Test the TBuf class.
1702 test.Start(_L("All operations"));
1704 test.Next(_L("Constructors"));
1706 test.Next(_L("Additional tests"));
1708 test.Next(_L("Comparison operators"));
1710 test.Next(_L("Conversion operators"));
1712 test.Next(_L("Comparison"));
1714 test.Next(_L("Matching"));
1716 test.Next(_L("Locating"));
1718 test.Next(_L("Copying"));
1720 test.Next(_L("Finding"));
1722 test.Next(_L("Basic like ops"));
1724 test.Next(_L("Leaving variants of Formating"));
1727 test.Next(_L("Leaving variants of Replacing"));
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.
1743 template <class T,class S,class DESTEMPLATE>
1744 LOCAL_C void testFormatL()
1747 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4026"));
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"));
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".
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"));
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"));
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
1844 @SYMTestExpectedResults LString AppendFormatL() method should format data
1845 in the LString as expected with and without an overflow handler
1848 template <class T,class S,class DESTEMPLATE>
1849 void testAppendFormatIgnoreOverflowL()
1852 test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4027"));
1854 test.Next(_L("Test no overflow"));
1857 buf.AppendFormatL(_TL("A Descriptor"));
1858 test(buf==_TL("A Descriptor"));
1860 test.Next(_L("Test overflow with no conversions"));
1861 buf.AppendFormatL(_TL("123456789"));
1862 test(buf==_TL("A Descriptor123456789"));
1864 test.Next(_L("Force overflow with descriptor conversion"));
1865 buf = _TL("Symbian OS");
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"));
1878 #pragma warning( disable : 4702) //Unreachable code
1879 #pragma warning( disable : 4710) //Function not expanded
1885 test.Next(_L("class LString8"));
1886 TestLString<LString8, TText8, TPtrC8> a(0x50);
1889 test.Next(_L("TReal formating with auto LString8 extension "));
1890 testFormatL<LString8, TText8, TPtrC8>();
1892 test.Next(_L("class LString16"));
1893 TestLString<LString16, TText,TPtrC> b(0x50);
1896 test.Next(_L("TReal formating with auto LString16 extension "));
1897 testFormatL<LString16, TText,TPtrC>();
1899 testAppendFormatIgnoreOverflowL<LString8,TText8,TPtrC8>();
1900 testAppendFormatIgnoreOverflowL<LString16,TText,TPtrC>();
1903 GLDEF_C TInt E32Main()
1904 // Test the TBuf type.
1907 CTrapCleanup* trapHandler=CTrapCleanup::New();
1908 test(trapHandler!=NULL);
1912 test.Start(_L("Test Formating Functions"));
1914 TRAPD(err, RunTestsL());
1924 //#pragma warning( default : 4702)
1925 //#pragma warning( default : 4710)