sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Overview: sl@0: // Test methods of the LString16, LString8, LString template class. sl@0: // API Information: sl@0: // LString16, LString8, LString sl@0: // Details : sl@0: // - Create some 16 bit modifiable descriptors, 8 bit modifiable descriptors sl@0: // of fixed length, Build-independent modifiable descriptors, initialize sl@0: // with different strings and check for sl@0: // - Comparison operators, sl@0: // - Property access methods, sl@0: // - Fill & swap methods, sl@0: // - Conversion methods, sl@0: // - Comparison methods, sl@0: // - Pattern Matching methods, sl@0: // - Pattern Locating methods, sl@0: // - Copying methods, sl@0: // - Find, FindC, FindF methods, sl@0: // - Repeat, Trim, TrimLeft, TrimRight, Insert, Delete, Left, sl@0: // Right, Mid methods, sl@0: // - Formatting methods, sl@0: // - Replace methods are as expected. sl@0: // - Construct some descriptors with buffer length, string and buffer reference and sl@0: // verify that they are created successfully. sl@0: // - Test assignment operators and comparison operators for different descriptors. sl@0: // - Initialize some descriptors and check descriptors' maximum length, length and sl@0: // size are as expected. sl@0: // - Check Fill and Swap methods are as expected. sl@0: // - Test Fold, Collate, LowerCase, UpperCase methods are as expected. sl@0: // - Test Comparison methods are as expected. sl@0: // - Test pattern matching for simple string, wild cards with collated comparison. Verify that the sl@0: // return value is KErrNotFound when pattern doesn't match. sl@0: // - Check Locating methods by searching character in forward and backward direction and sl@0: // verify the return value is KErrNotFound when unavailable character is searched. sl@0: // - Check copying strings and converting those into lower and upper case strings are sl@0: // as expected. sl@0: // - Check Find methods by searching string and verify the return value is KErrNotFound when sl@0: // unavailable string is searched. sl@0: // - Check Repeat, Trim, Insert and Delete methods are as expected. sl@0: // - Check the formatting operations are as expected. sl@0: // - Check integer to decimal character representation is as expected. sl@0: // - Check integer to character representation with different number system is as expected. sl@0: // - Check string formatting with variable parameter list is as expected sl@0: // - Check Replace method by replacing string at different places in a string is as expected. sl@0: // - Check the conversion of real numbers, extended precision real numbers into string sl@0: // format is as expected. sl@0: // - Check Format and FormatList methods are as expected. sl@0: // - Check Format of TReal is as expected. sl@0: // - Check the non-leaving and leaving descriptors overflow handlers are as expected. sl@0: // Platforms/Drives/Compatibility: sl@0: // All sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef __VC32__ sl@0: // Solve compilation problem caused by non-English locale sl@0: #pragma setlocale("english") sl@0: #endif sl@0: sl@0: LOCAL_D RTest test(_L("T_LSFORMAT")); sl@0: sl@0: #pragma warning(disable: 4127) // disabling warning "conditional expression is constant" sl@0: #pragma warning(disable: 4310) // disabling warning "cast truncates constant value" sl@0: sl@0: #undef _TL sl@0: #define _TL(a) DESTEMPLATE((S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a)) sl@0: #undef _TS sl@0: #define _TS(a) ((const S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a)) sl@0: sl@0: template sl@0: class TestLString sl@0: { sl@0: public: sl@0: TestLString(TInt aLength); // Test class constructor. sl@0: void Test1L(); // Tests all functions of the class with auto extension sl@0: void Test2(); // Tests all constructors. sl@0: void Test3(); // Tests all assignment operators sl@0: void Test4(); // Tests all comparison operators sl@0: void Test7(); // Tests all conversion sl@0: void Test8(); // Tests all comparison sl@0: void Test9(); // Tests all matching sl@0: void Test10(); // Tests all locating sl@0: void Test11L(); // Tests all Copying sl@0: void Test12(); // Tests all finding sl@0: void Test13L(); // Tests all basic like ops sl@0: void Test14L(); // Tests all formating with auto extension sl@0: void Test15L(); // Tests all replacing with auto extension sl@0: void test_TBufL(); // Test all classes sl@0: protected: sl@0: void Test14_ReorderedParameterFormatting(TInt aDummyParameter, ...); sl@0: void Test14_ReorderedParameterFormattingL(TInt aDummyParameter, ...); sl@0: private: sl@0: TInt iMaxBufLength; sl@0: }; sl@0: sl@0: template sl@0: void TestEq(const T& a, const T& b, TInt aLine) sl@0: { sl@0: if (a!=b) sl@0: { sl@0: LString16 buf(256); sl@0: test.Printf(_L("LINE %d:\n"),aLine); sl@0: buf.CopyL(a); sl@0: test.Printf(_L("a=%S\n"),&buf); sl@0: buf.CopyL(b); sl@0: test.Printf(_L("b=%S\n"),&buf); sl@0: test(0); sl@0: } sl@0: } sl@0: sl@0: sl@0: #define TESTEQ(a,b) TestEq((a),(b),__LINE__) sl@0: sl@0: template sl@0: GLDEF_C TestLString::TestLString(TInt aLength) sl@0: // Constructor. sl@0: : iMaxBufLength(aLength) sl@0: {} sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4011 sl@0: @SYMTestCaseDesc Tests LString Auto-extending functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the auto-extending LString sl@0: functions to manipulate the strings. sl@0: Verifies that the LStrings are auto-extended as expected. sl@0: @SYMTestExpectedResults The LString objects should be auto-extended as required to sl@0: contain any new data. sl@0: @SYMREQ 10372-3 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test1L() sl@0: { sl@0: sl@0: test.Start(_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4011")); sl@0: sl@0: test.Next(_L("Extending Methods")); sl@0: sl@0: T a(1); sl@0: T b(1); sl@0: sl@0: test(a.Length()==0); sl@0: test(a.MaxLength() >=1); sl@0: sl@0: test.Next(_L("Setting a bigger length ")); sl@0: a.SetLengthL(10); sl@0: test(a.Length()== 10); sl@0: test(a.MaxLength() >= 10); sl@0: sl@0: test.Next(_L("operator+ with memory extension ")); sl@0: test(b.MaxLength() >=1); sl@0: b += a; sl@0: test(b.Length()== 10); sl@0: test(b.MaxLength() >= 10); sl@0: sl@0: TChar c('A'); sl@0: test(b.MaxLength() >=1); sl@0: b += c; sl@0: test(b.Length()== 11); sl@0: test(b.MaxLength() >= 10); sl@0: sl@0: test.Next(_L("Filling past current size ")); sl@0: a.FillL(' ', 20); sl@0: test(a.Length()== 20); sl@0: test(a.MaxLength() >= 20); sl@0: sl@0: test.Next(_L("Append filling past current size ")); sl@0: a.AppendFillL(' ', 10); sl@0: test(a.Length()== 30); sl@0: test(a.MaxLength() >= 30); sl@0: sl@0: test.Next(_L("Zeroing past current size ")); sl@0: a.FillZL(40); sl@0: test(a.Length()== 40); sl@0: test(a.MaxLength() >= 40); sl@0: sl@0: test.Next(_L("Entended Copying")); sl@0: a.CopyL(b); sl@0: test(a == b); sl@0: sl@0: a.CopyL(_TL("AB")); sl@0: test(a == _TL("AB")); sl@0: sl@0: a.CopyFL(b); sl@0: sl@0: T d(b); sl@0: d.Fold(); sl@0: test(a == d); sl@0: sl@0: a.CopyFL(_TL("AB")); sl@0: test(a == _TL("ab")); sl@0: sl@0: a.CopyCL(b); sl@0: sl@0: d = b; sl@0: d.Collate(); sl@0: test(a == d); sl@0: sl@0: a.CopyCL(_TL("AB")); sl@0: test(a == _TL("ab")); sl@0: sl@0: a.CopyLCL(b); sl@0: sl@0: d = b; sl@0: d.LowerCase(); sl@0: test(a == d); sl@0: sl@0: a.CopyLCL(_TL("AB")); sl@0: test(a == _TL("ab")); sl@0: sl@0: a.CopyUCL(b); sl@0: sl@0: d = b; sl@0: d.UpperCase(); sl@0: test(a == d); sl@0: sl@0: a.CopyUCL(_TL("AB")); sl@0: test(a == _TL("AB")); sl@0: sl@0: a.CopyCPL(b); sl@0: sl@0: d = b; sl@0: d.Capitalize(); sl@0: test(a == d); sl@0: sl@0: a.CopyCPL(_TL("AB")); sl@0: test(a == _TL("Ab")); sl@0: sl@0: test.Next(_L("Basic like ops")); sl@0: sl@0: a.Zero(); sl@0: b=_TL("AA"); sl@0: a.InsertL(0,b); sl@0: test(a == b); sl@0: sl@0: test.Next(_L("Formating")); sl@0: a.JustifyL(_TL("AB"),10,ELeft,' '); sl@0: test(a == _TL("AB ")); sl@0: sl@0: a.JustifyL(b,10,ELeft,' '); sl@0: test(a == _TL("AA ")); sl@0: sl@0: b.FillL('A',2); sl@0: test(b == _TL("AA")); sl@0: sl@0: a.Zero(); sl@0: a.AppendJustifyL(_TL("AB"),10,ELeft,' '); sl@0: test(a == _TL("AB ")); sl@0: sl@0: a.AppendJustifyL(b,10,ELeft,' '); sl@0: test(a == _TL("AB AA ")); sl@0: sl@0: DESTEMPLATE des(b); sl@0: a.Zero(); sl@0: a.AppendJustifyL(des,2,10,ELeft,' '); sl@0: test(a == _TL("AA ")); sl@0: sl@0: a.AppendJustifyL(des,2,KDefaultJustifyWidth ,ELeft,' '); sl@0: test(a == _TL("AA AA")); sl@0: sl@0: a.Zero(); sl@0: a.AppendJustifyL(des,10,ELeft,' '); sl@0: test(a == _TL("AA ")); sl@0: sl@0: a.AppendJustifyL(des,KDefaultJustifyWidth ,ELeft,' '); sl@0: test(a == _TL("AA AA")); sl@0: sl@0: a.Zero(); sl@0: a.AppendJustifyL(b.PtrZL(),10,ELeft,' '); sl@0: test(a == _TL("AA ")); sl@0: sl@0: a.AppendJustifyL(b.PtrZL(),KDefaultJustifyWidth,ELeft,' '); sl@0: test(a == _TL("AA AA")); sl@0: sl@0: a.AppendJustifyL(b.PtrZL(),2,KDefaultJustifyWidth,ELeft,' '); sl@0: test(a == _TL("AA AAAA")); sl@0: sl@0: a.Zero(); sl@0: a.AppendJustifyL(b.PtrZL(),2,10,ELeft,' '); sl@0: test(a == _TL("AA ")); sl@0: sl@0: a.AppendJustifyL(b.PtrZL(),2,5,ELeft,' '); sl@0: test(a == _TL("AA AA ")); sl@0: sl@0: TInt v1=10; sl@0: a.NumL(v1); sl@0: test(a == _TL("10")); sl@0: a.AppendNumL(v1); sl@0: test(a == _TL("1010")); sl@0: sl@0: TInt v2=10; sl@0: a.NumL((TUint)v2,EHex); sl@0: test(a == _TL("a")); sl@0: a.AppendNumL((TUint)v2,EHex); sl@0: test(a == _TL("aa")); sl@0: sl@0: a.NumUCL((TUint)v2,EHex); sl@0: test(a == _TL("A")); sl@0: a.AppendNumUCL((TUint)v2,EHex); sl@0: test(a == _TL("AA")); sl@0: sl@0: a.NumFixedWidthL((TUint)v2,EHex,1); sl@0: test(a == _TL("a")); sl@0: a.AppendNumFixedWidthL((TUint)v2,EHex,1); sl@0: test(a == _TL("aa")); sl@0: sl@0: a.NumFixedWidthUCL((TUint)v2,EHex,1); sl@0: test(a == _TL("A")); sl@0: a.AppendNumFixedWidthUCL((TUint)v2,EHex,1); sl@0: test(a == _TL("AA")); sl@0: sl@0: TReal v3=10.0; sl@0: TRealFormat ff; sl@0: ff.iType=KRealFormatFixed; sl@0: ff.iWidth=10; sl@0: ff.iPlaces=2; sl@0: ff.iPoint='.'; sl@0: ff.iTriad=','; sl@0: ff.iTriLen=3; sl@0: a.NumL(v3,ff); sl@0: test(a == _TL("10.00")); sl@0: sl@0: a.AppendNumL(v3,ff); sl@0: test(a == _TL("10.0010.00")); sl@0: sl@0: a.FormatL(_TL("%d"),12); sl@0: test(a == _TL("12")); sl@0: sl@0: a.AppendFormatL(_TL("%d"),12); sl@0: test(a == _TL("1212")); sl@0: sl@0: b=_TL("%d"); sl@0: a.FormatL(b,12); sl@0: test(a == _TL("12")); sl@0: a.AppendFormatL(b,12); sl@0: test(a == _TL("1212")); sl@0: //*/ sl@0: sl@0: test.Next(_L("Replacing")); sl@0: a=_TL("AAC"); sl@0: b=_TL("B"); sl@0: a.ReplaceL(1,1,b); sl@0: test(a == _TL("ABC")); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4012 sl@0: @SYMTestCaseDesc Tests all LString Constructors sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects using the different constructors. sl@0: Verifies that length and contents are as expected sl@0: @SYMTestExpectedResults LString objects should be created with the correct sl@0: Length and contents sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test2() sl@0: // Tests all constructors. sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4012")); sl@0: sl@0: test.Next(_L("Default")); sl@0: sl@0: T a(iMaxBufLength); sl@0: test(a.MaxLength() >=iMaxBufLength); sl@0: test(a.Length()==0); sl@0: sl@0: test.Next(_L("By string")); sl@0: T c(iMaxBufLength); sl@0: c = _TL("AB"); sl@0: test(c.Length()==2); sl@0: test(c[0]=='A'); sl@0: test(c[1]=='B'); sl@0: sl@0: test.Next(_L("By buffer reference")); sl@0: T d(iMaxBufLength); sl@0: d = c; sl@0: test(d.Length()==2); sl@0: test(d[0]=='A'); sl@0: test(d[1]=='B'); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4013 sl@0: @SYMTestCaseDesc Tests all LString Assignment operators sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the different assignment sl@0: operators to change the string contents sl@0: Verifies that length and contents are as expected sl@0: @SYMTestExpectedResults LString data should be assigned as expected sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test3() sl@0: // Tests all assignment operators sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4013")); sl@0: sl@0: test.Next(_L("By String")); sl@0: sl@0: T a; sl@0: a=_TL("AB"); sl@0: a+=_TL("CD"); sl@0: test(a.Length()==4); sl@0: test(a==_TL("ABCD")); sl@0: sl@0: test.Next(_L("By buffer")); sl@0: T b; sl@0: b=a; sl@0: b+=a; sl@0: test(b.Length()==8); sl@0: test(b==_TL("ABCDABCD")); sl@0: // sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4014 sl@0: @SYMTestCaseDesc Tests all LString comparison operators sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the different comparison sl@0: operators to compare string contents against other strings sl@0: Verifies that comparison operators work as expected sl@0: @SYMTestExpectedResults LString data comparison should work as expected sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test4() sl@0: // Test all comparison operators sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4014")); sl@0: sl@0: test.Next(_L("By NULL string")); sl@0: sl@0: T a; sl@0: test(a==_TL("")); // NULL strings sl@0: test(!(a!=_TL(""))); sl@0: test(a<=_TL("")); sl@0: test(a>=_TL("")); sl@0: test(!(a<_TL(""))); sl@0: test(!(a>_TL(""))); sl@0: test(_TL("")==a); sl@0: test(!(_TL("")!=a)); sl@0: test(_TL("")<=a); sl@0: test(_TL("")>=a); sl@0: test(!(_TL("")a)); sl@0: sl@0: test.Next(_L("By string or buffer")); sl@0: a=_TL("abc"); sl@0: test(a==_TL("abc")); // == sl@0: test(!(a==_TL("xyz"))); sl@0: test(!(a==_TL("aa"))); sl@0: test(_TL("abc")==a); sl@0: test(!(_TL("xyz")==a)); sl@0: test(!(_TL("aa")==a)); sl@0: test(a!=_TL("xyz")); // != sl@0: test(!(a!=_TL("abc"))); sl@0: test(a!=_TL("aa")); sl@0: test(_TL("xyz")!=a); sl@0: test(!(_TL("abc")!=a)); sl@0: test(_TL("aa")!=a); sl@0: test(a<_TL("x")); // < sl@0: test(!(a<_TL("abc"))); sl@0: test(!(a<_TL("aa"))); sl@0: test(_TL("aa")_TL("aa")); // > sl@0: test(!(a>_TL("abc"))); sl@0: test(!(a>_TL("xyz"))); sl@0: test(_TL("xyz")>a); sl@0: test(!(_TL("abc")>a)); sl@0: test(!(_TL("aa")>a)); sl@0: test(a>=_TL("abc")); // >= sl@0: test(!(a>=_TL("xyz"))); sl@0: test(a>=_TL("aa")); sl@0: test(_TL("abc")>=a); sl@0: test(!(_TL("aaa")>=a)); sl@0: test(_TL("xyz")>=a); sl@0: test(a<=_TL("abc")); // <= sl@0: test(!(a<=_TL("aa"))); sl@0: test(a<=_TL("xyz")); sl@0: test(_TL("abc")<=a); sl@0: test(!(_TL("xyz")<=a)); sl@0: test(_TL("aa")<=a); sl@0: sl@0: test.Next(_L("By special characters")); sl@0: a=_TL("!@#$%^&*()"); sl@0: test(a==_TL("!@#$%^&*()")); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4015 sl@0: @SYMTestCaseDesc Tests all LString conversion methods sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the different conversion sl@0: methods to fold, collate and change case. sl@0: Verifies that conversion methods work as expected. sl@0: @SYMTestExpectedResults LString data conversion methods should work as expected sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test7() sl@0: // Conversion operators sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4015")); sl@0: sl@0: test.Next(_L("Fold, collate ...")); sl@0: sl@0: T a; sl@0: T b; sl@0: a=_TL("abc AbC"); sl@0: b=_TL("ABC ABC"); sl@0: a.Fold(); sl@0: b.Fold(); sl@0: test(a==b); sl@0: a=_TL("abc AbC"); sl@0: b=_TL("ABC ABC"); sl@0: a.Collate(); sl@0: b.Collate(); sl@0: test(a==b); sl@0: a.LowerCase(); sl@0: test(a==_TL("abc abc")); sl@0: a.Capitalize(); sl@0: test(a==_TL("Abc abc")); sl@0: a.UpperCase(); sl@0: test(a==_TL("ABC ABC")); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4016 sl@0: @SYMTestCaseDesc Tests LString Compare() method sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the Compare() sl@0: method to compare string contents against other strings sl@0: Verifies that comparison method works as expected sl@0: @SYMTestExpectedResults LString Compare() method should return a positive sl@0: value if this LString is greater than the specified descriptor. sl@0: Negative if this LString is less than the specified descriptor. sl@0: Zero if both descriptors have the same length and the their sl@0: contents are the same. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test8() sl@0: // Comparison sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4016")); sl@0: sl@0: test.Next(_L("By string")); sl@0: sl@0: T a(iMaxBufLength); sl@0: a=_TL("abc AbC"); sl@0: test(a.Compare(_TL("abc AbC"))==0); sl@0: test(a.CompareF(_TL("ABC aBc"))==0); sl@0: test(a.Compare(_TL("xyz"))!=0); sl@0: test(a.CompareC(_TL("xyz"))!=0); sl@0: test(a.CompareF(_TL("xyz"))!=0); sl@0: sl@0: test.Next(_L("By buffer")); sl@0: T b; sl@0: T c; sl@0: a=_TL("abc AbC"); sl@0: b=_TL("abc AbC"); sl@0: c=_TL("xyz"); sl@0: test(a.Compare(b)==0); sl@0: test(a.Compare(c)!=0); sl@0: b=_TL("ABC aBc"); sl@0: test(a.CompareC(c)!=0); sl@0: test(a.CompareF(b)==0); sl@0: test(a.CompareF(c)!=0); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4017 sl@0: @SYMTestCaseDesc Tests LString MatchX() methods sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the MatchX() sl@0: methods to compare string contents against other strings sl@0: Verifies that MatchX methods work as expected sl@0: @SYMTestExpectedResults LString MatchX() methods should compare string sl@0: contents and return the index of the first match, sl@0: or KErrNotFound if there is no match. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test9() sl@0: // Matching (need to test explicit result as error KErrNotFound = KMaxTUint sl@0: // and so registers as TRUE. (test parameter is TUint) ) sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4017")); sl@0: sl@0: test.Next(_L("By string")); sl@0: sl@0: T a(iMaxBufLength); sl@0: a=_TL("abc AbC"); sl@0: test(a.Match(_TL("abc AbC"))==0); sl@0: test(a.MatchC(_TL("ABC aBc"))==0); sl@0: test(a.MatchF(_TL("ABC aBc"))==0); sl@0: test(a.Match(_TL("xyz"))==KErrNotFound); sl@0: test(a.MatchC(_TL("xyz"))==KErrNotFound); sl@0: test(a.MatchF(_TL("xyz"))==KErrNotFound); sl@0: sl@0: test.Next(_L("By buffer")); sl@0: T b; sl@0: T c; sl@0: a=_TL("abc AbC"); sl@0: b=_TL("abc AbC"); sl@0: c=_TL("xyz"); sl@0: test(a.Match(b)==0); sl@0: test(a.Match(c)==KErrNotFound); sl@0: b=_TL("ABC aBc"); sl@0: test(a.MatchC(b)==0); sl@0: test(a.MatchC(c)==KErrNotFound); sl@0: test(a.MatchF(b)==0); sl@0: test(a.MatchF(c)==KErrNotFound); sl@0: sl@0: test.Next(_L("Wildcards")); sl@0: a=_TL("abcxyz"); sl@0: test(a.Match(_TL("abc*"))==0); sl@0: test(a.Match(_TL("abw*"))==KErrNotFound); sl@0: a=_TL("abcdefg"); sl@0: test(a.Match(_TL("a*fg"))==0); sl@0: test(a.Match(_TL("a*f"))==KErrNotFound); sl@0: test(a.Match(_TL("abc*fgh"))==KErrNotFound); sl@0: a=_TL("abcdef"); sl@0: test(a.Match(_TL("abc?ef"))==0); sl@0: test(a.Match(_TL("abc?xf"))==KErrNotFound); sl@0: sl@0: a=_TL("a(01)"); sl@0: test(a.Match(_TL("*(01)"))==1); sl@0: test(a.Match(_TL("?(01)"))==0); sl@0: test(a.Match(_TL("?(*)"))==0); sl@0: test(a.Match(_TL("?(**)"))==0); sl@0: sl@0: test(a.Match(_TL("?(\?\?)"))==0); sl@0: test(a.Match(_TL("*(*)"))>=0); sl@0: test(a.Match(_TL("*(0?)"))>=0); sl@0: test(a.Match(_TL("a(\?\?)"))==0); sl@0: test(a.Match(_TL("*(\?\?)"))>=0); sl@0: sl@0: test.Next(_L("wild cards with collated comparison")); sl@0: a = _TL("abcdefghijkl"); sl@0: test(a.MatchC(_TL("abc*")) == 0); sl@0: test(a.MatchC(_TL("abc")) == KErrNotFound); sl@0: test(a.MatchC(_TL("xyz")) == KErrNotFound); sl@0: test(a.MatchC(_TL("*def")) == KErrNotFound); sl@0: test(a.MatchC(_TL("*def*")) == 3); sl@0: test(a.MatchC(_TL("*d?f*")) == 3); sl@0: test(a.MatchC(_TL("a*kl")) == 0); sl@0: test(a.MatchC(_TL("*e*?l")) == 4); sl@0: test(a.MatchC(_TL("abc*dEf*")) == 0); sl@0: sl@0: T candidate(_TL("")); sl@0: T search(_TL("**")); sl@0: sl@0: test(candidate.MatchC(search) == 0); sl@0: sl@0: candidate = _TL(""); sl@0: search = _TL("*"); sl@0: test(candidate.MatchC(search) == 0); sl@0: sl@0: candidate = _TL("abcd"); sl@0: search = _TL("*abc*cd"); sl@0: test(candidate.MatchC(search) == KErrNotFound); sl@0: sl@0: if (sizeof(S) == 2) sl@0: { sl@0: test.Next(_L("Unicode MatchC and FindC treat base+accent as equal to composed character")); sl@0: LString16 p = _L("te\x302te"); sl@0: test(p.MatchC(_L("t\xeate")) == 0); sl@0: test(p.FindC(_L("t\xeate")) == 0); sl@0: } sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4018 sl@0: @SYMTestCaseDesc Tests LString Locate() methods sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the LocateX() sl@0: methods to search for a character within the LString sl@0: Verifies that LocateX() methods works as expected sl@0: @SYMTestExpectedResults LString LocateX() method should return offset sl@0: of the character position from the beginning of the data or sl@0: KErrNotFound if no matching character can be found. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test10() sl@0: // Locating sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4018")); sl@0: sl@0: T a(iMaxBufLength); sl@0: TChar b; sl@0: sl@0: test.Next(_L("First Char")); sl@0: sl@0: b='a'; sl@0: a=_TL("axaxa"); sl@0: test(a.Locate(b)==0); sl@0: test(a.LocateF(b)==0); sl@0: test(a.LocateReverse(b)==4); sl@0: test(a.LocateReverseF(b)==4); sl@0: sl@0: test.Next(_L("Middle Char")); sl@0: a=_TL("xaxa"); sl@0: test(a.Locate(b)==1); sl@0: test(a.LocateF(b)==1); sl@0: a=_TL("axax"); sl@0: test(a.LocateReverse(b)==2); sl@0: test(a.LocateReverseF(b)==2); sl@0: sl@0: test.Next(_L("Last Char")); sl@0: a=_TL("xxa"); sl@0: test(a.Locate(b)==2); sl@0: test(a.LocateF(b)==2); sl@0: a=_TL("axx"); sl@0: test(a.LocateReverse(b)==0); sl@0: test(a.LocateReverseF(b)==0); sl@0: sl@0: test.Next(_L("Test for failure of locate")); sl@0: a=_TL("xxx"); sl@0: test(a.Locate(b)==KErrNotFound); sl@0: test(a.LocateF(b)==KErrNotFound); sl@0: test(a.LocateReverse(b)==KErrNotFound); sl@0: test(a.LocateReverseF(b)==KErrNotFound); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4019 sl@0: @SYMTestCaseDesc Tests LString CopyX() methods sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the CopyX() sl@0: methods to copy data into the strings. sl@0: Verifies that the length and contents of the LString sl@0: are as expefcted sl@0: @SYMTestExpectedResults LString CopyX() methods should copy data into sl@0: LString as expected sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test11L() sl@0: // Copying sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4019")); sl@0: sl@0: test.Next(_L("By String")); sl@0: sl@0: T a(iMaxBufLength); sl@0: T b(iMaxBufLength); sl@0: sl@0: a.CopyL(_TL("abc")); sl@0: test(a.Length()==3); sl@0: test(a==_TL("abc")); sl@0: a.CopyFL(_TL("abc")); sl@0: test(a.Length()==3); sl@0: b.CopyFL(_TL("ABC")); sl@0: test(a==b); sl@0: a.CopyLCL(_TL("AbC")); sl@0: test(a==_TL("abc")); sl@0: test(a.Length()==3); sl@0: a.CopyCL(_TL("abc")); sl@0: b.CopyCL(_TL("ABC")); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: a.CopyCPL(_TL("abc")); sl@0: test(a==_TL("Abc")); sl@0: test(a.Length()==3); sl@0: a.CopyUCL(_TL("aBc")); sl@0: test(a==_TL("ABC")); sl@0: test(a.Length()==3); sl@0: sl@0: test.Next(_L("By buffer")); sl@0: b=_TL("abc"); sl@0: a.CopyL(b); sl@0: test(a==_TL("abc")); sl@0: test(a.Length()==3); sl@0: a=_TL(""); sl@0: a.CopyFL(b); sl@0: b.CopyFL(_TL("ABC")); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: a=_TL(""); sl@0: b=_TL("AbC"); sl@0: a.CopyLCL(b); sl@0: test(a==_TL("abc")); sl@0: test(a.Length()==3); sl@0: a=_TL(""); sl@0: b=_TL("abC"); sl@0: a.CopyCL(b); sl@0: b.CopyCL(_TL("ABC")); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: a=_TL(""); sl@0: b=_TL("abC"); sl@0: a.CopyCPL(b); sl@0: test(a==_TL("Abc")); sl@0: test(a.Length()==3); sl@0: a=_TL(""); sl@0: b=_TL("aBc"); sl@0: a.CopyUCL(b); sl@0: test(a.Length()==3); sl@0: test(a==_TL("ABC")); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4020 sl@0: @SYMTestCaseDesc Tests LString FindX() methods sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the FindX() sl@0: methods to find substrings. sl@0: Verifies that the index of the substring returned is as expected sl@0: @SYMTestExpectedResults LString FindX() methods should return the index of the first sl@0: character of the substring if it exists in the LString otherwise sl@0: return KErrNotFound. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test12() sl@0: // Finding sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4020")); sl@0: sl@0: test.Next(_L("By String")); sl@0: sl@0: T a(iMaxBufLength); sl@0: T b(iMaxBufLength); sl@0: sl@0: a=_TL("abccef"); sl@0: test(a.Find(_TL(""))==0); sl@0: test(a.Find(_TL("abc"))==0); sl@0: test(a.Find(_TL("cce"))==2); sl@0: test(a.Find(_TL("cef"))==3); sl@0: test(a.Find(_TL("efg"))==KErrNotFound); sl@0: test(a.Find(_TL("xxx"))==KErrNotFound); sl@0: test(a.FindF(_TL(""))==0); sl@0: test(a.FindF(_TL("AbC"))==0); sl@0: test(a.FindF(_TL("CcE"))==2); sl@0: test(a.FindF(_TL("CeF"))==3); sl@0: test(a.FindF(_TL("efg"))==KErrNotFound); sl@0: test(a.FindF(_TL("xxx"))==KErrNotFound); sl@0: test(a.FindC(_TL(""))==0); sl@0: test(a.FindC(_TL("aBc"))==0); sl@0: test(a.FindC(_TL("cce"))==2); sl@0: test(a.FindC(_TL("cEf"))==3); sl@0: test(a.FindC(_TL("efg"))==KErrNotFound); sl@0: test(a.FindC(_TL("xxx"))==KErrNotFound); sl@0: sl@0: test.Next(_L("By buffer")); sl@0: test(a.Find(b)==0); sl@0: test(a.FindF(b)==0); sl@0: test(a.FindC(b)==0); sl@0: b=_TL("xxx"); sl@0: test(a.Find(b)==KErrNotFound); sl@0: test(a.FindF(b)==KErrNotFound); sl@0: test(a.FindC(b)==KErrNotFound); sl@0: b=_TL("efg"); sl@0: test(a.Find(b)==KErrNotFound); sl@0: test(a.FindF(b)==KErrNotFound); sl@0: test(a.FindC(b)==KErrNotFound); sl@0: b=_TL("abc"); sl@0: test(a.Find(b)==0); sl@0: b=_TL("cce"); sl@0: test(a.Find(b)==2); sl@0: b=_TL("cef"); sl@0: test(a.Find(b)==3); sl@0: b=_TL("AbC"); sl@0: test(a.FindF(b)==0); sl@0: b=_TL("CcE"); sl@0: test(a.FindF(b)==2); sl@0: b=_TL("CeF"); sl@0: test(a.FindF(b)==3); sl@0: b=_TL("aBc"); sl@0: test(a.FindC(b)==0); sl@0: b=_TL("cCe"); sl@0: test(a.FindC(b)==2); sl@0: b=_TL("cEf"); sl@0: test(a.FindC(b)==3); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4021 sl@0: @SYMTestCaseDesc Tests LString modification methods sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the Repeat(), sl@0: TrimX(), InsertL(), Delete(), Left(), Right() and Mid() methods sl@0: to modify the string. sl@0: Verifies that the LString is modified as expected sl@0: @SYMTestExpectedResults LString modification methods should modify the LString sl@0: data as expected. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test13L() sl@0: // Basic like ops sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4021")); sl@0: sl@0: test.Next(_L("Repeat, trim, insert and delete")); sl@0: sl@0: T a(iMaxBufLength); sl@0: T b(iMaxBufLength); sl@0: TInt max=a.MaxLength(); sl@0: b=_TL("abc"); sl@0: a.Repeat(_TL("abc")); sl@0: test(a==_TL("")); sl@0: a.Repeat(b); sl@0: test(a==_TL("")); sl@0: for (TInt j=1;j sl@0: GLDEF_C void TestLString::Test14L() sl@0: // Formating operations sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4022")); sl@0: sl@0: test.Next(_L("Justify")); sl@0: //---------------------------Apepend+Justify----------------------------------- sl@0: T a(1); sl@0: T b(1); sl@0: T d(1); sl@0: sl@0: TInt aWidth; sl@0: TChar c; sl@0: a=_TL("wxyz"); sl@0: b=_TL("abc"); sl@0: d=_TL("linearisation"); sl@0: const S* pD=_TS("299792458"); sl@0: c='x'; sl@0: aWidth=KDefaultJustifyWidth; // Left justified, Default width sl@0: a.JustifyL(b,aWidth,ELeft,c); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: a.AppendJustifyL(b,aWidth,ELeft,c); sl@0: test(a==_TL("abcabc")); sl@0: test(a.Length()==6); sl@0: aWidth=1; // Width < String length sl@0: a.JustifyL(b,aWidth,ELeft,c); sl@0: test(a==_TL("a")); sl@0: test(a.Length()==1); sl@0: a.AppendJustifyL(b,aWidth,ELeft,c); sl@0: test(a==_TL("aa")); sl@0: test(a.Length()==2); sl@0: aWidth=5; // Width > String length sl@0: a.JustifyL(b,aWidth,ELeft,c); sl@0: test(a==_TL("abcxx")); sl@0: test(a.Length()==5); sl@0: a.AppendJustifyL(b,aWidth,ELeft,c); sl@0: test(a==_TL("abcxxabcxx")); sl@0: test(a.Length()==10); sl@0: sl@0: aWidth=KDefaultJustifyWidth; // Right justified, Default width sl@0: a.JustifyL(b,aWidth,ERight,c); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: a.AppendJustifyL(b,aWidth,ERight,c); sl@0: test(a==_TL("abcabc")); sl@0: test(a.Length()==6); sl@0: sl@0: aWidth=1; // Right justified, Width < String length sl@0: a.JustifyL(b,aWidth,ERight,c); sl@0: test(a==_TL("a")); sl@0: test(a.Length()==1); sl@0: a.AppendJustifyL(b,aWidth,ERight,c); sl@0: test(a==_TL("aa")); sl@0: test(a.Length()==2); sl@0: sl@0: aWidth=5; // Right justified, width > String length sl@0: a.JustifyL(b,aWidth,ERight,c); sl@0: test(a==_TL("xxabc")); sl@0: test(a.Length()==5); sl@0: a.AppendJustifyL(b,aWidth,ERight,c); sl@0: test(a==_TL("xxabcxxabc")); sl@0: test(a.Length()==10); sl@0: sl@0: aWidth=KDefaultJustifyWidth; // Center justified, Default width sl@0: a.JustifyL(b,aWidth,ECenter,c); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: a.AppendJustifyL(b,aWidth,ECenter,c); sl@0: test(a==_TL("abcabc")); sl@0: test(a.Length()==6); sl@0: sl@0: aWidth=1; // Centre justified, width < String length sl@0: a.JustifyL(b,aWidth,ECenter,c); sl@0: test(a==_TL("a")); sl@0: test(a.Length()==1); sl@0: a.AppendJustifyL(b,aWidth,ECenter,c); sl@0: test(a==_TL("aa")); sl@0: test(a.Length()==2); sl@0: sl@0: aWidth=5; // Centre justified, width > String length sl@0: a.JustifyL(b,aWidth,ECenter,c); sl@0: test(a==_TL("xabcx")); sl@0: test(a.Length()==5); sl@0: a.AppendJustifyL(b,aWidth,ECenter,c); sl@0: test(a==_TL("xabcxxabcx")); sl@0: test(a.Length()==10); sl@0: sl@0: //----------------------Num---------------------------------------------------- sl@0: test.Next(_L("Num")); sl@0: TInt j=-2147483647-1; sl@0: a.NumL(j); sl@0: test(a==_TL("-2147483648")); sl@0: test(a.Length()==11); sl@0: TUint i=2147483648u; sl@0: a.NumL(i); sl@0: test(a==_TL("2147483648")); sl@0: test(a.Length()==10); sl@0: if (a.MaxLength()>31) sl@0: { sl@0: a.NumL(i,EBinary); sl@0: test(a==_TL("10000000000000000000000000000000")); sl@0: test(a.Length()==32); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EBinary); sl@0: test(a==_TL("10000000000000000000000000000000")); sl@0: test(a.Length()==32); sl@0: } sl@0: i=31; sl@0: a.NumL(i,EBinary); sl@0: test(a==_TL("11111")); sl@0: test(a.Length()==5); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EBinary); sl@0: test(a==_TL("11111")); sl@0: test(a.Length()==5); sl@0: i=2147483648u; sl@0: a.NumL(i,EOctal); sl@0: test(a==_TL("20000000000")); sl@0: test(a.Length()==11); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EOctal); sl@0: test(a==_TL("20000000000")); sl@0: test(a.Length()==11); sl@0: a.NumL(i,EDecimal); sl@0: test(a==_TL("2147483648")); sl@0: test(a.Length()==10); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EDecimal); sl@0: test(a==_TL("2147483648")); sl@0: test(a.Length()==10); sl@0: a.NumL(i,EHex); sl@0: test(a==_TL("80000000")); sl@0: test(a.Length()==8); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EHex); sl@0: test(a==_TL("80000000")); sl@0: test(a.Length()==8); sl@0: i=0; sl@0: a.NumL(i); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL("abc"); sl@0: a.NumL(i,EBinary); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL("abc"); sl@0: a.NumUCL(i,EBinary); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL("abc"); sl@0: a.NumL(i,EOctal); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EOctal); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL("abc"); sl@0: a.NumL(i,EDecimal); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EDecimal); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL("abc"); sl@0: a.NumL(i,EHex); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: a=_TL(""); sl@0: a.NumUCL(i,EHex); sl@0: test(a==_TL("0")); sl@0: test(a.Length()==1); sl@0: sl@0: // TInt i=a.Num(6.2,format); NOT IMPLEMENTED sl@0: //----------------------AppendNum---------------------------------------------------- sl@0: test.Next(_L("AppendNum")); sl@0: a=_TL("0"); sl@0: a.AppendNumL(j); sl@0: test(a==_TL("0-2147483648")); sl@0: test(a.Length()==12); sl@0: sl@0: a=_TL("abc"); sl@0: i=4294967295u; sl@0: a.AppendNumL(i); sl@0: test(a==_TL("abc4294967295")); sl@0: test(a.Length()==13); sl@0: sl@0: j=2147483647; sl@0: a=_TL("abc"); sl@0: a.AppendNumL(j); sl@0: test(a==_TL("abc2147483647")); sl@0: test(a.Length()==13); sl@0: sl@0: a=_TL("a"); sl@0: i=180150000; sl@0: if (a.MaxLength()>28) sl@0: { sl@0: a.AppendNumL(i,EBinary); sl@0: test(a==_TL("a1010101111001101111011110000")); sl@0: test(a.Length()==29); sl@0: } sl@0: a=_TL("a"); sl@0: a.AppendNumL(15,EBinary); sl@0: test(a==_TL("a1111")); sl@0: test(a.Length()==5); sl@0: sl@0: a=_TL("a"); sl@0: a.AppendNumL(i,EDecimal); sl@0: test(a==_TL("a180150000")); sl@0: test(a.Length()==10); sl@0: sl@0: a=_TL("a"); sl@0: a.AppendNumL(i,EOctal); sl@0: test(a==_TL("a1257157360")); sl@0: test(a.Length()==11); sl@0: sl@0: a=_TL("a"); sl@0: a.AppendNumUCL(i,EHex); sl@0: test(a==_TL("aABCDEF0")); sl@0: test(a.Length()==8); sl@0: sl@0: sl@0: a=_TL("a"); sl@0: a.AppendNumFixedWidthL(i,EHex,3); sl@0: test(a==_TL("aabc")); sl@0: test(a.Length()==4); sl@0: sl@0: a=_TL("a"); sl@0: a.AppendNumFixedWidthUCL(i,EHex,4); sl@0: test(a==_TL("aABCD")); sl@0: test(a.Length()==5); sl@0: sl@0: sl@0: //----------------------Format---------------------------------------------------- sl@0: test.Next(_L("Format")); sl@0: a=_TL(""); sl@0: b=_TL("cde"); sl@0: a.FormatL(_TL("%S"),&b); sl@0: test(a==b); sl@0: test(a.Length()==3); sl@0: sl@0: DESTEMPLATE xyz=_TL("xyzwpq"); sl@0: a.FormatL(_TL("%S"),&xyz); sl@0: test(a==_TL("xyzwpq")); sl@0: test(a.Length()==6); sl@0: sl@0: DESTEMPLATE cde=_TL("cde"); sl@0: a.FormatL(_TL("ab %-x5S"),&cde); sl@0: test(a==_TL("ab cdexx")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %=x5S"),&cde); sl@0: test(a==_TL("ab xcdex")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %+x5S"),&cde); sl@0: test(a==_TL("ab xxcde")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %5S"),&cde); sl@0: test(a==_TL("ab cde")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %-**S"),'x',5,&cde); sl@0: test(a==_TL("ab cdexx")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %*S"),5,&cde); sl@0: test(a==_TL("ab cde")); sl@0: test(a.Length()==8); sl@0: sl@0: a=_TL("xyz"); sl@0: a.FormatL(_TL("ab %-x5S"),&b); sl@0: test(a==_TL("ab cdexx")); sl@0: test(a.Length()==8); sl@0: sl@0: a=_TL("xyz"); sl@0: a.FormatL(_TL("ab %-**S"),'x',5,&b); sl@0: test(a==_TL("ab cdexx")); sl@0: test(a.Length()==8); sl@0: sl@0: a=_TL("xyz"); sl@0: a.FormatL(_TL("ab %*S"),5,&b); sl@0: test(a==_TL("ab cde")); sl@0: test(a.Length()==8); sl@0: sl@0: DESTEMPLATE fred=_TL("fred"); sl@0: a.FormatL(_TL("%+0*S"),10,&fred); sl@0: test(a==_TL("000000fred")); sl@0: test(a.Length()==10); sl@0: sl@0: a.FormatL(_TL("%-0*S"),7,&fred); sl@0: test(a==_TL("fred000")); sl@0: test(a.Length()==7); sl@0: sl@0: a.FormatL(_TL("%0*S"),11,&fred); sl@0: test(a==_TL("0000000fred")); sl@0: test(a.Length()==11); sl@0: sl@0: a.FormatL(_TL("c=%s"),pD); sl@0: TESTEQ(a,_TL("c=299792458")); sl@0: sl@0: a.FormatL(_TL("c=%10.6s"),pD); sl@0: test(a==_TL("c= 299792")); sl@0: sl@0: a.FormatL(_TL("c=%*.*s"),5,4,pD); sl@0: test(a==_TL("c= 2997")); sl@0: sl@0: a.FormatL(_TL("%S"),&d); sl@0: test(a==_TL("linearisation")); sl@0: sl@0: a.FormatL(_TL("%10.6S"),&d); sl@0: test(a==_TL(" linear")); sl@0: sl@0: a.FormatL(_TL("%*.*S"),5,4,&d); sl@0: test(a==_TL(" line")); sl@0: sl@0: a.FormatL(_TL("%*.*Sed"),10,8,&d); sl@0: test(a==_TL(" linearised")); sl@0: sl@0: a.FormatL(_TL("%*.*S"),14,20,&d); sl@0: test(a==_TL(" linearisation")); sl@0: sl@0: a.FormatL(_TL("ab %-,5b"),7); sl@0: test(a==_TL("ab 111,,")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %=,5O"),31); sl@0: test(a==_TL("ab ,37,,")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %+xlx"),TInt64(171)); sl@0: test(a==_TL("ab ab")); sl@0: test(a.Length()==5); sl@0: sl@0: a.FormatL(_TL("ab %+xlX %+xlx"),TInt64(171),TInt64(171)); sl@0: TESTEQ(a,_TL("ab AB ab")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab %lu"),MAKE_TINT64((TUint)(KMinTInt),0)); sl@0: test(a==_TL("ab 9223372036854775808")); sl@0: test(a.Length()==22); sl@0: sl@0: a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),1)); sl@0: test(a==_TL("ab -9223372036854775807")); sl@0: test(a.Length()==23); sl@0: sl@0: a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),0)); sl@0: test(a==_TL("ab -9223372036854775808")); sl@0: test(a.Length()==23); sl@0: sl@0: a.FormatL(_TL("ab %ld"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint)); sl@0: test(a==_TL("ab 9223372036854775807")); sl@0: test(a.Length()==22); sl@0: sl@0: a.FormatL(_TL("ab %ld"),MAKE_TINT64(KMaxTUint,KMaxTUint)); sl@0: test(a==_TL("ab -1")); sl@0: test(a.Length()==5); sl@0: sl@0: a.FormatL(_TL("ab %lu"),MAKE_TINT64(KMaxTUint,KMaxTUint)); sl@0: test(a==_TL("ab 18446744073709551615")); sl@0: test(a.Length()==23); sl@0: sl@0: a.FormatL(_TL("ab %ld"),TInt64(0)); sl@0: test(a==_TL("ab 0")); sl@0: test(a.Length()==4); sl@0: sl@0: a.FormatL(_TL("ab %lb"),TInt64(0)); sl@0: test(a==_TL("ab 0")); sl@0: test(a.Length()==4); sl@0: sl@0: a.FormatL(_TL("ab %lx"),TInt64(0)); sl@0: test(a==_TL("ab 0")); sl@0: test(a.Length()==4); sl@0: sl@0: a.FormatL(_TL("ab %lo"),TInt64(0)); sl@0: test(a==_TL("ab 0")); sl@0: test(a.Length()==4); sl@0: sl@0: a.FormatL(_TL("ab %lu"),TInt64(0)); sl@0: test(a==_TL("ab 0")); sl@0: test(a.Length()==4); sl@0: sl@0: a.FormatL(_TL("ab %lb"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint)); sl@0: test(a==_TL("ab 111111111111111111111111111111111111111111111111111111111111111")); sl@0: test(a.Length()==66); sl@0: sl@0: a.FormatL(_TL("ab %lb"),MAKE_TINT64(KMaxTUint,KMaxTUint)); sl@0: test(a==_TL("ab 1111111111111111111111111111111111111111111111111111111111111111")); sl@0: test(a.Length()==67); sl@0: sl@0: a.FormatL(_TL("ab %lx"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint)); sl@0: test(a==_TL("ab 7fffffffffffffff")); sl@0: test(a.Length()==19); sl@0: sl@0: a.FormatL(_TL("ab %lx"),MAKE_TINT64(KMaxTUint,KMaxTUint)); sl@0: test(a==_TL("ab ffffffffffffffff")); sl@0: test(a.Length()==19); sl@0: sl@0: a.FormatL(_TL("ab %lo"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint)); sl@0: test(a==_TL("ab 777777777777777777777")); sl@0: test(a.Length()==24); sl@0: sl@0: // tests which excercise any 8 byte alignment requirement on 64bit integers sl@0: a.FormatL(_TL("%li%S"),MAKE_TINT64(1,2),&fred); sl@0: test(a==_TL("4294967298fred")); sl@0: sl@0: a.FormatL(_TL("%S%li%S"),&fred,MAKE_TINT64(1,2),&fred); sl@0: test(a==_TL("fred4294967298fred")); sl@0: sl@0: a.FormatL(_TL("%lu%S"),MAKE_TINT64(1,2),&fred); sl@0: test(a==_TL("4294967298fred")); sl@0: sl@0: a.FormatL(_TL("%S%lu%S"),&fred,MAKE_TINT64(1,2),&fred); sl@0: test(a==_TL("fred4294967298fred")); sl@0: sl@0: a.FormatL(_TL("ab %U"),233); sl@0: test(a==_TL("ab 233")); sl@0: test(a.Length()==6); sl@0: sl@0: a.FormatL(_TL("ab %*d"),5,-131); sl@0: test(a==_TL("ab -131")); sl@0: test(a.Length()==8); sl@0: sl@0: a.FormatL(_TL("ab%c"),'x'); sl@0: test(a==_TL("abx")); sl@0: test(a.Length()==3); sl@0: sl@0: a.FormatL(_TL("%W"),-131); sl@0: test(*(TInt32*)a.Ptr()==-131); sl@0: sl@0: a.FormatL(_TL("%M"),-131); sl@0: test(*(TInt32*)a.Ptr()==2113929215); sl@0: sl@0: a.FormatL(_TL("%w"),-131); sl@0: test(*(TInt16*)a.Ptr()==-131); sl@0: sl@0: a.FormatL(_TL("%m"),-131); sl@0: test(*(TInt16*)a.Ptr()==32255); sl@0: sl@0: //----------------------AppendFormat---------------------------------------------------- sl@0: a=_TL("xyz"); sl@0: a.AppendFormatL(_TL("ab %+xlx"),TInt64(171)); sl@0: test(a==_TL("xyzab ab")); sl@0: test(a.Length()==8); sl@0: sl@0: a=_TL("xyz"); sl@0: a.AppendFormatL(_TL("ab %5S"),&b); sl@0: test(a==_TL("xyzab cde")); sl@0: test(a.Length()==11); sl@0: sl@0: a=_TL("xyz"); sl@0: a.AppendFormatL(_TL("%W"),-131); sl@0: // test(*(TInt32*)(a.Ptr()+3)==-131); // Alignment-safe version: sl@0: TInt val; sl@0: Mem::Copy(&val,&a[3],4); sl@0: test(val==-131); sl@0: sl@0: // Cannot do this on GCCE or ARMv5 because of sl@0: // "Cannot pass objects of non-POD type through '...'. sl@0: // Call will abort at runtime". sl@0: sl@0: #ifdef __WINSCW__ sl@0: const TAny* const zeroTerminatedString=(sizeof(S)==2)? (const TAny*)_S16(":-)E"): (const TAny*)_S8(":-)E"); sl@0: const TInt dummyParameter=0; sl@0: b=_TL("ebdb"); sl@0: Test14_ReorderedParameterFormattingL(dummyParameter, 0x20ac, 11, 3, 13.89543, zeroTerminatedString, '!', TInt64(199), 2, &b, 6, 30005, TRealX(0.125), 0x8bdd); sl@0: #endif sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4024 sl@0: @SYMTestCaseDesc Tests LString leaving variant FormatListL() method sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the LString FormatListL() method sl@0: to format the string. sl@0: Verifies that the LString is formatted as expected sl@0: @SYMTestExpectedResults LString FormatListL() method should work as expected sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test14_ReorderedParameterFormattingL(TInt aDummyParameter, ...) sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4024")); sl@0: sl@0: VA_LIST parameterList; sl@0: T generated(1); sl@0: T expected(1); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%-**.*fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%.3Fyyyyyyy%c"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeeeebrrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(generated.Length()-1)==expected); sl@0: test(generated[generated.Length()-1]==(S)0x8bdd); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%$1$-**.*fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%$6$.3Fyyyyyyy%c"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeeeebrrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(generated.Length()-1)==expected); sl@0: test(generated[generated.Length()-1]==(S)0x8bdd); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%$6$.3Fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%$1$-**.*fyyyyyyy%c"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\t0.125qq:-)www!!199eeeeebrrrrr007535tttttt13.895%c%c%c%c%cyyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(generated.Length()-1)==expected); sl@0: test(generated[generated.Length()-1]==(S)0x8bdd); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%-**.*fqq%.3swww%$5$0*xeeee%.*Srrrrr%$3$+*5Ldtttttt%.3Fyyyyyyy%c"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www007535eeeeebrrrrr!!199tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(generated.Length()-1)==expected); sl@0: test(generated[generated.Length()-1]==(S)0x8bdd); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%-**.*fqq%$4$.*Swww%+*5Ldeeee%$2$.3srrrrr%0*xtttttt%.3Fyyyyyyy%c"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\t13.895%c%c%c%c%cqqebwww!!199eeee:-)rrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(generated.Length()-1)==expected); sl@0: test(generated[generated.Length()-1]==(S)0x8bdd); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%-**.*fqq%.3swww%+*5Ldeeee%$7$crrrrr%0*xtttttt%.3Fyyyyyyy%$4$.*S"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeee"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(29)==expected); sl@0: test(generated[29]==(S)0x8bdd); sl@0: test(generated.Mid(29+1)==_TL("rrrrr007535tttttt0.125yyyyyyyeb")); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%$4$.*Sqq%.3swww%+*5Ldeeee%$6$.3Frrrrr%0*xtttttt%$1$-**.*fyyyyyyy%c"), parameterList); sl@0: test(generated.Length()==61); sl@0: expected.FormatL(_TL("\tebqq:-)www!!199eeee0.125rrrrr007535tttttt13.895%c%c%c%c%cyyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Left(generated.Length()-1)==expected); sl@0: test(generated[generated.Length()-1]==(S)0x8bdd); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%$7$cqq%$6$.3Fwww%$5$0*xeeee%.*Srrrrr%$3$+*5Ldtttttt%$2$.3syyyyyyy%$1$-**.*f"), parameterList); sl@0: test(generated.Length()==61); sl@0: test(generated.Left(1)==_TL("\t")); sl@0: test(generated[1]==(S)0x8bdd); sl@0: expected.FormatL(_TL("qq0.125www007535eeeeebrrrrr!!199tttttt:-)yyyyyyy13.895%c%c%c%c%c"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Mid(2)==expected); sl@0: sl@0: VA_START(parameterList, aDummyParameter); sl@0: generated.FormatListL(_TL("\t%$7$cqq%$6$.3Fwww%$5$0*xeeee%$4$.*Srrrrr%$3$+*5Ldtttttt%$2$.3syyyyyyy%$1$-**.*f"), parameterList); sl@0: test(generated.Length()==61); sl@0: test(generated.Left(1)==_TL("\t")); sl@0: test(generated[1]==(S)0x8bdd); sl@0: expected.FormatL(_TL("qq0.125www007535eeeeebrrrrr!!199tttttt:-)yyyyyyy13.895%c%c%c%c%c"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac); sl@0: test(generated.Mid(2)==expected); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4025 sl@0: @SYMTestCaseDesc Tests LString ReplaceL() method sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the ReplaceL() method sl@0: to replace the string data. sl@0: Verifies that the LString data is replaced as expected sl@0: @SYMTestExpectedResults LString ReplaceL() method should replace data sl@0: in the LString as expected. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: GLDEF_C void TestLString::Test15L() sl@0: // Replacing sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4025")); sl@0: sl@0: test.Next(_L("Replace")); sl@0: T a(1); sl@0: T b(1); sl@0: test(a.MaxLength()>=1); sl@0: a=_TL("abccccc"); sl@0: b=_TL("def"); sl@0: a.ReplaceL(3,4,b); // Replace with smaller in middle (insert and delete) sl@0: test(a==_TL("abcdef")); sl@0: a.ReplaceL(1,1,b); // Replace with larger in middle (insert and delete) sl@0: test(a==_TL("adefcdef")); sl@0: a.ReplaceL(0,8,_TL("")); // Replace complete string (delete) sl@0: test(a==_TL("")); sl@0: a.ReplaceL(0,0,b); // Replace at beginning (insert) sl@0: test(a==b); sl@0: a.ReplaceL(3,0,_TL("xyz")); // Replace at end (append) sl@0: test(a==_TL("defxyz")); sl@0: a.ReplaceL(0,0,_TL("")); // Replace nothing at beginning (do nothing) sl@0: test(a==_TL("defxyz")); sl@0: a.ReplaceL(6,0,_TL("")); // Replace nothing at end (do nothing) sl@0: test(a==_TL("defxyz")); sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: template sl@0: GLDEF_C void TestLString::test_TBufL() sl@0: // Test the TBuf class. sl@0: { sl@0: test.Start(_L("All operations")); sl@0: Test1L(); sl@0: test.Next(_L("Constructors")); sl@0: Test2(); sl@0: test.Next(_L("Additional tests")); sl@0: Test3(); sl@0: test.Next(_L("Comparison operators")); sl@0: Test4(); sl@0: test.Next(_L("Conversion operators")); sl@0: Test7(); sl@0: test.Next(_L("Comparison")); sl@0: Test8(); sl@0: test.Next(_L("Matching")); sl@0: Test9(); sl@0: test.Next(_L("Locating")); sl@0: Test10(); sl@0: test.Next(_L("Copying")); sl@0: Test11L(); sl@0: test.Next(_L("Finding")); sl@0: Test12(); sl@0: test.Next(_L("Basic like ops")); sl@0: Test13L(); sl@0: test.Next(_L("Leaving variants of Formating")); sl@0: Test14L(); sl@0: sl@0: test.Next(_L("Leaving variants of Replacing")); sl@0: Test15L(); sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4026 sl@0: @SYMTestCaseDesc Tests LString FormatL() method sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the FormatL() method sl@0: to format the string data. sl@0: Verifies that the LString data is formatted as expected sl@0: @SYMTestExpectedResults LString FormatL() method should format data sl@0: in the LString as expected. sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: LOCAL_C void testFormatL() sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4026")); sl@0: sl@0: //TBuf<0x100> aa; sl@0: T aa(1); sl@0: aa.FormatL(_TL("x%- 5fx"), 6.2345678); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x%+ 5fx"), 6.2345678); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x% 5fx"), 6.2345678); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x%= 5fx"), 6.2345678); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x%- 10fx"), 6.2345); sl@0: test(aa==_TL("x6.234500 x")); sl@0: aa.FormatL(_TL("x%+ 10fx"), 6.2345); sl@0: test(aa==_TL("x 6.234500x")); sl@0: aa.FormatL(_TL("x% 10fx"), 6.2345); sl@0: test(aa==_TL("x 6.234500x")); sl@0: aa.FormatL(_TL("x%= 10fx"), 6.2345); sl@0: test(aa==_TL("x 6.234500 x")); sl@0: aa.FormatL(_TL("x%10fx"), 12345352342.545); sl@0: test(aa==_TL("x12,345,352,342.545000x")); sl@0: aa.FormatL(_TL("x%20.9fx"), 1.0123456789); sl@0: test(aa==_TL("x 1.012345679x")); sl@0: aa.FormatL(_TL("x%5.1fx"), 1.99); sl@0: test(aa==_TL("x 2.0x")); sl@0: sl@0: // Cannot do these on GCCE or ARMv5 because of sl@0: // "Cannot pass objects of non-POD type through '...'. sl@0: // Call will abort at runtime". sl@0: #ifdef __WINSCW__ sl@0: aa.FormatL(_TL("x%- 5Fx"), TRealX(6.2345678)); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x%+ 5Fx"), TRealX(6.2345678)); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x% 5Fx"), TRealX(6.2345678)); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x%= 5Fx"), TRealX(6.2345678)); sl@0: test(aa==_TL("x6.234568x")); sl@0: aa.FormatL(_TL("x%- 10Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x6.234500 x")); sl@0: aa.FormatL(_TL("x%+ 10Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x 6.234500x")); sl@0: aa.FormatL(_TL("x% 10Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x 6.234500x")); sl@0: aa.FormatL(_TL("x%+010Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x006.234500x")); sl@0: aa.FormatL(_TL("x%+10Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x 6.234500x")); sl@0: aa.FormatL(_TL("x%10Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x 6.234500x")); sl@0: aa.FormatL(_TL("x%010Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x006.234500x")); sl@0: aa.FormatL(_TL("x%= 10Fx"), TRealX(6.2345)); sl@0: test(aa==_TL("x 6.234500 x")); sl@0: aa.FormatL(_TL("x%10Fx"), TRealX(12345352342.545)); sl@0: test(aa==_TL("x12,345,352,342.545000x")); sl@0: aa.FormatL(_TL("x%20.9Fx"), TRealX(1.0123456789)); sl@0: test(aa==_TL("x 1.012345679x")); sl@0: aa.FormatL(_TL("x%5.1Fx"), TRealX(1.99)); sl@0: test(aa==_TL("x 2.0x")); sl@0: #endif sl@0: sl@0: aa.FormatL(_TL("x%- 5ex"), 6.2345678); sl@0: test(aa==_TL("x6.234568E+00x")); sl@0: aa.FormatL(_TL("x%+ 5ex"), 6.2345678); sl@0: test(aa==_TL("x6.234568E+00x")); sl@0: aa.FormatL(_TL("x% 5ex"), 6.2345678); sl@0: test(aa==_TL("x6.234568E+00x")); sl@0: aa.FormatL(_TL("x%= 5ex"), 6.2345678); sl@0: test(aa==_TL("x6.234568E+00x")); sl@0: aa.FormatL(_TL("x%- 14ex"), 6.2345); sl@0: test(aa==_TL("x6.234500E+00 x")); sl@0: aa.FormatL(_TL("x%+ 14ex"), 6.2345); sl@0: test(aa==_TL("x 6.234500E+00x")); sl@0: aa.FormatL(_TL("x% 14ex"), 6.2345); sl@0: test(aa==_TL("x 6.234500E+00x")); sl@0: aa.FormatL(_TL("x%= 14ex"), 6.2345); sl@0: test(aa==_TL("x 6.234500E+00 x")); sl@0: aa.FormatL(_TL("x%10ex"), 12345352342.545); sl@0: test(aa==_TL("x1.234535E+10x")); sl@0: aa.FormatL(_TL("x%20.9ex"), 1.0123456789); sl@0: test(aa==_TL("x 1.012345679E+00x")); sl@0: aa.FormatL(_TL("x%5.1ex"), 1.99); sl@0: test(aa==_TL("x2.0E+00x")); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-EUSERHL-UT-4027 sl@0: @SYMTestCaseDesc Tests LString AppendFormatL() method sl@0: @SYMTestPriority High sl@0: @SYMTestActions Creates LString objects and uses the AppendFormatL() method sl@0: to format the string data with and without an overflow handler. sl@0: Verifies that the LString data is formatted as expected when using an sl@0: overflow handler. sl@0: @SYMTestExpectedResults LString AppendFormatL() method should format data sl@0: in the LString as expected with and without an overflow handler sl@0: @SYMREQ 10372 sl@0: */ sl@0: template sl@0: void testAppendFormatIgnoreOverflowL() sl@0: { sl@0: sl@0: test.Start (_L ("@SYMTestCaseID:SYSLIB-EUSERHL-UT-4027")); sl@0: sl@0: test.Next(_L("Test no overflow")); sl@0: sl@0: T buf(1); sl@0: buf.AppendFormatL(_TL("A Descriptor")); sl@0: test(buf==_TL("A Descriptor")); sl@0: sl@0: test.Next(_L("Test overflow with no conversions")); sl@0: buf.AppendFormatL(_TL("123456789")); sl@0: test(buf==_TL("A Descriptor123456789")); sl@0: sl@0: test.Next(_L("Force overflow with descriptor conversion")); sl@0: buf = _TL("Symbian OS"); sl@0: buf.Compress(); sl@0: sl@0: T buf2; sl@0: buf2 = _TL(" - This descriptor should cause overflow"); sl@0: buf.AppendFormatL(_TL("%S"),&buf2); sl@0: test(buf==_TL("Symbian OS - This descriptor should cause overflow")); sl@0: sl@0: test.End(); sl@0: sl@0: } sl@0: sl@0: #ifndef _DEBUG sl@0: #pragma warning( disable : 4702) //Unreachable code sl@0: #pragma warning( disable : 4710) //Function not expanded sl@0: #endif sl@0: sl@0: sl@0: void RunTestsL() sl@0: { sl@0: test.Next(_L("class LString8")); sl@0: TestLString a(0x50); sl@0: a.test_TBufL(); sl@0: sl@0: test.Next(_L("TReal formating with auto LString8 extension ")); sl@0: testFormatL(); sl@0: sl@0: test.Next(_L("class LString16")); sl@0: TestLString b(0x50); sl@0: b.test_TBufL(); sl@0: sl@0: test.Next(_L("TReal formating with auto LString16 extension ")); sl@0: testFormatL(); sl@0: sl@0: testAppendFormatIgnoreOverflowL(); sl@0: testAppendFormatIgnoreOverflowL(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // Test the TBuf type. sl@0: { sl@0: sl@0: CTrapCleanup* trapHandler=CTrapCleanup::New(); sl@0: test(trapHandler!=NULL); sl@0: sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Test Formating Functions")); sl@0: sl@0: TRAPD(err, RunTestsL()); sl@0: sl@0: test.End(); sl@0: sl@0: delete trapHandler; sl@0: sl@0: return(err); sl@0: sl@0: } sl@0: sl@0: //#pragma warning( default : 4702) sl@0: //#pragma warning( default : 4710) sl@0: sl@0: