os/kernelhwsrv/kerneltest/e32test/buffer/t_buf.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/buffer/t_buf.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1928 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\buffer\t_buf.cpp
    1.18 +// Overview:
    1.19 +// Test methods of the TBuf16, TBuf8, TBuf template class.
    1.20 +// API Information:
    1.21 +// TBuf16, TBuf8, TBuf.
    1.22 +// Details :
    1.23 +// - Create some 16 bit modifiable descriptors, 8 bit modifiable descriptors
    1.24 +// of fixed length, Build-independent modifiable descriptors, initialize 
    1.25 +// with different strings and check for
    1.26 +// - Comparison operators,
    1.27 +// - Property access methods,
    1.28 +// - Fill & swap methods,
    1.29 +// - Conversion methods,
    1.30 +// - Comparison methods,
    1.31 +// - Pattern Matching methods,
    1.32 +// - Pattern Locating methods,
    1.33 +// - Copying methods, 
    1.34 +// - Find, FindC, FindF methods,
    1.35 +// - Repeat, Trim, TrimLeft, TrimRight, Insert, Delete, Left,
    1.36 +// Right, Mid methods,
    1.37 +// - Formatting methods,
    1.38 +// - Replace methods are as expected.
    1.39 +// - Construct some descriptors with buffer length, string and buffer reference and
    1.40 +// verify that they are created successfully.
    1.41 +// - Test assignment operators and comparison operators for different descriptors.
    1.42 +// - Initialize some descriptors and check descriptors' maximum length, length and 
    1.43 +// size are as expected. 
    1.44 +// - Check Fill and Swap methods are as expected.
    1.45 +// - Test Fold, Collate, LowerCase, UpperCase methods are as expected.
    1.46 +// - Test Comparison methods are as expected.
    1.47 +// - Test pattern matching for simple string, wild cards with collated comparison. Verify that the 
    1.48 +// return value is KErrNotFound when pattern doesn't match.
    1.49 +// - Check Locating methods by searching character in forward and backward direction and 
    1.50 +// verify the return value is KErrNotFound when unavailable character is searched.
    1.51 +// - Check copying strings and converting those into lower and upper case strings are
    1.52 +// as expected.
    1.53 +// - Check Find methods by searching string and verify the return value is KErrNotFound when 
    1.54 +// unavailable string is searched.
    1.55 +// - Check Repeat, Trim, Insert and Delete methods are as expected.
    1.56 +// - Check the formatting operations are as expected.
    1.57 +// - Check integer to decimal character representation is as expected.
    1.58 +// - Check integer to character representation with different number system is as expected.
    1.59 +// - Check string formatting with variable parameter list is as expected
    1.60 +// - Check Replace method by replacing string at different places in a string is as expected.
    1.61 +// - Check the conversion of real numbers, extended precision real numbers into string
    1.62 +// format is as expected.
    1.63 +// - Check Format and FormatList methods are as expected.
    1.64 +// - Check Format of TReal is as expected.
    1.65 +// - Check the non-leaving and leaving descriptors overflow handlers are as expected. 
    1.66 +// Platforms/Drives/Compatibility:
    1.67 +// All 
    1.68 +// Assumptions/Requirement/Pre-requisites:
    1.69 +// Failures and causes:
    1.70 +// Base Port information:
    1.71 +// 
    1.72 +//
    1.73 +
    1.74 +#include <e32test.h>
    1.75 +#include <e32math.h>
    1.76 +#include <hal.h>
    1.77 +#include <hal_data.h>
    1.78 +#include <hal_data.h>
    1.79 +#include <e32svr.h>
    1.80 +
    1.81 +#ifdef __VC32__
    1.82 +    // Solve compilation problem caused by non-English locale
    1.83 +    #pragma setlocale("english")
    1.84 +#endif
    1.85 +
    1.86 +LOCAL_D RTest test(_L("T_BUF"));
    1.87 +
    1.88 +#pragma warning(disable: 4127) // disabling warning "conditional expression is constant"
    1.89 +#pragma warning(disable: 4310) // disabling warning "cast truncates constant value"
    1.90 +
    1.91 +#undef _TL
    1.92 +#define _TL(a) DESTEMPLATE((S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a)) 
    1.93 +#undef _TS
    1.94 +#define _TS(a) ((const S*)RTest::String(sizeof(S),(TText8*)a,(TText16*)L ## a)) 
    1.95 +
    1.96 +template<class T,class S,class DESTEMPLATE>	
    1.97 +class TestTBuf
    1.98 +	{
    1.99 +public:
   1.100 +	TestTBuf(TInt aLength); // Test class constructor.
   1.101 +	void Test1();   // Tests all functions of the class.
   1.102 +	void Test2();   // Tests all constructors.
   1.103 +	void Test3();	// Tests all assignment operators
   1.104 +	void Test4();	// Tests all comparison operators
   1.105 +	void Test5();	// Tests all property access
   1.106 +	void Test6();	// Tests all fill and swap
   1.107 +	void Test7();	// Tests all conversion 
   1.108 +	void Test8();	// Tests all comparison
   1.109 +	void Test9();	// Tests all matching
   1.110 +	void Test10();	// Tests all locating
   1.111 +	void Test11();	// Tests all Copying
   1.112 +	void Test12();	// Tests all finding
   1.113 +	void Test13();	// Tests all basic like ops
   1.114 +	void Test14();  // Tests all formating
   1.115 +	void Test15();  // Tests all replacing
   1.116 +	void test_TBuf(); // Test all classes
   1.117 +protected:
   1.118 +	void Test1List(T* a,T* b,...);
   1.119 +	void Test14_ReorderedParameterFormatting(TInt aDummyParameter, ...);
   1.120 +private:
   1.121 +	TInt iMaxBufLength;
   1.122 +	};
   1.123 +
   1.124 +void TestEq(const TDesC8& a, const TDesC8& b, TInt aLine)
   1.125 +	{
   1.126 +	if (a!=b)
   1.127 +		{
   1.128 +		TBuf<256> buf;
   1.129 +		test.Printf(_L("LINE %d:\n"),aLine);
   1.130 +		buf.Copy(a);
   1.131 +		test.Printf(_L("a=%S\n"),&buf);
   1.132 +		buf.Copy(b);
   1.133 +		test.Printf(_L("b=%S\n"),&buf);
   1.134 +		test(0);
   1.135 +		}
   1.136 +	}
   1.137 +
   1.138 +void TestEq(const TDesC16& a, const TDesC16& b, TInt aLine)
   1.139 +	{
   1.140 +	if (a!=b)
   1.141 +		{
   1.142 +		test.Printf(_L("LINE %d:\n"),aLine);
   1.143 +		test.Printf(_L("a=%S\n"),&a);
   1.144 +		test.Printf(_L("b=%S\n"),&b);
   1.145 +		test(0);
   1.146 +		}
   1.147 +	}
   1.148 +
   1.149 +#define TESTEQ(a,b)	TestEq((a),(b),__LINE__)
   1.150 +
   1.151 +template <class T,class S,class DESTEMPLATE>
   1.152 +GLDEF_C TestTBuf<T,S,DESTEMPLATE>::TestTBuf(TInt aLength)
   1.153 +// Constructor.
   1.154 +	: iMaxBufLength(aLength)
   1.155 +	{}
   1.156 +
   1.157 +template <class T,class S,class DESTEMPLATE>
   1.158 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test1List(T* a,T* b,...)
   1.159 +// Test the format with list functions.
   1.160 +	{
   1.161 +	VA_LIST list;
   1.162 +	VA_START(list,b);
   1.163 +	a->Format(*b,list);
   1.164 +	VA_START(list,b);
   1.165 +	a->AppendFormat(*b,list);
   1.166 +	VA_START(list,b);
   1.167 +	a->Format(_TL("%d"),list);
   1.168 +	VA_START(list,b);
   1.169 +	a->AppendFormat(_TL("%d"),list);
   1.170 +	}
   1.171 +
   1.172 +template <class T,class S,class DESTEMPLATE>
   1.173 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test1()
   1.174 +// Tests all functions of the class.
   1.175 +	{
   1.176 +	test.Start(_L("Constructors"));
   1.177 +	T a;
   1.178 +	T b;
   1.179 +	T c(_TL("AB"));
   1.180 +	T d(c);
   1.181 +
   1.182 +// To avoid unused warning
   1.183 +    a.Length();
   1.184 +    b.Length();
   1.185 +    c.Length();
   1.186 +    d.Length();
   1.187 +
   1.188 +	test.Next(_L("Copy operators"));
   1.189 +	a=_TL("DE");
   1.190 +	b=c;
   1.191 +	a+=_TL("DE");
   1.192 +	b+=c;
   1.193 +
   1.194 +	test.Next(_L("Comparison operators"));
   1.195 +	TInt t=(a<b);
   1.196 +	t=(a<_TL("AB"));
   1.197 +	t=(_TL("AB")<a);
   1.198 +	t=(a<=b);
   1.199 +	t=(a<=_TL("AB"));
   1.200 +	t=(_TL("AB")<=a);
   1.201 +	t=(a>b);
   1.202 +	t=(a>_TL("AB"));
   1.203 +	t=(_TL("AB")>a);
   1.204 +	t=(a>=b);
   1.205 +	t=(a>=_TL("AB"));
   1.206 +	t=(_TL("AB")>=a);
   1.207 +	t=(a==b);
   1.208 +	t=(a==_TL("AB"));
   1.209 +	t=(_TL("AB")==a);
   1.210 +	t=(a!=_TL("AB"));
   1.211 +	t=(_TL("AB")!=a);
   1.212 +
   1.213 +	test.Next(_L("Property access"));
   1.214 +	a[0]='A';
   1.215 +	a.Ptr();
   1.216 +	TInt i=a.MaxLength()-a.Length();
   1.217 +	i=a.Size();
   1.218 +	a.Zero();
   1.219 +	a.SetLength(2); 
   1.220 +
   1.221 +	test.Next(_L("Fill & swap"));
   1.222 +	a.Fill(' ');
   1.223 +	a.Fill(' ',iMaxBufLength);
   1.224 +	a.FillZ();
   1.225 +	a.FillZ(iMaxBufLength);
   1.226 +	a.Swap(b);
   1.227 +
   1.228 +	test.Next(_L("Conversion"));
   1.229 +	a.Fold();
   1.230 +	a.Collate();
   1.231 +	a.LowerCase();
   1.232 +	a.UpperCase();
   1.233 +	a.Capitalize();
   1.234 +
   1.235 +	test.Next(_L("Comparison"));
   1.236 +	a.Compare(b);
   1.237 +	a.Compare(_TL("AB"));
   1.238 +	a.CompareF(b);
   1.239 +	a.CompareF(_TL("AB"));
   1.240 +	a.CompareC(b);
   1.241 +	a.CompareC(_TL("AB"));
   1.242 +
   1.243 +	test.Next(_L("Matching"));
   1.244 +	a.Match(b);
   1.245 +	a.Match(_TL("AB"));
   1.246 +	a.MatchF(b);
   1.247 +	a.MatchF(_TL("AB"));
   1.248 +
   1.249 +	T buf(_TL("abcdef"));
   1.250 +	TInt res = buf.MatchF(_TL("abc*def"));
   1.251 +	test(res == 0);
   1.252 +
   1.253 +	a.MatchC(b);
   1.254 +	a.MatchC(_TL("AB"));
   1.255 +
   1.256 +	test.Next(_L("Locating"));
   1.257 +	a.Locate('A');
   1.258 +	a.LocateF('A');
   1.259 +	a.LocateReverse('A');
   1.260 +	a.LocateReverseF('A');
   1.261 +
   1.262 +	test.Next(_L("Copying"));
   1.263 +	a.Copy(b);
   1.264 +	a.Copy(_TL("AB"));
   1.265 +//	a.Copy(_TL("AB"),1);
   1.266 +	a.CopyF(b);
   1.267 +	a.CopyF(_TL("AB"));
   1.268 +	a.CopyC(b);
   1.269 +	a.CopyC(_TL("AB"));
   1.270 +	a.CopyLC(b);
   1.271 +	a.CopyLC(_TL("AB"));
   1.272 +	a.CopyUC(b);
   1.273 +	a.CopyUC(_TL("AB"));
   1.274 +	a.CopyCP(b);
   1.275 +	a.CopyCP(_TL("AB"));
   1.276 +
   1.277 +	test.Next(_L("Finding"));
   1.278 +	a.Find(b);
   1.279 +	a.Find(_TL("AB"));
   1.280 +	a.FindF(b);
   1.281 +	a.FindF(_TL("AB"));
   1.282 +	a.FindC(b);
   1.283 +	a.FindC(_TL("AB"));
   1.284 +
   1.285 +	test.Next(_L("Basic like ops"));
   1.286 +	a.Repeat(b);
   1.287 +	a.Repeat(_TL("AB"));
   1.288 +	a.TrimLeft();
   1.289 +	a.TrimRight();
   1.290 +	a.Trim();
   1.291 +	b=_TL("AA");
   1.292 +	a.Insert(0,b);
   1.293 +	a.Delete(0,2);
   1.294 +	b = a.Left(1);
   1.295 +	b = a.Right(1);
   1.296 +	b = a.Mid(0,1);
   1.297 +
   1.298 +	test.Next(_L("Formating"));
   1.299 +	a.Justify(_TL("AB"),10,ELeft,' ');
   1.300 +	a.Justify(b,10,ELeft,' ');
   1.301 +	b.Fill('A',2);
   1.302 +	a.Zero();
   1.303 +	a.AppendJustify(_TL("AB"),10,ELeft,' ');
   1.304 +	a.AppendJustify(b,10,ELeft,' ');
   1.305 +	TInt v1=10;
   1.306 +	a.Num(v1);
   1.307 +	a.AppendNum(v1);
   1.308 +	TInt v2=10;
   1.309 +	a.Num((TUint)v2,EHex);
   1.310 +	a.AppendNum((TUint)v2,EHex);
   1.311 +	a.NumUC((TUint)v2,EHex);
   1.312 +	a.AppendNumUC((TUint)v2,EHex);
   1.313 +	TReal v3=10.0;
   1.314 +	TRealFormat ff;
   1.315 +	ff.iType=KRealFormatFixed;
   1.316 +	ff.iWidth=10;
   1.317 +	ff.iPlaces=2;
   1.318 +	ff.iPoint='.';
   1.319 +	ff.iTriad=',';
   1.320 +	ff.iTriLen=3;
   1.321 +	a.Num(v3,ff);
   1.322 +	a.AppendNum(v3,ff);
   1.323 +	a.Format(_TL("%d"),12);
   1.324 +	a.AppendFormat(_TL("%d"),12);
   1.325 +	b=_TL("%d");
   1.326 +	a.Format(b,12);
   1.327 +	a.AppendFormat(b,12);
   1.328 +	Test1List(&a,&b,12);
   1.329 +
   1.330 +	test.Next(_L("Replacing"));
   1.331 +	a=_TL("AAC");
   1.332 +	b=_TL("B");
   1.333 +	a.Replace(1,1,b);
   1.334 +	test.End();
   1.335 +	}
   1.336 +
   1.337 +template <class T,class S,class DESTEMPLATE>
   1.338 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test2()
   1.339 +// Tests all constructors.
   1.340 +	{
   1.341 +	test.Start(_L("Default"));
   1.342 +	T a;
   1.343 +	test(a.MaxLength()==iMaxBufLength);
   1.344 +	test(a.Length()==0);
   1.345 +
   1.346 +	test.Next(_L("By length"));
   1.347 +	T b(iMaxBufLength>>1);
   1.348 +	test(b.MaxLength()==iMaxBufLength);
   1.349 +	test(b.Length()==(iMaxBufLength>>1));
   1.350 +
   1.351 +	test.Next(_L("By string"));
   1.352 +	T c(_TL("AB"));
   1.353 +	test(c.MaxLength()==iMaxBufLength);
   1.354 +	test(c.Length()==2);
   1.355 +	test(c[0]=='A');
   1.356 +	test(c[1]=='B');
   1.357 +
   1.358 +	test.Next(_L("By buffer reference"));
   1.359 +	T d(c);
   1.360 +	test(d.MaxLength()==iMaxBufLength);
   1.361 +	test(d.Length()==2);
   1.362 +	test(d[0]=='A');
   1.363 +	test(d[1]=='B');
   1.364 +	test.End();
   1.365 +	}
   1.366 +
   1.367 +template <class T,class S,class DESTEMPLATE>
   1.368 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test3()
   1.369 +// Tests all assignment operators
   1.370 +	{
   1.371 +	test.Start(_L("By String"));
   1.372 +	T a;
   1.373 +	a=_TL("AB");
   1.374 +	a+=_TL("CD");
   1.375 +	test(a.Length()==4);
   1.376 +	test(a==_TL("ABCD"));
   1.377 +
   1.378 +	test.Next(_L("By buffer"));
   1.379 +	T b;
   1.380 +	b=a;
   1.381 +	b+=a;
   1.382 +	test(b.Length()==8);
   1.383 +	test(b==_TL("ABCDABCD"));
   1.384 +//	
   1.385 +	test.End();
   1.386 +	}
   1.387 +
   1.388 +template <class T,class S,class DESTEMPLATE>
   1.389 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test4()
   1.390 +// Test all comparison operators
   1.391 +	{
   1.392 +	test.Start(_L("By NULL string"));
   1.393 +	T a;
   1.394 +	test(a==_TL(""));		// NULL strings
   1.395 +	test(!(a!=_TL("")));
   1.396 +	test(a<=_TL(""));
   1.397 +	test(a>=_TL(""));
   1.398 +	test(!(a<_TL("")));
   1.399 +	test(!(a>_TL("")));
   1.400 +	test(_TL("")==a);
   1.401 +	test(!(_TL("")!=a));
   1.402 +	test(_TL("")<=a);
   1.403 +	test(_TL("")>=a);
   1.404 +	test(!(_TL("")<a));
   1.405 +	test(!(_TL("")>a));
   1.406 +
   1.407 +	test.Next(_L("By string or buffer"));
   1.408 +	a=_TL("abc");
   1.409 +	test(a==_TL("abc"));		// ==
   1.410 +	test(!(a==_TL("xyz")));
   1.411 +	test(!(a==_TL("aa")));
   1.412 +	test(_TL("abc")==a);
   1.413 +	test(!(_TL("xyz")==a));
   1.414 +	test(!(_TL("aa")==a));
   1.415 +	test(a!=_TL("xyz"));		// !=
   1.416 +	test(!(a!=_TL("abc")));
   1.417 +	test(a!=_TL("aa"));
   1.418 +	test(_TL("xyz")!=a);
   1.419 +	test(!(_TL("abc")!=a));
   1.420 +	test(_TL("aa")!=a);
   1.421 +	test(a<_TL("x"));			// <
   1.422 +	test(!(a<_TL("abc")));
   1.423 +	test(!(a<_TL("aa")));
   1.424 +	test(_TL("aa")<a);
   1.425 +	test(!(_TL("abc")<a));
   1.426 +	test(!(_TL("xyz")<a));
   1.427 +	test(a>_TL("aa"));			// >
   1.428 +	test(!(a>_TL("abc")));
   1.429 +	test(!(a>_TL("xyz")));
   1.430 +	test(_TL("xyz")>a);
   1.431 +	test(!(_TL("abc")>a));
   1.432 +	test(!(_TL("aa")>a));
   1.433 +	test(a>=_TL("abc"));		// >=
   1.434 +	test(!(a>=_TL("xyz")));
   1.435 +	test(a>=_TL("aa"));
   1.436 +	test(_TL("abc")>=a);
   1.437 +	test(!(_TL("aaa")>=a));
   1.438 +	test(_TL("xyz")>=a);
   1.439 +	test(a<=_TL("abc"));		// <=
   1.440 +	test(!(a<=_TL("aa")));
   1.441 +	test(a<=_TL("xyz"));
   1.442 +	test(_TL("abc")<=a);
   1.443 +	test(!(_TL("xyz")<=a));
   1.444 +	test(_TL("aa")<=a);
   1.445 +
   1.446 +	test.Next(_L("By special characters"));
   1.447 +	a=_TL("!@#$%^&*()");
   1.448 +	test(a==_TL("!@#$%^&*()"));
   1.449 +	test.End();	
   1.450 +	}
   1.451 +
   1.452 +template <class T,class S,class DESTEMPLATE>
   1.453 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test5()
   1.454 +// Test all property access
   1.455 +	{
   1.456 +	test.Start(_L("Length and Size"));
   1.457 +	T a;
   1.458 +	TInt maxLength=a.MaxLength();
   1.459 +    TInt i;
   1.460 +	for (i=0;i<maxLength;i++)
   1.461 +		{
   1.462 +		test(a.Length()==i);	// Length
   1.463 +		test(a.Size()==(TInt)(sizeof(S)*i)); // Size
   1.464 +		a.AppendNum(i%10);
   1.465 +		}
   1.466 +	const T b=a;
   1.467 +	for (i=0;i<maxLength;i++)
   1.468 +		{
   1.469 +		test(a[i]=='0'+(i%10));	// At
   1.470 +		test(b[i]=='0'+(i%10));	// AtConst
   1.471 +		}
   1.472 +	test(a[0]==*a.Ptr());	//Ptr
   1.473 +	a.SetLength(0);	// SetLength
   1.474 +	test(a.Length()==0);
   1.475 +	a.SetLength(maxLength-1);
   1.476 +	test(a.Length()==maxLength-1);
   1.477 +	a.Zero();	// Null
   1.478 +	test(a.Length()==0);
   1.479 +	test.End();
   1.480 +	}
   1.481 +
   1.482 +template <class T,class S,class DESTEMPLATE>
   1.483 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test6()
   1.484 +// Fill and Swap
   1.485 +	{
   1.486 +	test.Start(_L("Fill and Swap"));
   1.487 +	T a,b;
   1.488 +	TChar chr;
   1.489 +	TInt j;
   1.490 +	TInt maxLength=a.MaxLength();
   1.491 +	for (TInt i=0;i<maxLength;i++)
   1.492 +		{
   1.493 +		chr=(i%10)+'0';
   1.494 +		a.SetLength(i);
   1.495 +		a.Fill(chr);	// Fill(TChar)
   1.496 +		b.Swap(a);
   1.497 +		test(b.Length()==i);	// Swap
   1.498 +		j=0;
   1.499 +		while (j<i)
   1.500 +			test(b[j++]=='0'+(i%10));
   1.501 +		b.FillZ();	// FillZ()
   1.502 +		a.Swap(b);
   1.503 +		j=0;
   1.504 +		while (j<i)
   1.505 +			test(a[j++]==0);
   1.506 +		a.Fill(chr,i);	// Fill(TChar,TUint)
   1.507 +		j=0;
   1.508 +		while (j<i)
   1.509 +			test(a[j++]=='0'+(i%10));
   1.510 +		a.FillZ(i);	// FillZ(TUint)
   1.511 +		j=0;
   1.512 +		while (j<i)
   1.513 +			test(a[j++]==0);
   1.514 +		}
   1.515 +	test.End();
   1.516 +	}
   1.517 +
   1.518 +template <class T,class S,class DESTEMPLATE>
   1.519 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test7()
   1.520 +// Conversion operators
   1.521 +	{
   1.522 +	test.Start(_L("Fold, collate ..."));
   1.523 +	T a;
   1.524 +	T b;
   1.525 +	a=_TL("abc AbC");
   1.526 +	b=_TL("ABC ABC");
   1.527 +	a.Fold();
   1.528 +	b.Fold();
   1.529 +	test(a==b);
   1.530 +	a=_TL("abc AbC");
   1.531 +	b=_TL("ABC ABC");
   1.532 +	a.Collate();
   1.533 +	b.Collate();
   1.534 +	test(a==b);
   1.535 +	a.LowerCase();
   1.536 +	test(a==_TL("abc abc"));
   1.537 +	a.Capitalize();
   1.538 +	test(a==_TL("Abc abc"));
   1.539 +	a.UpperCase();
   1.540 +	test(a==_TL("ABC ABC"));
   1.541 +	test.End();
   1.542 +	}
   1.543 +
   1.544 +template <class T,class S,class DESTEMPLATE>
   1.545 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test8()
   1.546 +// Comparison
   1.547 +	{
   1.548 +	test.Start(_L("By string"));
   1.549 +	T a;
   1.550 +	a=_TL("abc AbC");
   1.551 +	test(a.Compare(_TL("abc AbC"))==0);
   1.552 +	test(a.CompareF(_TL("ABC aBc"))==0);
   1.553 +	test(a.Compare(_TL("xyz"))!=0);
   1.554 +	test(a.CompareC(_TL("xyz"))!=0);
   1.555 +	test(a.CompareF(_TL("xyz"))!=0);
   1.556 +
   1.557 +	test.Next(_L("By buffer"));
   1.558 +	T b;
   1.559 +	T c;
   1.560 +	a=_TL("abc AbC");
   1.561 +	b=_TL("abc AbC");
   1.562 +	c=_TL("xyz");
   1.563 +	test(a.Compare(b)==0);
   1.564 +	test(a.Compare(c)!=0);
   1.565 +	b=_TL("ABC aBc");
   1.566 +	test(a.CompareC(c)!=0);
   1.567 +	test(a.CompareF(b)==0);
   1.568 +	test(a.CompareF(c)!=0);
   1.569 +
   1.570 +	test.End();
   1.571 +	}
   1.572 +
   1.573 +template <class T,class S,class DESTEMPLATE>
   1.574 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test9()
   1.575 +// Matching (need to test explicit result as error KErrNotFound = KMaxTUint
   1.576 +// 			 and so registers as TRUE. (test parameter is TUint) )
   1.577 +	{
   1.578 +	test.Start(_L("By string"));
   1.579 +	T a;
   1.580 +	a=_TL("abc AbC");
   1.581 +	test(a.Match(_TL("abc AbC"))==0);
   1.582 +	test(a.MatchC(_TL("ABC aBc"))==0);
   1.583 +	test(a.MatchF(_TL("ABC aBc"))==0);
   1.584 +	test(a.Match(_TL("xyz"))==KErrNotFound);
   1.585 +	test(a.MatchC(_TL("xyz"))==KErrNotFound);
   1.586 +	test(a.MatchF(_TL("xyz"))==KErrNotFound);
   1.587 +
   1.588 +	test.Next(_L("By buffer"));
   1.589 +	T b;
   1.590 +	T c;
   1.591 +	a=_TL("abc AbC");
   1.592 +	b=_TL("abc AbC");
   1.593 +	c=_TL("xyz");
   1.594 +	test(a.Match(b)==0);
   1.595 +	test(a.Match(c)==KErrNotFound);
   1.596 +	b=_TL("ABC aBc");
   1.597 +	test(a.MatchC(b)==0);
   1.598 +	test(a.MatchC(c)==KErrNotFound);
   1.599 +	test(a.MatchF(b)==0);
   1.600 +	test(a.MatchF(c)==KErrNotFound);
   1.601 +
   1.602 +	test.Next(_L("Wildcards"));
   1.603 +	a=_TL("abcxyz");
   1.604 +	test(a.Match(_TL("abc*"))==0);
   1.605 +	test(a.Match(_TL("abw*"))==KErrNotFound);
   1.606 +	a=_TL("abcdefg");
   1.607 +	test(a.Match(_TL("a*fg"))==0);
   1.608 +	test(a.Match(_TL("a*f"))==KErrNotFound);
   1.609 +	test(a.Match(_TL("abc*fgh"))==KErrNotFound);
   1.610 +	a=_TL("abcdef");
   1.611 +	test(a.Match(_TL("abc?ef"))==0);
   1.612 +	test(a.Match(_TL("abc?xf"))==KErrNotFound);
   1.613 +
   1.614 +	a=_TL("a(01)");
   1.615 +	test(a.Match(_TL("*(01)"))==1);
   1.616 +	test(a.Match(_TL("?(01)"))==0);
   1.617 +	test(a.Match(_TL("?(*)"))==0);
   1.618 +	test(a.Match(_TL("?(**)"))==0);
   1.619 +
   1.620 +	test(a.Match(_TL("?(\?\?)"))==0);
   1.621 +	test(a.Match(_TL("*(*)"))>=0);
   1.622 +	test(a.Match(_TL("*(0?)"))>=0);
   1.623 +	test(a.Match(_TL("a(\?\?)"))==0);
   1.624 +	test(a.Match(_TL("*(\?\?)"))>=0);
   1.625 +
   1.626 +	test.Next(_L("wild cards with collated comparison"));
   1.627 +	a = _TL("abcdefghijkl");
   1.628 +	test(a.MatchC(_TL("abc*")) == 0);
   1.629 +	test(a.MatchC(_TL("abc")) == KErrNotFound);
   1.630 +	test(a.MatchC(_TL("xyz")) == KErrNotFound);
   1.631 +	test(a.MatchC(_TL("*def")) == KErrNotFound);
   1.632 +	test(a.MatchC(_TL("*def*")) == 3);
   1.633 +	test(a.MatchC(_TL("*d?f*")) == 3);
   1.634 +	test(a.MatchC(_TL("a*kl")) == 0);
   1.635 +	test(a.MatchC(_TL("*e*?l")) == 4);
   1.636 +	test(a.MatchC(_TL("abc*dEf*")) == 0);
   1.637 +	
   1.638 +	
   1.639 +	T candidate;
   1.640 +	T search;
   1.641 +	
   1.642 +	candidate = _TL("");
   1.643 +	search = _TL("**");
   1.644 +	test(candidate.MatchC(search) == 0);
   1.645 +	
   1.646 +	candidate = _TL("");
   1.647 +	search = _TL("*");
   1.648 +	test(candidate.MatchC(search) == 0);
   1.649 +	
   1.650 +	candidate = _TL("abcd");
   1.651 +	search = _TL("*abc*cd");
   1.652 +	test(candidate.MatchC(search) == KErrNotFound);
   1.653 +   	
   1.654 +	if (sizeof(S) == 2)
   1.655 +		{
   1.656 +		test.Next(_L("Unicode MatchC and FindC treat base+accent as equal to composed character"));
   1.657 +		TPtrC p = _L("te\x302te");
   1.658 +		test(p.MatchC(_L("t\xeate")) == 0);
   1.659 +		test(p.FindC(_L("t\xeate")) == 0);
   1.660 +		}
   1.661 +
   1.662 +	test.End();
   1.663 +	}
   1.664 +
   1.665 +template <class T,class S,class DESTEMPLATE>
   1.666 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test10()
   1.667 +// Locating
   1.668 +	{
   1.669 +	T a;
   1.670 +	TChar b;
   1.671 +
   1.672 +	test.Start(_L("First Char"));
   1.673 +	b='a';
   1.674 +	a=_TL("axaxa");
   1.675 +	test(a.Locate(b)==0);
   1.676 +	test(a.LocateF(b)==0);
   1.677 +	test(a.LocateReverse(b)==4);
   1.678 +	test(a.LocateReverseF(b)==4);
   1.679 +
   1.680 +	test.Next(_L("Middle Char"));
   1.681 +	a=_TL("xaxa");
   1.682 +	test(a.Locate(b)==1);
   1.683 +	test(a.LocateF(b)==1);
   1.684 +	a=_TL("axax");
   1.685 +	test(a.LocateReverse(b)==2);
   1.686 +	test(a.LocateReverseF(b)==2);
   1.687 +
   1.688 +	test.Next(_L("Last Char"));
   1.689 +	a=_TL("xxa");
   1.690 +	test(a.Locate(b)==2);
   1.691 +	test(a.LocateF(b)==2);
   1.692 +	a=_TL("axx");
   1.693 +	test(a.LocateReverse(b)==0);
   1.694 +	test(a.LocateReverseF(b)==0);
   1.695 +
   1.696 +	test.Next(_L("Test for failure of locate"));
   1.697 +	a=_TL("xxx");
   1.698 +	test(a.Locate(b)==KErrNotFound);
   1.699 +	test(a.LocateF(b)==KErrNotFound);
   1.700 +	test(a.LocateReverse(b)==KErrNotFound);
   1.701 +	test(a.LocateReverseF(b)==KErrNotFound);
   1.702 +
   1.703 +	test.End();
   1.704 +	}
   1.705 +
   1.706 +template <class T,class S,class DESTEMPLATE>
   1.707 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test11()
   1.708 +// Copying
   1.709 +	{
   1.710 +	T a, b;
   1.711 +		
   1.712 +	test.Start(_L("By String"));
   1.713 +	a.Copy(_TL("abc"));
   1.714 +	test(a.Length()==3);
   1.715 +	test(a==_TL("abc"));
   1.716 +	a.CopyF(_TL("abc"));
   1.717 +	test(a.Length()==3);
   1.718 +	b.CopyF(_TL("ABC"));
   1.719 +	test(a==b);
   1.720 +	a.CopyLC(_TL("AbC"));
   1.721 +	test(a==_TL("abc"));
   1.722 +	test(a.Length()==3);
   1.723 +	a.CopyC(_TL("abc"));
   1.724 +	b.CopyC(_TL("ABC"));
   1.725 +	test(a==b);
   1.726 +	test(a.Length()==3);
   1.727 +	a.CopyCP(_TL("abc"));
   1.728 +	test(a==_TL("Abc"));
   1.729 +	test(a.Length()==3);
   1.730 +	a.CopyUC(_TL("aBc"));
   1.731 +	test(a==_TL("ABC"));
   1.732 +	test(a.Length()==3);
   1.733 +//	a.Copy(_TL("abc"),3);
   1.734 +//	test(a==_TL("abc"));
   1.735 +//	test(a.Length()==3);
   1.736 +//	a.Copy(_TL("abcd"),3);
   1.737 +//	test(a==_TL("abc"));
   1.738 +//	test(a.Length()==3);
   1.739 +
   1.740 +	test.Next(_L("By buffer"));
   1.741 +	b=_TL("abc");
   1.742 +	a.Copy(b);
   1.743 +	test(a==_TL("abc"));
   1.744 +	test(a.Length()==3);
   1.745 +	a=_TL("");
   1.746 +	a.CopyF(b);
   1.747 +	b.CopyF(_TL("ABC"));
   1.748 +	test(a==b);
   1.749 +	test(a.Length()==3);
   1.750 +	a=_TL("");
   1.751 +	b=_TL("AbC");
   1.752 +	a.CopyLC(b);
   1.753 +	test(a==_TL("abc"));
   1.754 +	test(a.Length()==3);
   1.755 +	a=_TL("");
   1.756 +	b=_TL("abC");
   1.757 +	a.CopyC(b);
   1.758 +	b.CopyC(_TL("ABC"));
   1.759 +	test(a==b);
   1.760 +	test(a.Length()==3);
   1.761 +	a=_TL("");
   1.762 +	b=_TL("abC");
   1.763 +	a.CopyCP(b);
   1.764 +	test(a==_TL("Abc"));
   1.765 +	test(a.Length()==3);
   1.766 +	a=_TL("");
   1.767 +	b=_TL("aBc");
   1.768 +	a.CopyUC(b);
   1.769 +	test(a.Length()==3);
   1.770 +	test(a==_TL("ABC"));
   1.771 +
   1.772 +	test.End();
   1.773 +	}
   1.774 +
   1.775 +
   1.776 +template <class T,class S,class DESTEMPLATE>
   1.777 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test12()
   1.778 +// Finding
   1.779 +	{
   1.780 +	test.Start(_L("By String"));
   1.781 +	T a,b;
   1.782 +	a=_TL("abccef");
   1.783 +	test(a.Find(_TL(""))==0);
   1.784 +	test(a.Find(_TL("abc"))==0);
   1.785 +	test(a.Find(_TL("cce"))==2);
   1.786 +	test(a.Find(_TL("cef"))==3);
   1.787 +	test(a.Find(_TL("efg"))==KErrNotFound);
   1.788 +	test(a.Find(_TL("xxx"))==KErrNotFound);
   1.789 +	test(a.FindF(_TL(""))==0);
   1.790 +	test(a.FindF(_TL("AbC"))==0);
   1.791 +	test(a.FindF(_TL("CcE"))==2);
   1.792 +	test(a.FindF(_TL("CeF"))==3);
   1.793 +	test(a.FindF(_TL("efg"))==KErrNotFound);
   1.794 +	test(a.FindF(_TL("xxx"))==KErrNotFound);
   1.795 +	test(a.FindC(_TL(""))==0);
   1.796 +	test(a.FindC(_TL("aBc"))==0);
   1.797 +	test(a.FindC(_TL("cce"))==2);
   1.798 +	test(a.FindC(_TL("cEf"))==3);
   1.799 +	test(a.FindC(_TL("efg"))==KErrNotFound);
   1.800 +	test(a.FindC(_TL("xxx"))==KErrNotFound);
   1.801 +
   1.802 +	test.Next(_L("By buffer"));
   1.803 +	test(a.Find(b)==0);
   1.804 +	test(a.FindF(b)==0);
   1.805 +	test(a.FindC(b)==0);
   1.806 +	b=_TL("xxx");
   1.807 +	test(a.Find(b)==KErrNotFound);
   1.808 +	test(a.FindF(b)==KErrNotFound);
   1.809 +	test(a.FindC(b)==KErrNotFound);
   1.810 +	b=_TL("efg");
   1.811 +	test(a.Find(b)==KErrNotFound);
   1.812 +	test(a.FindF(b)==KErrNotFound);
   1.813 +	test(a.FindC(b)==KErrNotFound);
   1.814 +	b=_TL("abc");
   1.815 +	test(a.Find(b)==0);
   1.816 +	b=_TL("cce");
   1.817 +	test(a.Find(b)==2);
   1.818 +	b=_TL("cef");
   1.819 +	test(a.Find(b)==3);
   1.820 +	b=_TL("AbC");
   1.821 +	test(a.FindF(b)==0);
   1.822 +	b=_TL("CcE");
   1.823 +	test(a.FindF(b)==2);
   1.824 +	b=_TL("CeF");
   1.825 +	test(a.FindF(b)==3);
   1.826 +	b=_TL("aBc");
   1.827 +	test(a.FindC(b)==0);
   1.828 +	b=_TL("cCe");
   1.829 +	test(a.FindC(b)==2);
   1.830 +	b=_TL("cEf");
   1.831 +	test(a.FindC(b)==3);
   1.832 +
   1.833 +	test.End();
   1.834 +	}
   1.835 +
   1.836 +template <class T,class S,class DESTEMPLATE>
   1.837 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test13()
   1.838 +// Basic like ops
   1.839 +	{
   1.840 +	test.Start(_L("Repeat, trim, insert and delete"));
   1.841 +	T a,b;
   1.842 +	TInt max=a.MaxLength(); 
   1.843 +	b=_TL("abc");
   1.844 +	a.Repeat(_TL("abc"));
   1.845 +	test(a==_TL(""));
   1.846 +	a.Repeat(b);
   1.847 +	test(a==_TL(""));
   1.848 +	for (TInt j=1;j<max;j++) // ?? Cannot SetLength = MaxLength
   1.849 +		{
   1.850 +		a.SetLength(j);
   1.851 +		a.Repeat(_TL("abc"));
   1.852 +        TInt i;
   1.853 +		for (i=0;i<j;i++)
   1.854 +			test(a[i]==b[i%3]);
   1.855 +		a=_TL("");
   1.856 +		a.SetLength(j);
   1.857 +		a.Repeat(b);
   1.858 +		for (i=0;i<j;i++)
   1.859 +			test(a[i]==b[i%3]);
   1.860 +		a=_TL("");
   1.861 +		}
   1.862 +	a=_TL("\t\n  ab \t\n ");
   1.863 +	a.TrimLeft();
   1.864 +	test(a==_TL("ab \t\n "));
   1.865 +	test(a.Length()==6);
   1.866 +	a=_TL("\t\n  ab \t\n ");
   1.867 +	a.TrimRight();
   1.868 +	test(a==_TL("\t\n  ab"));
   1.869 +	test(a.Length()==6);
   1.870 +	a=_TL(" \t\n ab \t \n");
   1.871 +	a.Trim();
   1.872 +	test(a==_TL("ab"));
   1.873 +	a.Trim();
   1.874 +	test(a==_TL("ab"));
   1.875 +	a=_TL("abc");
   1.876 +	b=_TL("123");
   1.877 +	a.Insert(1,b);
   1.878 +	test(a==_TL("a123bc"));
   1.879 +	test(a.Length()==6);
   1.880 +	b=_TL("");
   1.881 +	a.Insert(4,b);
   1.882 +	test(a==_TL("a123bc"));
   1.883 +	test(a.Length()==6);
   1.884 +	a.Insert(0,b);
   1.885 +	test(a==_TL("a123bc"));
   1.886 +	test(a.Length()==6);
   1.887 +	a.Delete(1,3);
   1.888 +	test(a==_TL("abc"));
   1.889 +	test(a.Length()==3);
   1.890 +	a.Delete(0,3);
   1.891 +	test(a==_TL(""));
   1.892 +	test(a.Length()==0);
   1.893 +
   1.894 +	test.Next(_L("TrimAll"));
   1.895 +	a=_TL("");
   1.896 +	a.TrimAll();
   1.897 +	test(a==_TL(""));
   1.898 +	a=_TL(" ");
   1.899 +	a.TrimAll();
   1.900 +	test(a==_TL(""));
   1.901 +	a=_TL("   ");
   1.902 +	a.TrimAll();
   1.903 +	test(a==_TL(""));
   1.904 +	a=_TL("    ab cd  ef    g");
   1.905 +	a.TrimAll();
   1.906 +	test(a==_TL("ab cd ef g"));
   1.907 +	a=_TL("abcdef");
   1.908 +	a.TrimAll();
   1.909 +	test(a==_TL("abcdef"));
   1.910 +	a=_TL("a  b\t cd\t\tef");
   1.911 +	a.TrimAll();
   1.912 +	test(a==_TL("a b\tcd\tef"));
   1.913 +	a=_TL("abcdef \t ghijk");
   1.914 +	a.TrimAll();
   1.915 +	test(a==_TL("abcdef ghijk"));
   1.916 +	a=_TL("abcdef g");
   1.917 +	a.TrimAll();
   1.918 +	test(a==_TL("abcdef g"));
   1.919 +	a=_TL("ab  cd  ef  gh  ij");
   1.920 +	a.TrimAll();
   1.921 +	test(a==_TL("ab cd ef gh ij"));
   1.922 +	a=_TL("a        b          c     defg h     i  jk l     mno pqr stu  vw   xyz");
   1.923 +	a.TrimAll();
   1.924 +	test(a==_TL("a b c defg h i jk l mno pqr stu vw xyz"));
   1.925 +
   1.926 +	test.Next(_L("Right, Left and Mid"));
   1.927 +	a=_TL("abcdef");
   1.928 +	b = a.Left(3);
   1.929 +	test(b==_TL("abc"));
   1.930 +	test(b.Length()==3);
   1.931 +	b = a.Right(3);
   1.932 +	test(b==_TL("def"));
   1.933 +	b = a.Mid(2);
   1.934 +	test(b==_TL("cdef"));
   1.935 +	test(b.Length()==4);
   1.936 +	b = a.Left(2);
   1.937 +	test(b==_TL("ab"));
   1.938 +	test(b.Length()==2);
   1.939 +	b = a.Right(2);
   1.940 +	test(b==_TL("ef"));
   1.941 +	b = a.Mid(2,1);
   1.942 +	test(b==_TL("c"));
   1.943 +	test(b.Length()==1);
   1.944 +	b = a.Left(6);
   1.945 +	test(b==_TL("abcdef"));
   1.946 +	test(b.Length()==6);
   1.947 +	b=_TL("");
   1.948 +	b.SetLength(4);
   1.949 +	b = a.Right(6);
   1.950 +	test(b==_TL("abcdef"));
   1.951 +	test(b.Length()==6);
   1.952 +	a = a.Left(6);
   1.953 +	test(a==_TL("abcdef"));
   1.954 +	b=_TL("");
   1.955 +	b = a.Mid(0,6);
   1.956 +	test(b==_TL("abcdef")); 
   1.957 +	test.End();
   1.958 +	}
   1.959 +
   1.960 +template <class T,class S,class DESTEMPLATE>
   1.961 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test14()
   1.962 +// Formating operations
   1.963 +	{
   1.964 +	test.Start(_L("Justify"));
   1.965 +	T a,b,d;
   1.966 +	TInt aWidth;
   1.967 +	TChar c;
   1.968 +	a=_TL("wxyz");
   1.969 +	b=_TL("abc");
   1.970 +	d=_TL("linearisation");
   1.971 +	const S* pD=_TS("299792458");
   1.972 +	c='x';
   1.973 +	aWidth=KDefaultJustifyWidth; // Left justified, Default width
   1.974 +	a.Justify(b,aWidth,ELeft,c);
   1.975 +	test(a==b);
   1.976 +	test(a.Length()==3);
   1.977 +	a.AppendJustify(b,aWidth,ELeft,c);
   1.978 +	test(a==_TL("abcabc"));
   1.979 +	test(a.Length()==6);
   1.980 +	aWidth=1;	// Width < String length
   1.981 +	a.Justify(b,aWidth,ELeft,c);
   1.982 +	test(a==_TL("a"));
   1.983 +	test(a.Length()==1);
   1.984 +	a.AppendJustify(b,aWidth,ELeft,c);
   1.985 +	test(a==_TL("aa"));
   1.986 +	test(a.Length()==2);
   1.987 +	aWidth=5; // Width > String length
   1.988 +	a.Justify(b,aWidth,ELeft,c);
   1.989 +	test(a==_TL("abcxx"));
   1.990 +	test(a.Length()==5);
   1.991 +	a.AppendJustify(b,aWidth,ELeft,c);
   1.992 +	test(a==_TL("abcxxabcxx"));
   1.993 +	test(a.Length()==10);
   1.994 +
   1.995 +	aWidth=KDefaultJustifyWidth; // Right justified, Default width
   1.996 +	a.Justify(b,aWidth,ERight,c);
   1.997 +	test(a==b);
   1.998 +	test(a.Length()==3);
   1.999 +	a.AppendJustify(b,aWidth,ERight,c);
  1.1000 +	test(a==_TL("abcabc"));
  1.1001 +	test(a.Length()==6);
  1.1002 +	aWidth=1; // Right justified, Width < String length
  1.1003 +	a.Justify(b,aWidth,ERight,c);
  1.1004 +	test(a==_TL("a"));
  1.1005 +	test(a.Length()==1);
  1.1006 +	a.AppendJustify(b,aWidth,ERight,c);
  1.1007 +	test(a==_TL("aa"));
  1.1008 +	test(a.Length()==2);
  1.1009 +	aWidth=5; // Right justified, width > String length
  1.1010 +	a.Justify(b,aWidth,ERight,c);
  1.1011 +	test(a==_TL("xxabc"));
  1.1012 +	test(a.Length()==5);
  1.1013 +	a.AppendJustify(b,aWidth,ERight,c);
  1.1014 +	test(a==_TL("xxabcxxabc"));
  1.1015 +	test(a.Length()==10);
  1.1016 +
  1.1017 +	aWidth=KDefaultJustifyWidth; // Center justified, Default width
  1.1018 +	a.Justify(b,aWidth,ECenter,c);
  1.1019 +	test(a==b);
  1.1020 +	test(a.Length()==3);
  1.1021 +	a.AppendJustify(b,aWidth,ECenter,c);
  1.1022 +	test(a==_TL("abcabc"));
  1.1023 +	test(a.Length()==6);
  1.1024 +	aWidth=1; // Centre justified, width < String length
  1.1025 +	a.Justify(b,aWidth,ECenter,c);
  1.1026 +	test(a==_TL("a"));
  1.1027 +	test(a.Length()==1);
  1.1028 +	a.AppendJustify(b,aWidth,ECenter,c);
  1.1029 +	test(a==_TL("aa"));
  1.1030 +	test(a.Length()==2);
  1.1031 +	aWidth=5; // Centre justified, width > String length
  1.1032 +	a.Justify(b,aWidth,ECenter,c);
  1.1033 +	test(a==_TL("xabcx"));
  1.1034 +	test(a.Length()==5);
  1.1035 +	a.AppendJustify(b,aWidth,ECenter,c);
  1.1036 +	test(a==_TL("xabcxxabcx"));
  1.1037 +	test(a.Length()==10);
  1.1038 +
  1.1039 +	test.Next(_L("Num"));
  1.1040 +	TInt j=-2147483647-1; 
  1.1041 +	a.Num(j);
  1.1042 +	test(a==_TL("-2147483648"));
  1.1043 +	test(a.Length()==11);
  1.1044 +	TUint i=2147483648u;
  1.1045 +	a.Num(i);
  1.1046 +	test(a==_TL("2147483648"));
  1.1047 +	test(a.Length()==10);
  1.1048 +	if (a.MaxLength()>31)
  1.1049 +		{
  1.1050 +		a.Num(i,EBinary);
  1.1051 +		test(a==_TL("10000000000000000000000000000000"));
  1.1052 +		test(a.Length()==32);
  1.1053 +		a=_TL("");
  1.1054 +		a.NumUC(i,EBinary);
  1.1055 +		test(a==_TL("10000000000000000000000000000000"));
  1.1056 +		test(a.Length()==32);
  1.1057 +		}
  1.1058 +	i=31;
  1.1059 +	a.Num(i,EBinary);
  1.1060 +	test(a==_TL("11111"));
  1.1061 +	test(a.Length()==5);
  1.1062 +	a=_TL("");
  1.1063 +	a.NumUC(i,EBinary);
  1.1064 +	test(a==_TL("11111"));
  1.1065 +	test(a.Length()==5);
  1.1066 +	i=2147483648u;
  1.1067 +	a.Num(i,EOctal);
  1.1068 +	test(a==_TL("20000000000"));
  1.1069 +	test(a.Length()==11);
  1.1070 +	a=_TL("");
  1.1071 +	a.NumUC(i,EOctal);
  1.1072 +	test(a==_TL("20000000000"));
  1.1073 +	test(a.Length()==11);
  1.1074 +	a.Num(i,EDecimal);
  1.1075 +	test(a==_TL("2147483648"));
  1.1076 +	test(a.Length()==10);
  1.1077 +	a=_TL("");
  1.1078 +	a.NumUC(i,EDecimal);
  1.1079 +	test(a==_TL("2147483648"));
  1.1080 +	test(a.Length()==10);
  1.1081 +	a.Num(i,EHex);
  1.1082 +	test(a==_TL("80000000"));
  1.1083 +	test(a.Length()==8);
  1.1084 +	a=_TL("");
  1.1085 +	a.NumUC(i,EHex);
  1.1086 +	test(a==_TL("80000000"));
  1.1087 +	test(a.Length()==8);
  1.1088 +	i=0;
  1.1089 +	a.Num(i);
  1.1090 +	test(a==_TL("0"));
  1.1091 +	test(a.Length()==1);
  1.1092 +	a=_TL("abc");
  1.1093 +	a.Num(i,EBinary);
  1.1094 +	test(a==_TL("0"));
  1.1095 +	test(a.Length()==1);
  1.1096 +	a=_TL("abc");
  1.1097 +	a.NumUC(i,EBinary);
  1.1098 +	test(a==_TL("0"));
  1.1099 +	test(a.Length()==1);
  1.1100 +	a=_TL("abc");
  1.1101 +	a.Num(i,EOctal);
  1.1102 +	test(a==_TL("0"));
  1.1103 +	test(a.Length()==1);
  1.1104 +	a=_TL("");
  1.1105 +	a.NumUC(i,EOctal);
  1.1106 +	test(a==_TL("0"));
  1.1107 +	test(a.Length()==1);
  1.1108 +	a=_TL("abc");
  1.1109 +	a.Num(i,EDecimal);
  1.1110 +	test(a==_TL("0"));
  1.1111 +	test(a.Length()==1);
  1.1112 +	a=_TL("");
  1.1113 +	a.NumUC(i,EDecimal);
  1.1114 +	test(a==_TL("0"));
  1.1115 +	test(a.Length()==1);
  1.1116 +	a=_TL("abc");
  1.1117 +	a.Num(i,EHex);
  1.1118 +	test(a==_TL("0"));
  1.1119 +	test(a.Length()==1);
  1.1120 +	a=_TL("");
  1.1121 +	a.NumUC(i,EHex);
  1.1122 +	test(a==_TL("0"));
  1.1123 +	test(a.Length()==1);
  1.1124 +//	TInt i=a.Num(6.2,format); NOT IMPLEMENTED
  1.1125 +	a.AppendNum(j);
  1.1126 +	test(a==_TL("0-2147483648"));
  1.1127 +	test(a.Length()==12);
  1.1128 +	a=_TL("abc");
  1.1129 +	i=4294967295u;
  1.1130 +	a.AppendNum(i);
  1.1131 +	test(a==_TL("abc4294967295"));
  1.1132 +	test(a.Length()==13);
  1.1133 +	j=2147483647;
  1.1134 +	a=_TL("abc");
  1.1135 +	a.AppendNum(j);
  1.1136 +	test(a==_TL("abc2147483647"));
  1.1137 +	test(a.Length()==13);
  1.1138 +	a=_TL("a");
  1.1139 +	i=180150000;
  1.1140 +	if (a.MaxLength()>28)
  1.1141 +		{
  1.1142 +		a.AppendNum(i,EBinary);
  1.1143 +		test(a==_TL("a1010101111001101111011110000"));
  1.1144 +		test(a.Length()==29);
  1.1145 +		}
  1.1146 +	a=_TL("a");
  1.1147 +	a.AppendNum(15,EBinary);
  1.1148 +	test(a==_TL("a1111"));
  1.1149 +	test(a.Length()==5);
  1.1150 +	a=_TL("a");
  1.1151 +	a.AppendNum(i,EDecimal);
  1.1152 +	test(a==_TL("a180150000"));
  1.1153 +	test(a.Length()==10);
  1.1154 +	a=_TL("a");
  1.1155 +	a.AppendNum(i,EOctal);
  1.1156 +	test(a==_TL("a1257157360"));
  1.1157 +	test(a.Length()==11);
  1.1158 +	a=_TL("a");
  1.1159 +	a.AppendNumUC(i,EHex);
  1.1160 +	test(a==_TL("aABCDEF0"));
  1.1161 +	test(a.Length()==8);
  1.1162 +//	i=a.AppendNum(6.32, format); NOT IMPLEMENTED
  1.1163 +
  1.1164 +	test.Next(_L("Format"));
  1.1165 +	a=_TL("");
  1.1166 +	b=_TL("cde");
  1.1167 +	a.Format(_TL("%S"),&b);
  1.1168 +	test(a==b);
  1.1169 +	test(a.Length()==3);
  1.1170 +    DESTEMPLATE xyz=_TL("xyzwpq");
  1.1171 +	a.Format(_TL("%S"),&xyz);
  1.1172 +	test(a==_TL("xyzwpq"));
  1.1173 +	test(a.Length()==6);
  1.1174 +    DESTEMPLATE cde=_TL("cde");
  1.1175 +	a.Format(_TL("ab %-x5S"),&cde);
  1.1176 +	test(a==_TL("ab cdexx"));
  1.1177 +	test(a.Length()==8);
  1.1178 +	a.Format(_TL("ab %=x5S"),&cde);
  1.1179 +	test(a==_TL("ab xcdex"));
  1.1180 +	test(a.Length()==8);
  1.1181 +	a.Format(_TL("ab %+x5S"),&cde);
  1.1182 +	test(a==_TL("ab xxcde"));
  1.1183 +	test(a.Length()==8);
  1.1184 +	a.Format(_TL("ab %5S"),&cde);
  1.1185 +	test(a==_TL("ab   cde"));
  1.1186 +	test(a.Length()==8);
  1.1187 +	a.Format(_TL("ab %-**S"),'x',5,&cde);
  1.1188 +	test(a==_TL("ab cdexx"));
  1.1189 +	test(a.Length()==8);
  1.1190 +	a.Format(_TL("ab %*S"),5,&cde);
  1.1191 +	test(a==_TL("ab   cde"));
  1.1192 +	test(a.Length()==8);
  1.1193 +	a=_TL("xyz");
  1.1194 +	a.Format(_TL("ab %-x5S"),&b);
  1.1195 +	test(a==_TL("ab cdexx"));
  1.1196 +	test(a.Length()==8);
  1.1197 +	a=_TL("xyz");
  1.1198 +	a.Format(_TL("ab %-**S"),'x',5,&b);
  1.1199 +	test(a==_TL("ab cdexx"));
  1.1200 +	test(a.Length()==8);
  1.1201 +	a=_TL("xyz");
  1.1202 +	a.Format(_TL("ab %*S"),5,&b);
  1.1203 +	test(a==_TL("ab   cde"));
  1.1204 +	test(a.Length()==8);
  1.1205 +
  1.1206 +	DESTEMPLATE fred=_TL("fred");
  1.1207 +	a.Format(_TL("%+0*S"),10,&fred);
  1.1208 +	test(a==_TL("000000fred"));
  1.1209 +	test(a.Length()==10);
  1.1210 +	a.Format(_TL("%-0*S"),7,&fred);
  1.1211 +	test(a==_TL("fred000"));
  1.1212 +	test(a.Length()==7);
  1.1213 +	a.Format(_TL("%0*S"),11,&fred);
  1.1214 +	test(a==_TL("0000000fred"));
  1.1215 +	test(a.Length()==11);
  1.1216 +	a.Format(_TL("c=%s"),pD);
  1.1217 +	TESTEQ(a,_TL("c=299792458"));
  1.1218 +	a.Format(_TL("c=%10.6s"),pD);
  1.1219 +	test(a==_TL("c=    299792"));
  1.1220 +	a.Format(_TL("c=%*.*s"),5,4,pD);
  1.1221 +	test(a==_TL("c= 2997"));
  1.1222 +	a.Format(_TL("%S"),&d);
  1.1223 +	test(a==_TL("linearisation"));
  1.1224 +	a.Format(_TL("%10.6S"),&d);
  1.1225 +	test(a==_TL("    linear"));
  1.1226 +	a.Format(_TL("%*.*S"),5,4,&d);
  1.1227 +	test(a==_TL(" line"));
  1.1228 +	a.Format(_TL("%*.*Sed"),10,8,&d);
  1.1229 +	test(a==_TL("  linearised"));
  1.1230 +	a.Format(_TL("%*.*S"),14,20,&d);
  1.1231 +	test(a==_TL(" linearisation"));
  1.1232 +
  1.1233 +	a.Format(_TL("ab %-,5b"),7);
  1.1234 +	test(a==_TL("ab 111,,"));
  1.1235 +	test(a.Length()==8);
  1.1236 +	a.Format(_TL("ab %=,5O"),31);
  1.1237 +	test(a==_TL("ab ,37,,"));
  1.1238 +	test(a.Length()==8);
  1.1239 +	a.Format(_TL("ab %+xlx"),TInt64(171));
  1.1240 +	test(a==_TL("ab ab"));
  1.1241 +	test(a.Length()==5);
  1.1242 +	a.Format(_TL("ab %+xlX %+xlx"),TInt64(171),TInt64(171));
  1.1243 +	TESTEQ(a,_TL("ab AB ab"));
  1.1244 +	test(a.Length()==8);
  1.1245 +	a.Format(_TL("ab %lu"),MAKE_TINT64((TUint)(KMinTInt),0));
  1.1246 +	test(a==_TL("ab 9223372036854775808"));
  1.1247 +	test(a.Length()==22);
  1.1248 +	a.Format(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),1));
  1.1249 +	test(a==_TL("ab -9223372036854775807"));
  1.1250 +	test(a.Length()==23);
  1.1251 +	a.Format(_TL("ab %ld"),MAKE_TINT64((TUint)(KMinTInt),0));
  1.1252 +	test(a==_TL("ab -9223372036854775808"));
  1.1253 +	test(a.Length()==23);
  1.1254 +	a.Format(_TL("ab %ld"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
  1.1255 +	test(a==_TL("ab 9223372036854775807"));
  1.1256 +	test(a.Length()==22);
  1.1257 +	a.Format(_TL("ab %ld"),MAKE_TINT64(KMaxTUint,KMaxTUint));
  1.1258 +	test(a==_TL("ab -1"));
  1.1259 +	test(a.Length()==5);
  1.1260 +	a.Format(_TL("ab %lu"),MAKE_TINT64(KMaxTUint,KMaxTUint));
  1.1261 +	test(a==_TL("ab 18446744073709551615"));
  1.1262 +	test(a.Length()==23);
  1.1263 +	a.Format(_TL("ab %ld"),TInt64(0));
  1.1264 +	test(a==_TL("ab 0"));
  1.1265 +	test(a.Length()==4);
  1.1266 +	a.Format(_TL("ab %lb"),TInt64(0));
  1.1267 +	test(a==_TL("ab 0"));
  1.1268 +	test(a.Length()==4);
  1.1269 +	a.Format(_TL("ab %lx"),TInt64(0));
  1.1270 +	test(a==_TL("ab 0"));
  1.1271 +	test(a.Length()==4);
  1.1272 +	a.Format(_TL("ab %lo"),TInt64(0));
  1.1273 +	test(a==_TL("ab 0"));
  1.1274 +	test(a.Length()==4);
  1.1275 +	a.Format(_TL("ab %lu"),TInt64(0));
  1.1276 +	test(a==_TL("ab 0"));
  1.1277 +	test(a.Length()==4);
  1.1278 +	a.Format(_TL("ab %lb"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
  1.1279 +	test(a==_TL("ab 111111111111111111111111111111111111111111111111111111111111111"));
  1.1280 +	test(a.Length()==66);
  1.1281 +	a.Format(_TL("ab %lb"),MAKE_TINT64(KMaxTUint,KMaxTUint));
  1.1282 +	test(a==_TL("ab 1111111111111111111111111111111111111111111111111111111111111111"));
  1.1283 +	test(a.Length()==67);
  1.1284 +	a.Format(_TL("ab %lx"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
  1.1285 +	test(a==_TL("ab 7fffffffffffffff"));
  1.1286 +	test(a.Length()==19);
  1.1287 +	a.Format(_TL("ab %lx"),MAKE_TINT64(KMaxTUint,KMaxTUint));
  1.1288 +	test(a==_TL("ab ffffffffffffffff"));
  1.1289 +	test(a.Length()==19);
  1.1290 +	a.Format(_TL("ab %lo"),MAKE_TINT64((TUint)(KMaxTInt),KMaxTUint));
  1.1291 +	test(a==_TL("ab 777777777777777777777"));
  1.1292 +	test(a.Length()==24);
  1.1293 +	// tests which excercise any 8 byte alignment requirement on 64bit integers
  1.1294 +	a.Format(_TL("%li%S"),MAKE_TINT64(1,2),&fred);
  1.1295 +	test(a==_TL("4294967298fred"));
  1.1296 +	a.Format(_TL("%S%li%S"),&fred,MAKE_TINT64(1,2),&fred);
  1.1297 +	test(a==_TL("fred4294967298fred"));
  1.1298 +	a.Format(_TL("%lu%S"),MAKE_TINT64(1,2),&fred);
  1.1299 +	test(a==_TL("4294967298fred"));
  1.1300 +	a.Format(_TL("%S%lu%S"),&fred,MAKE_TINT64(1,2),&fred);
  1.1301 +	test(a==_TL("fred4294967298fred"));
  1.1302 +
  1.1303 +	a.Format(_TL("ab %U"),233);
  1.1304 +	test(a==_TL("ab 233"));
  1.1305 +	test(a.Length()==6);
  1.1306 +	a.Format(_TL("ab %*d"),5,-131);
  1.1307 +	test(a==_TL("ab  -131"));
  1.1308 +	test(a.Length()==8);
  1.1309 +	a.Format(_TL("ab%c"),'x');
  1.1310 +	test(a==_TL("abx"));
  1.1311 +	test(a.Length()==3);
  1.1312 +	a.Format(_TL("%W"),-131);
  1.1313 +	test(*(TInt32*)a.Ptr()==-131);
  1.1314 +	a.Format(_TL("%M"),-131);
  1.1315 +	test(*(TInt32*)a.Ptr()==2113929215);
  1.1316 +	a.Format(_TL("%w"),-131);
  1.1317 +	test(*(TInt16*)a.Ptr()==-131);
  1.1318 +	a.Format(_TL("%m"),-131);
  1.1319 +	test(*(TInt16*)a.Ptr()==32255);
  1.1320 +	a=_TL("xyz");
  1.1321 +	a.AppendFormat(_TL("ab %+xlx"),TInt64(171));
  1.1322 +	test(a==_TL("xyzab ab"));
  1.1323 +	test(a.Length()==8);
  1.1324 +	a=_TL("xyz");
  1.1325 +	a.AppendFormat(_TL("ab %5S"),&b);
  1.1326 +	test(a==_TL("xyzab   cde"));
  1.1327 +	test(a.Length()==11);
  1.1328 +	a=_TL("xyz");
  1.1329 +	a.AppendFormat(_TL("%W"),-131);
  1.1330 +//	test(*(TInt32*)(a.Ptr()+3)==-131); // Alignment-safe version:
  1.1331 +    TInt val;
  1.1332 +    Mem::Copy(&val,&a[3],4);
  1.1333 +	test(val==-131);
  1.1334 +	a=_TL("xyz");
  1.1335 +//	a.Append(_TL("abc"),3);
  1.1336 +//	test(a==_TL("xyzabc"));
  1.1337 +
  1.1338 +	a.Format(_TL(""));
  1.1339 +	test(a==_TL(""));
  1.1340 +	a.Format(_TL(""),9,5);
  1.1341 +	test(a==_TL(""));
  1.1342 +	a.Format(_TL("qwerty"));
  1.1343 +	test(a==_TL("qwerty"));
  1.1344 +	a.Format(_TL("qwerty"),9,5);
  1.1345 +	test(a==_TL("qwerty"));
  1.1346 +	a.Format(_TL("%$1$d%$2$d"),9,5);
  1.1347 +	test(a==_TL("95"));
  1.1348 +	test(a.Length()==2);
  1.1349 +	a.Format(_TL("%$2$d%$1$d"),9,5);
  1.1350 +	test(a==_TL("59"));
  1.1351 +	test(a.Length()==2);
  1.1352 +	b=_TL("eb");
  1.1353 +	a.Format(_TL("%$1$S%$2$d"),&b,205);
  1.1354 +	test(a==_TL("eb205"));
  1.1355 +	test(a.Length()==5);
  1.1356 +	a.Format(_TL("%$2$d%$1$S"),&b,205);
  1.1357 +	test(a==_TL("205eb"));
  1.1358 +	test(a.Length()==5);
  1.1359 +	b=_TL("ebdb");
  1.1360 +
  1.1361 +// Cannot do this on GCC (X86) because of "Cannot pass objects of non-POD type through '...'. Call will abort at runtime".
  1.1362 +#if !(defined(__GCC32__) && defined(__X86__))
  1.1363 +	const TAny* const zeroTerminatedString=(sizeof(S)==2)? (const TAny*)_S16(":-)E"): (const TAny*)_S8(":-)E");
  1.1364 +	const TInt dummyParameter=0;
  1.1365 +	Test14_ReorderedParameterFormatting(dummyParameter, 0x20ac, 11, 3, 13.89543, zeroTerminatedString, '!', TInt64(199), 2, &b, 6, 30005, TRealX(0.125), 0x8bdd);
  1.1366 +#endif
  1.1367 +
  1.1368 +	test.Next(_L("Print some numbers"));
  1.1369 +	TInt64 TI64 = MAKE_TINT64(0x101010u,0x10101010u);
  1.1370 +	test.Printf(_L("    %%ld: %ld\n"),TI64);
  1.1371 +	test.Printf(_L("    %%lu: %lu\n"),TI64);
  1.1372 +	test.Printf(_L("    %%lx: %lx\n"),TI64);
  1.1373 +	test.Printf(_L("    %%lb: %lb\n"),TI64);
  1.1374 +	test.Printf(_L("    %%lo: %lo\n\n"),TI64);
  1.1375 +	TI64 = UI64LIT(0xabcdef12345678);
  1.1376 +	test.Printf(_L("    %%ld: %ld\n"),TI64);
  1.1377 +	test.Printf(_L("    %%lu: %lu\n"),TI64);
  1.1378 +	test.Printf(_L("    %%lx: %lx\n"),TI64);
  1.1379 +	test.Printf(_L("    %%lb: %lb\n"),TI64);
  1.1380 +	test.Printf(_L("    %%lo: %lo\n\n"),TI64);
  1.1381 +	TI64 = UI64LIT(0x7fffffffffffffff);
  1.1382 +	test.Printf(_L("    %%ld: %ld\n"),TI64);
  1.1383 +	test.Printf(_L("    %%lu: %lu\n"),TI64);
  1.1384 +	test.Printf(_L("    %%lx: %lx\n"),TI64);
  1.1385 +	test.Printf(_L("    %%lb: %lb\n"),TI64);
  1.1386 +	test.Printf(_L("    %%lo: %lo\n\n"),TI64);
  1.1387 +	TI64 = UI64LIT(0x8000000000000000);
  1.1388 +	test.Printf(_L("    %%ld: %ld\n"),TI64);
  1.1389 +	test.Printf(_L("    %%lu: %lu\n"),TI64);
  1.1390 +	test.Printf(_L("    %%lx: %lx\n"),TI64);
  1.1391 +	test.Printf(_L("    %%lb: %lb\n"),TI64);
  1.1392 +	test.Printf(_L("    %%lo: %lo\n\n"),TI64);
  1.1393 +	TI64 = UI64LIT(0xffffffffffffffff);
  1.1394 +	test.Printf(_L("    %%ld: %ld\n"),TI64);
  1.1395 +	test.Printf(_L("    %%lu: %lu\n"),TI64);
  1.1396 +	test.Printf(_L("    %%lx: %lx\n"),TI64);
  1.1397 +	test.Printf(_L("    %%lb: %lb\n"),TI64);
  1.1398 +	test.Printf(_L("    %%lo: %lo\n\n"),TI64);
  1.1399 +
  1.1400 +	test.Next(_L("Regression tests"));
  1.1401 +	a.Format(_TL("[%-A4p]"));
  1.1402 +	test(a==_TL("[AAAA]"));
  1.1403 +
  1.1404 +	test.End();
  1.1405 +	}
  1.1406 +
  1.1407 +template <class T,class S,class DESTEMPLATE>
  1.1408 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test14_ReorderedParameterFormatting(TInt aDummyParameter, ...)
  1.1409 +	{
  1.1410 +	VA_LIST parameterList;
  1.1411 +	T generated;
  1.1412 +	T expected;
  1.1413 +
  1.1414 +	VA_START(parameterList, aDummyParameter);
  1.1415 +	generated.FormatList(_TL("\t%-**.*fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%.3Fyyyyyyy%c"), parameterList);
  1.1416 +	test(generated.Length()==61);
  1.1417 +	expected.Format(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeeeebrrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1418 +	test(generated.Left(generated.Length()-1)==expected);
  1.1419 +	test(generated[generated.Length()-1]==(S)0x8bdd);
  1.1420 +
  1.1421 +	VA_START(parameterList, aDummyParameter);
  1.1422 +	generated.FormatList(_TL("\t%$1$-**.*fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%$6$.3Fyyyyyyy%c"), parameterList);
  1.1423 +	test(generated.Length()==61);
  1.1424 +	expected.Format(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeeeebrrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1425 +	test(generated.Left(generated.Length()-1)==expected);
  1.1426 +	test(generated[generated.Length()-1]==(S)0x8bdd);
  1.1427 +
  1.1428 +	VA_START(parameterList, aDummyParameter);
  1.1429 +	generated.FormatList(_TL("\t%$6$.3Fqq%.3swww%+*5Ldeeee%.*Srrrrr%0*xtttttt%$1$-**.*fyyyyyyy%c"), parameterList);
  1.1430 +	test(generated.Length()==61);
  1.1431 +	expected.Format(_TL("\t0.125qq:-)www!!199eeeeebrrrrr007535tttttt13.895%c%c%c%c%cyyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1432 +	test(generated.Left(generated.Length()-1)==expected);
  1.1433 +	test(generated[generated.Length()-1]==(S)0x8bdd);
  1.1434 +
  1.1435 +	VA_START(parameterList, aDummyParameter);
  1.1436 +	generated.FormatList(_TL("\t%-**.*fqq%.3swww%$5$0*xeeee%.*Srrrrr%$3$+*5Ldtttttt%.3Fyyyyyyy%c"), parameterList);
  1.1437 +	test(generated.Length()==61);
  1.1438 +	expected.Format(_TL("\t13.895%c%c%c%c%cqq:-)www007535eeeeebrrrrr!!199tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1439 +	test(generated.Left(generated.Length()-1)==expected);
  1.1440 +	test(generated[generated.Length()-1]==(S)0x8bdd);
  1.1441 +
  1.1442 +	VA_START(parameterList, aDummyParameter);
  1.1443 +	generated.FormatList(_TL("\t%-**.*fqq%$4$.*Swww%+*5Ldeeee%$2$.3srrrrr%0*xtttttt%.3Fyyyyyyy%c"), parameterList);
  1.1444 +	test(generated.Length()==61);
  1.1445 +	expected.Format(_TL("\t13.895%c%c%c%c%cqqebwww!!199eeee:-)rrrrr007535tttttt0.125yyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1446 +	test(generated.Left(generated.Length()-1)==expected);
  1.1447 +	test(generated[generated.Length()-1]==(S)0x8bdd);
  1.1448 +
  1.1449 +	VA_START(parameterList, aDummyParameter);
  1.1450 +	generated.FormatList(_TL("\t%-**.*fqq%.3swww%+*5Ldeeee%$7$crrrrr%0*xtttttt%.3Fyyyyyyy%$4$.*S"), parameterList);
  1.1451 +	test(generated.Length()==61);
  1.1452 +	expected.Format(_TL("\t13.895%c%c%c%c%cqq:-)www!!199eeee"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1453 +	test(generated.Left(29)==expected);
  1.1454 +	test(generated[29]==(S)0x8bdd);
  1.1455 +	test(generated.Mid(29+1)==_TL("rrrrr007535tttttt0.125yyyyyyyeb"));
  1.1456 +
  1.1457 +	VA_START(parameterList, aDummyParameter);
  1.1458 +	generated.FormatList(_TL("\t%$4$.*Sqq%.3swww%+*5Ldeeee%$6$.3Frrrrr%0*xtttttt%$1$-**.*fyyyyyyy%c"), parameterList);
  1.1459 +	test(generated.Length()==61);
  1.1460 +	expected.Format(_TL("\tebqq:-)www!!199eeee0.125rrrrr007535tttttt13.895%c%c%c%c%cyyyyyyy"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1461 +	test(generated.Left(generated.Length()-1)==expected);
  1.1462 +	test(generated[generated.Length()-1]==(S)0x8bdd);
  1.1463 +
  1.1464 +	VA_START(parameterList, aDummyParameter);
  1.1465 +	generated.FormatList(_TL("\t%$7$cqq%$6$.3Fwww%$5$0*xeeee%.*Srrrrr%$3$+*5Ldtttttt%$2$.3syyyyyyy%$1$-**.*f"), parameterList);
  1.1466 +	test(generated.Length()==61);
  1.1467 +	test(generated.Left(1)==_TL("\t"));
  1.1468 +	test(generated[1]==(S)0x8bdd);
  1.1469 +	expected.Format(_TL("qq0.125www007535eeeeebrrrrr!!199tttttt:-)yyyyyyy13.895%c%c%c%c%c"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1470 +	test(generated.Mid(2)==expected);
  1.1471 +
  1.1472 +	VA_START(parameterList, aDummyParameter);
  1.1473 +	generated.FormatList(_TL("\t%$7$cqq%$6$.3Fwww%$5$0*xeeee%$4$.*Srrrrr%$3$+*5Ldtttttt%$2$.3syyyyyyy%$1$-**.*f"), parameterList);
  1.1474 +	test(generated.Length()==61);
  1.1475 +	test(generated.Left(1)==_TL("\t"));
  1.1476 +	test(generated[1]==(S)0x8bdd);
  1.1477 +	expected.Format(_TL("qq0.125www007535eeeeebrrrrr!!199tttttt:-)yyyyyyy13.895%c%c%c%c%c"), (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac, (S)0x20ac);
  1.1478 +	test(generated.Mid(2)==expected);
  1.1479 +	}
  1.1480 +
  1.1481 +template <class T,class S,class DESTEMPLATE>
  1.1482 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::Test15()
  1.1483 +// Replacing
  1.1484 +	{
  1.1485 +	test.Start(_L("Replace"));
  1.1486 +	T a,b;
  1.1487 +	test(a.MaxLength()>=9);
  1.1488 +	a=_TL("abccccc");
  1.1489 +	b=_TL("def");
  1.1490 +	a.Replace(3,4,b); // Replace with smaller in middle (insert and delete)
  1.1491 +	test(a==_TL("abcdef"));
  1.1492 +	a.Replace(1,1,b); // Replace with larger in middle (insert and delete)
  1.1493 +	test(a==_TL("adefcdef"));
  1.1494 +	a.Replace(0,8,_TL("")); // Replace complete string (delete)
  1.1495 +	test(a==_TL(""));
  1.1496 +	a.Replace(0,0,b); // Replace at beginning (insert)
  1.1497 +	test(a==b);
  1.1498 +	a.Replace(3,0,_TL("xyz")); // Replace at end (append)
  1.1499 +	test(a==_TL("defxyz"));
  1.1500 +	a.Replace(0,0,_TL("")); // Replace nothing at beginning (do nothing)
  1.1501 +	test(a==_TL("defxyz"));
  1.1502 +	a.Replace(6,0,_TL("")); // Replace nothing at end (do nothing)
  1.1503 +	test(a==_TL("defxyz"));
  1.1504 +	//a.Replace(6,1,_TL("")); // this will panic - no char after end to replace
  1.1505 +	//a.Replace(0,7,_TL("")); // this will panic - aint 7 chars to replace
  1.1506 +	test.End();
  1.1507 +	}
  1.1508 +
  1.1509 +template<class T,class S,class DESTEMPLATE>
  1.1510 +GLDEF_C void TestTBuf<T,S,DESTEMPLATE>::test_TBuf()
  1.1511 +// Test the TBuf class.
  1.1512 +	{
  1.1513 +	test.Start(_L("All operations"));
  1.1514 +	Test1();
  1.1515 +	test.Next(_L("Constructors"));
  1.1516 +	Test2();
  1.1517 +	test.Next(_L("Additional tests"));
  1.1518 +	Test3();
  1.1519 +	test.Next(_L("Comparison operators"));
  1.1520 +	Test4();
  1.1521 +	test.Next(_L("Property access"));
  1.1522 +	Test5();
  1.1523 +	test.Next(_L("Fill and swap"));
  1.1524 +	Test6();
  1.1525 +	test.Next(_L("Conversion operators"));
  1.1526 +	Test7();
  1.1527 +	test.Next(_L("Comparison"));
  1.1528 +	Test8();
  1.1529 +	test.Next(_L("Matching"));
  1.1530 +	Test9();
  1.1531 +	test.Next(_L("Locating"));
  1.1532 +	Test10();
  1.1533 +	test.Next(_L("Copying"));
  1.1534 +	Test11();
  1.1535 +	test.Next(_L("Finding"));
  1.1536 +	Test12();
  1.1537 +	test.Next(_L("Basic like ops"));
  1.1538 +	Test13();
  1.1539 +	test.Next(_L("Formating"));
  1.1540 +	Test14();
  1.1541 +	test.Next(_L("Replacing"));
  1.1542 +	Test15();
  1.1543 +	test.End();
  1.1544 +	}
  1.1545 +
  1.1546 +LOCAL_C void testFormat()
  1.1547 +	{
  1.1548 +	TBuf<0x100> aa;
  1.1549 +	aa.Format(_L("x%- 5fx"), 6.2345678);
  1.1550 +	test(aa==_L("x6.234568x"));
  1.1551 +	aa.Format(_L("x%+ 5fx"), 6.2345678);
  1.1552 +	test(aa==_L("x6.234568x"));
  1.1553 +	aa.Format(_L("x% 5fx"), 6.2345678);
  1.1554 +	test(aa==_L("x6.234568x"));
  1.1555 +	aa.Format(_L("x%= 5fx"), 6.2345678);
  1.1556 +	test(aa==_L("x6.234568x"));
  1.1557 +	aa.Format(_L("x%- 10fx"), 6.2345);
  1.1558 +	test(aa==_L("x6.234500  x"));
  1.1559 +	aa.Format(_L("x%+ 10fx"), 6.2345);
  1.1560 +	test(aa==_L("x  6.234500x"));
  1.1561 +	aa.Format(_L("x% 10fx"), 6.2345);
  1.1562 +	test(aa==_L("x  6.234500x"));
  1.1563 +	aa.Format(_L("x%= 10fx"), 6.2345);
  1.1564 +	test(aa==_L("x 6.234500 x"));
  1.1565 +	aa.Format(_L("x%10fx"), 12345352342.545);
  1.1566 +	test(aa==_L("x12,345,352,342.545000x"));
  1.1567 +	aa.Format(_L("x%20.9fx"), 1.0123456789);
  1.1568 +	test(aa==_L("x         1.012345679x"));
  1.1569 +	aa.Format(_L("x%5.1fx"), 1.99);
  1.1570 +	test(aa==_L("x  2.0x"));
  1.1571 +
  1.1572 +// Cannot do these on GCC (X86) because of "Cannot pass objects of non-POD type through '...'. Call will abort at runtime".
  1.1573 +#if !(defined(__GCC32__) && defined(__X86__))
  1.1574 +	aa.Format(_L("x%- 5Fx"), TRealX(6.2345678));
  1.1575 +	test(aa==_L("x6.234568x"));
  1.1576 +	aa.Format(_L("x%+ 5Fx"), TRealX(6.2345678));
  1.1577 +	test(aa==_L("x6.234568x"));
  1.1578 +	aa.Format(_L("x% 5Fx"), TRealX(6.2345678));
  1.1579 +	test(aa==_L("x6.234568x"));
  1.1580 +	aa.Format(_L("x%= 5Fx"), TRealX(6.2345678));
  1.1581 +	test(aa==_L("x6.234568x"));
  1.1582 +	aa.Format(_L("x%- 10Fx"), TRealX(6.2345));
  1.1583 +	test(aa==_L("x6.234500  x"));
  1.1584 +	aa.Format(_L("x%+ 10Fx"), TRealX(6.2345));
  1.1585 +	test(aa==_L("x  6.234500x"));
  1.1586 +	aa.Format(_L("x% 10Fx"), TRealX(6.2345));
  1.1587 +	test(aa==_L("x  6.234500x"));
  1.1588 +	aa.Format(_L("x%+010Fx"), TRealX(6.2345));
  1.1589 +	test(aa==_L("x006.234500x"));
  1.1590 +	aa.Format(_L("x%+10Fx"), TRealX(6.2345));
  1.1591 +	test(aa==_L("x  6.234500x"));
  1.1592 +	aa.Format(_L("x%10Fx"), TRealX(6.2345));
  1.1593 +	test(aa==_L("x  6.234500x"));
  1.1594 +	aa.Format(_L("x%010Fx"), TRealX(6.2345));
  1.1595 +	test(aa==_L("x006.234500x"));
  1.1596 +	aa.Format(_L("x%= 10Fx"), TRealX(6.2345));
  1.1597 +	test(aa==_L("x 6.234500 x"));
  1.1598 +	aa.Format(_L("x%10Fx"), TRealX(12345352342.545));
  1.1599 +	test(aa==_L("x12,345,352,342.545000x"));
  1.1600 +	aa.Format(_L("x%20.9Fx"), TRealX(1.0123456789));
  1.1601 +	test(aa==_L("x         1.012345679x"));
  1.1602 +	aa.Format(_L("x%5.1Fx"), TRealX(1.99));
  1.1603 +	test(aa==_L("x  2.0x"));
  1.1604 +#endif
  1.1605 +
  1.1606 +	aa.Format(_L("x%- 5ex"), 6.2345678);
  1.1607 +	test(aa==_L("x6.234568E+00x"));
  1.1608 +	aa.Format(_L("x%+ 5ex"), 6.2345678);
  1.1609 +	test(aa==_L("x6.234568E+00x"));
  1.1610 +	aa.Format(_L("x% 5ex"), 6.2345678);
  1.1611 +	test(aa==_L("x6.234568E+00x"));
  1.1612 +	aa.Format(_L("x%= 5ex"), 6.2345678);
  1.1613 +	test(aa==_L("x6.234568E+00x"));
  1.1614 +	aa.Format(_L("x%- 14ex"), 6.2345);
  1.1615 +	test(aa==_L("x6.234500E+00  x"));
  1.1616 +	aa.Format(_L("x%+ 14ex"), 6.2345);
  1.1617 +	test(aa==_L("x  6.234500E+00x"));
  1.1618 +	aa.Format(_L("x% 14ex"), 6.2345);
  1.1619 +	test(aa==_L("x  6.234500E+00x"));
  1.1620 +	aa.Format(_L("x%= 14ex"), 6.2345);
  1.1621 +	test(aa==_L("x 6.234500E+00 x"));
  1.1622 +	aa.Format(_L("x%10ex"), 12345352342.545);
  1.1623 +	test(aa==_L("x1.234535E+10x"));
  1.1624 +	aa.Format(_L("x%20.9ex"), 1.0123456789);
  1.1625 +	test(aa==_L("x     1.012345679E+00x"));
  1.1626 +	aa.Format(_L("x%5.1ex"), 1.99);
  1.1627 +	test(aa==_L("x2.0E+00x"));
  1.1628 +	}
  1.1629 +
  1.1630 +
  1.1631 +class TO8 : public TDes8Overflow
  1.1632 +	{
  1.1633 +public:
  1.1634 +	virtual void Overflow(TDes8 &aDes);
  1.1635 +	};
  1.1636 +
  1.1637 +void TO8::Overflow(TDes8 &aDes)
  1.1638 +	{
  1.1639 +	aDes=_L8("OVERFLOW");
  1.1640 +	}
  1.1641 +
  1.1642 +class TO8L : public TDes8Overflow
  1.1643 +	{
  1.1644 +public:
  1.1645 +	virtual void Overflow(TDes8 &aDes);
  1.1646 +	};
  1.1647 +
  1.1648 +void TO8L::Overflow(TDes8 &/*aDes*/)
  1.1649 +	{
  1.1650 +	User::Leave(KErrOverflow);
  1.1651 +	}
  1.1652 +
  1.1653 +class TO16 : public TDes16Overflow
  1.1654 +	{
  1.1655 +public:
  1.1656 +	virtual void Overflow(TDes16 &aDes);
  1.1657 +	};
  1.1658 +
  1.1659 +void TO16::Overflow(TDes16 &aDes)
  1.1660 +	{
  1.1661 +	aDes=_L16("OVERFLOW");
  1.1662 +	}
  1.1663 +
  1.1664 +class TO16L : public TDes16Overflow
  1.1665 +	{
  1.1666 +public:
  1.1667 +	virtual void Overflow(TDes16 &aDes);
  1.1668 +	};
  1.1669 +
  1.1670 +void TO16L::Overflow(TDes16 &/*aDes*/)
  1.1671 +	{
  1.1672 +	User::Leave(KErrOverflow);
  1.1673 +	}
  1.1674 +
  1.1675 +void append8(TDes8 &aBuf, TDes8Overflow *aHandler, TRefByValue<const TDesC8> aFmt, ...)
  1.1676 +	{
  1.1677 +	VA_LIST list;
  1.1678 +	VA_START(list, aFmt);
  1.1679 +	aBuf.AppendFormatList(aFmt, list, aHandler);
  1.1680 +	}
  1.1681 +
  1.1682 +void append16(TDes16 &aBuf, TDes16Overflow *aHandler, TRefByValue<const TDesC16> aFmt, ...)
  1.1683 +	{
  1.1684 +	VA_LIST list;
  1.1685 +	VA_START(list, aFmt);
  1.1686 +	aBuf.AppendFormatList(aFmt, list, aHandler);
  1.1687 +	}
  1.1688 +
  1.1689 +void testOverflow()
  1.1690 +	{
  1.1691 +	test.Start(_L("Test no overflow"));
  1.1692 +	TBuf8<16> buf=_L8("A ");
  1.1693 +	append8(buf, NULL, _L8("Descriptor"));
  1.1694 +	test(buf==_L8("A Descriptor"));
  1.1695 +
  1.1696 +	test.Printf(_L("Use a non-leaving overflow handler\n"));
  1.1697 +	test.Next(_L("Force overflow with no conversions"));
  1.1698 +    TO8 overflow;
  1.1699 +	append8(buf, &overflow, _L8("12345678901234567"));
  1.1700 +	test(buf==_L8("OVERFLOW"));
  1.1701 +
  1.1702 +	test.Next(_L("Force overflow with decimal conversion"));
  1.1703 +	buf=_L8("A Descriptor");
  1.1704 +	append8(buf, &overflow,  _L8("%d"), 12345678);
  1.1705 +	test(buf==_L8("OVERFLOW"));
  1.1706 +
  1.1707 +	test.Printf(_L("Use a leaving overflow handler\n"));
  1.1708 +	test.Next(_L("AppendFormatList with no overflow"));
  1.1709 +	buf=_L8("A Descriptor");
  1.1710 +    TO8L overflowLeave;
  1.1711 +	TRAPD(r, append8(buf, &overflowLeave, _L8("ONE")));
  1.1712 +	test(r==KErrNone);
  1.1713 +	test(buf==_L8("A DescriptorONE"));
  1.1714 +	test.Next(_L("Force overflow with hexadecimal conversion"));
  1.1715 +	buf=_L8("A Descriptor");
  1.1716 +	TRAP(r, append8(buf, &overflowLeave, _L8("%08x"), 0));
  1.1717 +	test(r==KErrOverflow);
  1.1718 +		{
  1.1719 +		test.Printf(_L("Repeat tests with TBuf16\n"));
  1.1720 +		test.Next(_L("Test no overflow"));
  1.1721 +		TBuf16<16> buf=_L16("A ");
  1.1722 +		append16(buf, NULL, _L16("Descriptor"));
  1.1723 +		test(buf==_L16("A Descriptor"));
  1.1724 +
  1.1725 +		test.Printf(_L("Use a non-leaving overflow handler\n"));
  1.1726 +		test.Next(_L("Force overflow with no conversions"));
  1.1727 +		TO16 overflow;
  1.1728 +		append16(buf, &overflow, _L16("12345678901234567"));
  1.1729 +		test(buf==_L16("OVERFLOW"));
  1.1730 +
  1.1731 +		test.Next(_L("Force overflow with decimal conversion"));
  1.1732 +		buf=_L16("A Descriptor");
  1.1733 +		append16(buf, &overflow,  _L16("%d"), 12345678);
  1.1734 +		test(buf==_L16("OVERFLOW"));
  1.1735 +
  1.1736 +		test.Printf(_L("Use a leaving overflow handler\n"));
  1.1737 +		test.Next(_L("AppendFormatList with no overflow"));
  1.1738 +		buf=_L16("A Descriptor");
  1.1739 +		TO16L overflowLeave;
  1.1740 +		TRAPD(r, append16(buf, &overflowLeave, _L16("ONE")));
  1.1741 +		test(r==KErrNone);
  1.1742 +		test(buf==_L16("A DescriptorONE"));
  1.1743 +		test.Next(_L("Force overflow with hexadecimal conversion"));
  1.1744 +		buf=_L16("A Descriptor");
  1.1745 +		TRAP(r, append16(buf, &overflowLeave, _L16("%08x"), 0));
  1.1746 +		test(r==KErrOverflow);
  1.1747 +		}
  1.1748 +	test.End();
  1.1749 +	}
  1.1750 +
  1.1751 +void testIgnoreOverflow()
  1.1752 +	{
  1.1753 +	test.Start(_L("Test no overflow"));
  1.1754 +	TBuf8<16> buf=_L8("A ");
  1.1755 +	append8(buf, NULL, _L8("Descriptor"));
  1.1756 +	test(buf==_L8("A Descriptor"));
  1.1757 +
  1.1758 +	test.Printf(_L("Use a non-leaving overflow handler\n"));
  1.1759 +	test.Next(_L("Force overflow with no conversions"));
  1.1760 +    TDes8IgnoreOverflow overflow;
  1.1761 +	append8(buf, &overflow, _L8("12345678901234567"));
  1.1762 +	test(buf==_L8("A Descriptor1234"));
  1.1763 +
  1.1764 +	test.Next(_L("Force overflow with decimal conversion"));
  1.1765 +	buf=_L8("A Descriptor");
  1.1766 +	append8(buf, &overflow,  _L8("%d"), 123456789);
  1.1767 +	test(buf==_L8("A Descriptor"));
  1.1768 +
  1.1769 +	//test.Printf(_L("Repeat tests with TBuf16\n"));
  1.1770 +	test.Next(_L("Test no overflow"));
  1.1771 +	TBuf16<17> buf2=_L16("A ");
  1.1772 +	append16(buf2, NULL, _L16("Descriptor"));
  1.1773 +	test(buf2==_L16("A Descriptor"));
  1.1774 +
  1.1775 +	test.Printf(_L("Use a non-leaving overflow handler\n"));
  1.1776 +	test.Next(_L("Force overflow with no conversions"));
  1.1777 +	TDes16IgnoreOverflow overflow2;
  1.1778 +	append16(buf2, &overflow2, _L16("12345678901234567"));
  1.1779 +	test(buf2==_L16("A Descriptor12345"));
  1.1780 +
  1.1781 +	test.Next(_L("Force overflow with decimal conversion"));
  1.1782 +	buf2=_L16("A Descriptor");
  1.1783 +	append16(buf2, &overflow2,  _L16("%d"), 123456789);
  1.1784 +	test(buf2==_L16("A Descriptor"));
  1.1785 +
  1.1786 +	test.End();
  1.1787 +	}
  1.1788 +
  1.1789 +void testAppendFormatIgnoreOverflow()
  1.1790 +	{
  1.1791 +	test.Start(_L("Test no overflow"));
  1.1792 +	TBuf8<16> buf;
  1.1793 +	buf.AppendFormat(_L8("A Descriptor"));	
  1.1794 +	test(buf==_L8("A Descriptor"));
  1.1795 +	
  1.1796 +	test.Next(_L("Force overflow with no conversions"));
  1.1797 +    TDes8IgnoreOverflow overflow;
  1.1798 +	buf.AppendFormat(_L8("123456789012345679"),&overflow);
  1.1799 +	test(buf==_L8("A Descriptor1234"));
  1.1800 +	
  1.1801 +	test.Next(_L("Force overflow with decimal conversion"));
  1.1802 +	buf = _L8("Symbian OS");
  1.1803 +	buf.AppendFormat(_L8("%d"), &overflow, 1234567);
  1.1804 +	test(buf==_L8("Symbian OS"));
  1.1805 +	
  1.1806 +	test.Next(_L("Test no overflow"));
  1.1807 +	TBuf16<16> buf2;
  1.1808 +	buf2.AppendFormat(_L16("A Descriptor"));	
  1.1809 +	test(buf2==_L16("A Descriptor"));
  1.1810 +	
  1.1811 +	test.Next(_L("Force overflow with no conversions"));
  1.1812 +    TDes16IgnoreOverflow overflow2;
  1.1813 +	buf2.AppendFormat(_L16("123456789012345679"),&overflow2);
  1.1814 +	test(buf2==_L16("A Descriptor1234"));
  1.1815 +	
  1.1816 +	test.Next(_L("Force overflow with decimal conversion"));
  1.1817 +	buf2 = _L16("Symbian OS");
  1.1818 +	buf2.AppendFormat(_L16("%d"), &overflow2, 1234567);
  1.1819 +	test(buf2==_L16("Symbian OS"));
  1.1820 +
  1.1821 +	test.End();
  1.1822 +
  1.1823 +
  1.1824 +	}
  1.1825 +
  1.1826 +// INC061330  AV28Crit: NTT - TInt TDesC16.FindC -method is giving strange output values 
  1.1827 +// This test should pass with "ELangPrcChinese" locale.
  1.1828 +void INC061330()
  1.1829 +	{
  1.1830 +	TLanguage defaultLang = User::Language();
  1.1831 +
  1.1832 +	TInt err = HAL::Set(HAL::ELanguageIndex, ELangPrcChinese);
  1.1833 +	test(err == KErrNone);	
  1.1834 +
  1.1835 +	TBuf<50> libraryName;
  1.1836 +
  1.1837 +	libraryName.Format(_L("ELOCL.%02d"), ELangPrcChinese);
  1.1838 +
  1.1839 +	//Reset the locale
  1.1840 +	err=UserSvr::ChangeLocale(KNullDesC);
  1.1841 +	test(err==KErrNone);
  1.1842 +
  1.1843 +	//Now change to chinese locale
  1.1844 +	err = UserSvr::ChangeLocale(libraryName);
  1.1845 +	if(err==KErrNotFound)
  1.1846 +		{
  1.1847 +		test.Printf(_L("TEST CASE NOT RUN BECAUSE ELangPrcChinese LOCALE NOT FOUND!\n"));
  1.1848 +		HAL::Set(HAL::ELanguageIndex, defaultLang);
  1.1849 +		return;
  1.1850 +		}
  1.1851 +	test(err == KErrNone);
  1.1852 +	
  1.1853 +	TLanguage lang = User::Language();
  1.1854 +	test(lang == ELangPrcChinese);
  1.1855 +
  1.1856 +	TInt pos;
  1.1857 +	_LIT(KBuf, "hello");
  1.1858 +
  1.1859 +	pos = KBuf().FindC(_L("a"));
  1.1860 +	test(pos == KErrNotFound);
  1.1861 +
  1.1862 +	pos = KBuf().FindC(_L("zzz"));
  1.1863 +	test(pos == KErrNotFound);
  1.1864 +
  1.1865 +	pos = KBuf().FindC(_L("."));
  1.1866 +	test(pos == KErrNotFound);
  1.1867 +
  1.1868 +	pos = KBuf().FindC(_L(":"));
  1.1869 +	test(pos == KErrNotFound);
  1.1870 +
  1.1871 +	pos = KBuf().FindC(_L("hela"));
  1.1872 +	test(pos == KErrNotFound);
  1.1873 +
  1.1874 +	//Reset the locale
  1.1875 +	err=UserSvr::ChangeLocale(KNullDesC);
  1.1876 +	test(err==KErrNone);
  1.1877 +	
  1.1878 +	//Now revert to the original default english locale
  1.1879 +	libraryName.Format(_L("ELOCL.%02d"), defaultLang);
  1.1880 +	test(err == KErrNone);
  1.1881 +	err = UserSvr::ChangeLocale(libraryName);
  1.1882 +	test(err == KErrNone);
  1.1883 +	
  1.1884 +	lang = User::Language();
  1.1885 +	test(lang == defaultLang);
  1.1886 +	}
  1.1887 +#ifndef _DEBUG
  1.1888 +#pragma warning( disable : 4702) //Unreachable code
  1.1889 +#pragma warning( disable : 4710) //Function not expanded
  1.1890 +#endif
  1.1891 +GLDEF_C TInt E32Main()
  1.1892 +// Test the TBuf type.
  1.1893 +    {
  1.1894 +	test.Title();
  1.1895 +
  1.1896 +	test.Start(_L("class TBuf16<0x50>"));
  1.1897 +	TestTBuf<TBuf16<0x50>,TText16,TPtrC16> c(0x50);
  1.1898 +	c.test_TBuf();
  1.1899 +	
  1.1900 +	test.Next(_L("class TBuf8<0x50>"));
  1.1901 +	TestTBuf<TBuf8<0x50>,TText8,TPtrC8> b(0x50);
  1.1902 +	b.test_TBuf();
  1.1903 +	
  1.1904 +	test.Next(_L("class TBuf<0x50>"));
  1.1905 +	TestTBuf<TBuf<0x50>,TText,TPtrC> a(0x50);
  1.1906 +	a.test_TBuf();
  1.1907 +
  1.1908 +	test.Next(_L("TReal formating"));
  1.1909 +	testFormat();
  1.1910 +
  1.1911 +	test.Next(_L("Test overflow handler"));
  1.1912 +	testOverflow();
  1.1913 +
  1.1914 +	test.Next(_L("Test ignore overflow handler"));
  1.1915 +	testIgnoreOverflow();
  1.1916 +
  1.1917 +	test.Next(_L("Test Format ignore overflow handler"));
  1.1918 +	testAppendFormatIgnoreOverflow();
  1.1919 +
  1.1920 +	test.Next(_L("INC061330"));
  1.1921 +	INC061330();
  1.1922 +
  1.1923 +	test.End();
  1.1924 +
  1.1925 +	return(KErrNone);
  1.1926 +    }
  1.1927 +
  1.1928 +//#pragma warning( default : 4702)
  1.1929 +//#pragma warning( default : 4710)
  1.1930 +
  1.1931 +