author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32test\server\t_parse.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include "t_server.h" |
|
22 |
||
23 |
GLDEF_D RTest test(_L("T_PARSE")); |
|
24 |
TPtrC test_string=_L("Y:\\"); |
|
25 |
||
26 |
LOCAL_C void Test1() |
|
27 |
// |
|
28 |
// Test all TParse methods |
|
29 |
// |
|
30 |
{ |
|
31 |
||
32 |
test.Start(_L("Test all TParse methods")); |
|
33 |
TBuf<16> relatedFiles(_L(".CCC")); |
|
34 |
TBuf<16> defaultPath(_L("C:\\")); |
|
35 |
TParse parser; |
|
36 |
TInt r=parser.Set(_L("\\WWW\\XXX\\YYY\\ZZZ\\AAA"),&relatedFiles,&defaultPath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
37 |
test_KErrNone(r); |
0 | 38 |
test(parser.FullName()==_L("C:\\WWW\\XXX\\YYY\\ZZZ\\AAA.CCC")); |
39 |
test(parser.Drive()==_L("C:")); |
|
40 |
test(parser.Path()==_L("\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
41 |
test(parser.DriveAndPath()==_L("C:\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
42 |
test(parser.Name()==_L("AAA")); |
|
43 |
test(parser.Ext()==_L(".CCC")); |
|
44 |
test(parser.NameAndExt()==_L("AAA.CCC")); |
|
45 |
test(parser.DrivePresent()==EFalse); |
|
46 |
test(parser.PathPresent()); |
|
47 |
test(parser.NamePresent()); |
|
48 |
test(parser.ExtPresent()==EFalse); |
|
49 |
test(parser.NameOrExtPresent()); |
|
50 |
test(parser.IsRoot()==EFalse); |
|
51 |
test(parser.IsWild()==EFalse); |
|
52 |
test(parser.IsNameWild()==EFalse); |
|
53 |
test(parser.IsExtWild()==EFalse); |
|
54 |
r=parser.SetNoWild(_L("\\WWW\\XXX\\YYY\\ZZZ\\AAA.EXT"),&relatedFiles,&defaultPath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
test_KErrNone(r); |
0 | 56 |
test(parser.PopDir()==KErrNone); |
57 |
test(parser.AddDir(_L("BBB"))==KErrNone); |
|
58 |
test.End(); |
|
59 |
} |
|
60 |
||
61 |
LOCAL_C void Test2() |
|
62 |
// |
|
63 |
// Test multiple PopDirs |
|
64 |
// |
|
65 |
{ |
|
66 |
||
67 |
test.Start(_L("Test multiple PopDirs")); |
|
68 |
TParse parser; |
|
69 |
TInt r=parser.Set(_L("\\WWW\\XXX\\YYY\\ZZZ\\"),NULL,NULL); |
|
70 |
// TParsePtrC parser(_L("\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
test_KErrNone(r); |
0 | 72 |
r=parser.PopDir(); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
test_KErrNone(r); |
0 | 74 |
test(parser.Path()==_L("\\WWW\\XXX\\YYY\\")); |
75 |
r=parser.PopDir(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
76 |
test_KErrNone(r); |
0 | 77 |
test(parser.Path()==_L("\\WWW\\XXX\\")); |
78 |
r=parser.PopDir(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
test_KErrNone(r); |
0 | 80 |
test(parser.Path()==_L("\\WWW\\")); |
81 |
r=parser.PopDir(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
test_KErrNone(r); |
0 | 83 |
test(parser.Path()==_L("\\")); |
84 |
r=parser.PopDir(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
test_Value(r, r == KErrGeneral); |
0 | 86 |
// |
87 |
test(parser.Set(_L("C:\\Documents\\.TXT"),NULL,NULL)==KErrNone); |
|
88 |
test(parser.PopDir()==KErrNone); |
|
89 |
test(parser.FullName()==_L("C:\\.TXT")); |
|
90 |
test.End(); |
|
91 |
} |
|
92 |
||
93 |
LOCAL_C void Test3() |
|
94 |
// |
|
95 |
// Test conflicting drive letters |
|
96 |
// |
|
97 |
{ |
|
98 |
||
99 |
test.Start(_L("Test conflicting default drive letters")); |
|
100 |
TParse parser; |
|
101 |
TPtrC one=_L("\\ONE\\"); |
|
102 |
TPtrC null=_L("\\"); |
|
103 |
TPtrC x=_L("X:"); |
|
104 |
TPtrC x2=_L("X:\\"); |
|
105 |
TPtrC z=_L("Z:"); |
|
106 |
TInt r=parser.Set(_L("Z:\\Hello"),&one,&null); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
test_KErrNone(r); |
0 | 108 |
test(parser.FullName()==_L("Z:\\Hello")); |
109 |
TPtrC sht=_L("*.SHT"); |
|
110 |
r=parser.Set(_L("Z:"),&sht,&x); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
test_KErrNone(r); |
0 | 112 |
test(parser.FullName()==_L("Z:*.SHT")); |
113 |
r=parser.Set(_L("Hello"),&z,&x2); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
test_KErrNone(r); |
0 | 115 |
test(parser.FullName()==_L("Z:\\Hello")); |
116 |
r=parser.Set(_L("W:\\Hello"),&z,&x2); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
test_KErrNone(r); |
0 | 118 |
test(parser.FullName()==_L("W:\\Hello")); |
119 |
TPtrC abcdefg=_L("abcdefg"); |
|
120 |
TPtrC onetwo=_L("X:\\ONE\\TWO\\.CCC"); |
|
121 |
r=parser.Set(_L("W:"),&abcdefg,&onetwo); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
test_KErrNone(r); |
0 | 123 |
test(parser.FullName()==_L("W:\\ONE\\TWO\\abcdefg.CCC")); |
124 |
TPtrC y=_L("Y:"); |
|
125 |
TPtrC xhello=_L("X:\\HELLO\\"); |
|
126 |
r=parser.Set(_L("World"),&y,&xhello); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
test_KErrNone(r); |
0 | 128 |
test(parser.FullName()==_L("Y:\\HELLO\\World")); |
129 |
TPtrC xhelloext=_L("X:\\HELLO\\.EXT"); |
|
130 |
r=parser.Set(_L("World"),&y,&xhelloext); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
test_KErrNone(r); |
0 | 132 |
test(parser.FullName()==_L("Y:\\HELLO\\World.EXT")); |
133 |
test.End(); |
|
134 |
} |
|
135 |
||
136 |
LOCAL_C void Test4() |
|
137 |
// |
|
138 |
// Conflicting relative path drives and names |
|
139 |
// |
|
140 |
{ |
|
141 |
||
142 |
test.Start(_L("Test conflicting relative drive letters")); |
|
143 |
TParse parser; |
|
144 |
TPtrC xone=_L("X:\\ONE\\"); |
|
145 |
TPtrC y=_L("Y:\\"); |
|
146 |
TInt r=parser.Set(_L("Z:\\Hello"),&xone,&y); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
test_KErrNone(r); |
0 | 148 |
test(parser.FullName()==_L("Z:\\Hello")); |
149 |
TPtrC zone=_L("Z:\\ONE\\"); |
|
150 |
TPtrC xnew=_L("X:\\NEW\\"); |
|
151 |
r=parser.Set(_L("\\Hello"),&zone,&xnew); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
test_KErrNone(r); |
0 | 153 |
test(parser.FullName()==_L("Z:\\Hello")); |
154 |
TPtrC aone=_L("A:\\ONE\\"); |
|
155 |
TPtrC anew=_L("A:\\NEW\\"); |
|
156 |
r=parser.Set(_L("A:Hello"),&aone,&anew); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
test_KErrNone(r); |
0 | 158 |
test(parser.FullName()==_L("A:\\ONE\\Hello")); |
159 |
TPtrC a=_L("A:\\"); |
|
160 |
r=parser.Set(_L("Hello"),&a,&xnew); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
test_KErrNone(r); |
0 | 162 |
test(parser.FullName()==_L("A:\\Hello")); |
163 |
r=parser.Set(_L("Hello"),&aone,&xnew); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
test_KErrNone(r); |
0 | 165 |
test(parser.FullName()==_L("A:\\ONE\\Hello")); |
166 |
test.End(); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
LOCAL_C void Test5() |
|
171 |
// |
|
172 |
// Test illegal paths |
|
173 |
// |
|
174 |
{ |
|
175 |
||
176 |
test.Start(_L("Test errors returned by illegal paths")); |
|
177 |
TParse parser; |
|
178 |
TInt r=parser.Set(_L("FOO\\"),NULL,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
test_Value(r, r == KErrBadName); |
0 | 180 |
r=parser.Set(_L("C:\\FOO\\\\"),NULL,NULL); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
test_KErrNone(r); |
0 | 182 |
test.End(); |
183 |
} |
|
184 |
||
185 |
LOCAL_C void Test6() |
|
186 |
// |
|
187 |
// Test AddDir |
|
188 |
// |
|
189 |
{ |
|
190 |
||
191 |
test.Start(_L("Test AddDir")); |
|
192 |
TParse parser; |
|
193 |
test(parser.Set(_L("C:\\"),NULL,NULL)==KErrNone); |
|
194 |
test(parser.IsRoot()); |
|
195 |
test(parser.FullName()==_L("C:\\")); |
|
196 |
test(parser.AddDir(_L("HELLO"))==KErrNone); |
|
197 |
test(parser.IsRoot()==EFalse); |
|
198 |
test(parser.FullName()==_L("C:\\HELLO\\")); |
|
199 |
test(parser.AddDir(_L("BYEBYE"))==KErrNone); |
|
200 |
test(parser.IsRoot()==EFalse); |
|
201 |
test(parser.FullName()==_L("C:\\HELLO\\BYEBYE\\")); |
|
202 |
test(parser.PopDir()==KErrNone); |
|
203 |
test(parser.IsRoot()==EFalse); |
|
204 |
test(parser.FullName()==_L("C:\\HELLO\\")); |
|
205 |
test(parser.PopDir()==KErrNone); |
|
206 |
test(parser.IsRoot()); |
|
207 |
test(parser.FullName()==_L("C:\\")); |
|
208 |
// |
|
209 |
test(parser.AddDir(_L(""))==KErrNone); |
|
210 |
test(parser.IsRoot()); |
|
211 |
test(parser.FullName()==_L("C:\\")); |
|
212 |
test(parser.AddDir(_L("HELLO"))==KErrNone); |
|
213 |
test(parser.IsRoot()==EFalse); |
|
214 |
test(parser.FullName()==_L("C:\\HELLO\\")); |
|
215 |
test(parser.AddDir(_L(""))==KErrNone); |
|
216 |
test(parser.IsRoot()==EFalse); |
|
217 |
test(parser.FullName()==_L("C:\\HELLO\\")); |
|
218 |
// |
|
219 |
test(parser.Set(_L("C:\\Documents\\.TXT"),NULL,NULL)==KErrNone); |
|
220 |
test(parser.AddDir(_L("Documents"))==KErrNone); |
|
221 |
test(parser.FullName()==_L("C:\\Documents\\Documents\\.TXT")); |
|
222 |
test.End(); |
|
223 |
} |
|
224 |
||
225 |
LOCAL_C void Test7() |
|
226 |
// |
|
227 |
// Test TParsePtr |
|
228 |
// |
|
229 |
{ |
|
230 |
||
231 |
test.Start(_L("Test TParsePtr")); |
|
232 |
TBuf<128> nameBuf=_L("C:\\WWW\\XXX\\YYY\\ZZZ\\AAA.CCC"); |
|
233 |
TParsePtr parser(nameBuf); |
|
234 |
||
235 |
test(parser.FullName()==_L("C:\\WWW\\XXX\\YYY\\ZZZ\\AAA.CCC")); |
|
236 |
test(parser.Drive()==_L("C:")); |
|
237 |
test(parser.Path()==_L("\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
238 |
test(parser.DriveAndPath()==_L("C:\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
239 |
test(parser.Name()==_L("AAA")); |
|
240 |
test(parser.Ext()==_L(".CCC")); |
|
241 |
test(parser.NameAndExt()==_L("AAA.CCC")); |
|
242 |
test(parser.DrivePresent()); |
|
243 |
test(parser.PathPresent()); |
|
244 |
test(parser.NamePresent()); |
|
245 |
test(parser.ExtPresent()); |
|
246 |
test(parser.NameOrExtPresent()); |
|
247 |
test(parser.IsRoot()==EFalse); |
|
248 |
test(parser.IsWild()==EFalse); |
|
249 |
test(parser.IsNameWild()==EFalse); |
|
250 |
test(parser.IsExtWild()==EFalse); |
|
251 |
||
252 |
test(parser.AddDir(_L("HELLO"))==KErrNone); |
|
253 |
test(parser.Path()==_L("\\WWW\\XXX\\YYY\\ZZZ\\HELLO\\")); |
|
254 |
||
255 |
TBuf<16> shortName=_L("1234567812345678"); |
|
256 |
TParsePtr parser2(shortName); |
|
257 |
test(parser2.FullName()==_L("1234567812345678")); |
|
258 |
test(parser2.Path()==_L("")); |
|
259 |
test(parser2.DriveAndPath()==_L("")); |
|
260 |
test(parser2.Ext()==_L("")); |
|
261 |
test(parser2.Name()==_L("1234567812345678")); |
|
262 |
test(parser2.AddDir(_L("TOOBIG"))==KErrGeneral); |
|
263 |
test.End(); |
|
264 |
} |
|
265 |
||
266 |
LOCAL_C void Test8() |
|
267 |
// |
|
268 |
// Test TParsePtrC |
|
269 |
// |
|
270 |
{ |
|
271 |
||
272 |
test.Start(_L("Test TParsePtrC")); |
|
273 |
TBuf<128> nameBuf=_L("C:\\WWW\\XXX\\YYY\\ZZZ\\AAA.CCC"); |
|
274 |
TParsePtrC parser(nameBuf); |
|
275 |
||
276 |
test(parser.FullName()==_L("C:\\WWW\\XXX\\YYY\\ZZZ\\AAA.CCC")); |
|
277 |
test(parser.Drive()==_L("C:")); |
|
278 |
test(parser.Path()==_L("\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
279 |
test(parser.DriveAndPath()==_L("C:\\WWW\\XXX\\YYY\\ZZZ\\")); |
|
280 |
test(parser.Name()==_L("AAA")); |
|
281 |
test(parser.Ext()==_L(".CCC")); |
|
282 |
test(parser.NameAndExt()==_L("AAA.CCC")); |
|
283 |
test(parser.DrivePresent()); |
|
284 |
test(parser.PathPresent()); |
|
285 |
test(parser.NamePresent()); |
|
286 |
test(parser.ExtPresent()); |
|
287 |
test(parser.NameOrExtPresent()); |
|
288 |
test(parser.IsRoot()==EFalse); |
|
289 |
test(parser.IsWild()==EFalse); |
|
290 |
test(parser.IsNameWild()==EFalse); |
|
291 |
test(parser.IsExtWild()==EFalse); |
|
292 |
test.End(); |
|
293 |
} |
|
294 |
||
295 |
LOCAL_C void Test9() |
|
296 |
// |
|
297 |
// Test names with leading spaces |
|
298 |
// |
|
299 |
{ |
|
300 |
||
301 |
test.Start(_L("Test names with leading spaces")); |
|
302 |
TParse parser; |
|
303 |
TBuf<16> nameBuf=_L(" name.txt"); |
|
304 |
TBuf<16> pathBuf=_L("\\PATH\\"); |
|
305 |
||
306 |
TInt r=parser.Set(pathBuf,NULL,&nameBuf); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
test_KErrNone(r); |
0 | 308 |
test(parser.FullName()==_L("\\PATH\\ name.txt")); |
309 |
r=parser.Set(_L(""),&nameBuf,&pathBuf); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
test_KErrNone(r); |
0 | 311 |
test(parser.FullName()==_L("\\PATH\\ name.txt")); |
312 |
r=parser.Set(_L(" name.txt"),NULL,&pathBuf); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
test_KErrNone(r); |
0 | 314 |
test(parser.FullName()==_L("\\PATH\\ name.txt")); |
315 |
r=parser.Set(nameBuf,&pathBuf,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
test_KErrNone(r); |
0 | 317 |
test(parser.FullName()==_L("\\PATH\\ name.txt")); |
318 |
||
319 |
TBuf<16> badPath=_L(" \\PATH\\"); |
|
320 |
r=parser.Set(_L("C:\\"),NULL,&badPath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
test_Value(r, r == KErrBadName); |
0 | 322 |
r=parser.Set(_L("C:\\"),&badPath,NULL); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
test_Value(r, r == KErrBadName); |
0 | 324 |
|
325 |
TBuf<16> spacePath=_L("\\ PATH\\"); |
|
326 |
r=parser.Set(_L("C:"),&nameBuf,&spacePath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
test_KErrNone(r); |
0 | 328 |
test(parser.FullName()==_L("C:\\ PATH\\ name.txt")); |
329 |
||
330 |
TBuf<32> spacename=_L("\\ name . txt "); |
|
331 |
r=parser.Set(_L("C:"),&spacename,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
test_KErrNone(r); |
0 | 333 |
test(parser.FullName()==_L("C:\\ name . txt")); |
334 |
||
335 |
// Illegal (?) values |
|
336 |
||
337 |
TBuf<16> pureSpace=_L(" "); |
|
338 |
r=parser.Set(_L("C:\\NAME\\"),NULL,&pureSpace); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
test_KErrNone(r); |
0 | 340 |
test(parser.FullName()==_L("C:\\NAME\\")); // Trims right off name |
341 |
r=parser.Set(_L("C:\\NAME\\ "),NULL,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
test_KErrNone(r); |
0 | 343 |
test(parser.FullName()==_L("C:\\NAME\\")); |
344 |
||
345 |
TBuf<16> spacePlusExt=_L(" . ext "); |
|
346 |
r=parser.Set(_L("C:\\NAME\\"),NULL,&spacePlusExt); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
test_KErrNone(r); |
0 | 348 |
test(parser.FullName()==_L("C:\\NAME\\ . ext")); // Trims right off ext |
349 |
r=parser.Set(_L("C:\\NAME\\ . ext "),NULL,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
test_KErrNone(r); |
0 | 351 |
test(parser.FullName()==_L("C:\\NAME\\ . ext")); |
352 |
||
353 |
TBuf<32> pathSpace=_L("\\asdf\\zxcv\\ \\asdf\\"); |
|
354 |
r=parser.Set(_L("C:"),NULL,&pathSpace); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
test_KErrNone(r); |
0 | 356 |
test(parser.FullName()==_L("C:\\asdf\\zxcv\\ \\asdf\\")); // Leaves spaces in path |
357 |
r=parser.Set(_L("C:\\NAME\\ \\alt.sdf"),NULL,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
358 |
test_KErrNone(r); |
0 | 359 |
test(parser.FullName()==_L("C:\\NAME\\ \\alt.sdf")); |
360 |
||
361 |
||
362 |
TBuf<32> zeroPath=_L("\\asdf\\wqer\\\\asdf\\"); |
|
363 |
r=parser.Set(_L("NAME.TXT"),NULL,&zeroPath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
test_KErrNone(r); |
0 | 365 |
test(parser.FullName()==_L("\\asdf\\wqer\\\\asdf\\NAME.TXT")); // Leaves zerolength path |
366 |
r=parser.Set(_L("C:\\NAME\\\\alt.sdf"),NULL,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
test_KErrNone(r); |
0 | 368 |
test(parser.FullName()==_L("C:\\NAME\\\\alt.sdf")); |
369 |
test.End(); |
|
370 |
} |
|
371 |
||
372 |
LOCAL_C void Test10() |
|
373 |
// |
|
374 |
// Test a very long path |
|
375 |
// |
|
376 |
{ |
|
377 |
||
378 |
test.Next(_L("Test a Path > 256 chars")); |
|
379 |
TBuf<16> pathPart=_L("\\2345678"); |
|
380 |
TBuf<512> testPath; |
|
381 |
||
382 |
for(TInt i=0;i<63;i++) |
|
383 |
testPath+=pathPart; |
|
384 |
||
385 |
RFs fs; |
|
386 |
TInt r=fs.Connect(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
test_KErrNone(r); |
0 | 388 |
TParse parse; |
389 |
r=fs.Parse(testPath,parse); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
390 |
test_Value(r, r == KErrBadName); |
0 | 391 |
fs.Close(); |
392 |
||
393 |
TFileName longFileName; |
|
394 |
longFileName.SetLength(254); |
|
395 |
// Mem::Fill((TUint8*)longFileName.Ptr(),254,'A'); |
|
396 |
Mem::Fill((TUint8*)longFileName.Ptr(),254*sizeof(TText),'A'); |
|
397 |
longFileName[0]='\\'; |
|
398 |
longFileName[253]='\\'; |
|
399 |
r=parse.Set(longFileName,&test_string,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
400 |
test_KErrNone(r); |
0 | 401 |
r=parse.PopDir(); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
402 |
test_KErrNone(r); |
0 | 403 |
|
404 |
longFileName[123]='\\'; |
|
405 |
r=parse.Set(longFileName,&test_string,NULL); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
406 |
test_KErrNone(r); |
0 | 407 |
r=parse.PopDir(); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
408 |
test_KErrNone(r); |
0 | 409 |
TPtrC startPath((TText*)longFileName.Ptr(),124); |
410 |
test(parse.Path()==startPath); |
|
411 |
||
412 |
TPtrC endPath((TText*)longFileName.Ptr()+124,252-124+1); |
|
413 |
r=parse.AddDir(endPath); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
test_KErrNone(r); |
0 | 415 |
test(parse.Path()==longFileName); |
416 |
} |
|
417 |
||
418 |
LOCAL_C void DoTestsL() |
|
419 |
// |
|
420 |
// Call all tests |
|
421 |
// |
|
422 |
{ |
|
423 |
||
424 |
Test1(); |
|
425 |
Test2(); |
|
426 |
Test3(); |
|
427 |
Test4(); |
|
428 |
Test5(); |
|
429 |
Test6(); |
|
430 |
Test7(); |
|
431 |
Test8(); |
|
432 |
Test9(); |
|
433 |
Test10(); |
|
434 |
} |
|
435 |
||
436 |
GLDEF_C void CallTestsL(void) |
|
437 |
// |
|
438 |
// Test resource counting |
|
439 |
// |
|
440 |
{ |
|
441 |
test.Title(); |
|
442 |
||
443 |
test.Start(_L("Starting TParse Tests ...")); |
|
444 |
DoTestsL(); |
|
445 |
||
446 |
test.End(); |
|
447 |
test.Close(); |
|
448 |
return; |
|
449 |
} |
|
450 |