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