|
1 // Copyright (c) 1998-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_fsy2k.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <e32test.h> |
|
20 #include "t_server.h" |
|
21 #include <e32hal.h> |
|
22 #include <e32math.h> |
|
23 #include <f32dbg.h> |
|
24 |
|
25 GLDEF_D RTest test(_L("T_FSY2K")); |
|
26 GLDEF_D TBuf<128> gDateBuf; |
|
27 |
|
28 const TInt KMaxValidDateTimes=25; |
|
29 const TInt KMaxInvalidDateTimes=7; |
|
30 |
|
31 static void testRFsSetEntry(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
32 // |
|
33 // Test RFs::SetEntry() and RFs::Entry() functions on both a file and a directory |
|
34 // |
|
35 { |
|
36 MakeFile(_L("Y2KTEST.tst")); |
|
37 |
|
38 TInt r=TheFs.SetEntry(_L("Y2KTEST.tst"),*aTime,KEntryAttHidden,KEntryAttArchive); |
|
39 test(r==KErrNone); |
|
40 |
|
41 TEntry entry; |
|
42 r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
|
43 test(r==KErrNone); |
|
44 |
|
45 TDateTime checkDateTime=(entry.iModified).DateTime(); |
|
46 test(checkDateTime.Year()==aDateTime->Year()); |
|
47 if (validDate) |
|
48 { |
|
49 test(checkDateTime.Month()==aDateTime->Month()); |
|
50 test(checkDateTime.Day()==aDateTime->Day()); |
|
51 } |
|
52 else |
|
53 { |
|
54 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
55 test(checkDateTime.Day()==0); |
|
56 } |
|
57 |
|
58 (entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
59 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
60 |
|
61 r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
62 test(r==KErrNone); |
|
63 |
|
64 MakeDir(_L("\\Y2KTEST\\")); |
|
65 r=TheFs.SetEntry(_L("\\Y2KTEST\\"),*aTime,KEntryAttHidden,KEntryAttArchive); |
|
66 test(r==KErrNone); |
|
67 |
|
68 r=TheFs.Entry(_L("\\Y2KTEST\\"),entry); |
|
69 test(r==KErrNone); |
|
70 |
|
71 checkDateTime=(entry.iModified).DateTime(); |
|
72 test(checkDateTime.Year()==aDateTime->Year()); |
|
73 if (validDate) |
|
74 { |
|
75 test(checkDateTime.Month()==aDateTime->Month()); |
|
76 test(checkDateTime.Day()==aDateTime->Day()); |
|
77 } |
|
78 else |
|
79 { |
|
80 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
81 test(checkDateTime.Day()==0); |
|
82 } |
|
83 |
|
84 (entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
85 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
86 |
|
87 r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
|
88 test(r==KErrNone); |
|
89 |
|
90 } |
|
91 |
|
92 |
|
93 static void testRFsSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
94 // |
|
95 // Test RFs::SetModified() and RFs::Modified() functions on both a file and a directory |
|
96 // |
|
97 { |
|
98 MakeFile(_L("Y2KTEST.tst")); |
|
99 |
|
100 TInt r=TheFs.SetModified(_L("Y2KTEST.tst"),*aTime); |
|
101 test(r==KErrNone); |
|
102 |
|
103 TTime check; |
|
104 r=TheFs.Modified(_L("Y2KTEST.tst"),check); |
|
105 test(r==KErrNone); |
|
106 |
|
107 TDateTime checkDateTime=check.DateTime(); |
|
108 |
|
109 test(checkDateTime.Year()==aDateTime->Year()); |
|
110 if (validDate) |
|
111 { |
|
112 test(checkDateTime.Month()==aDateTime->Month()); |
|
113 test(checkDateTime.Day()==aDateTime->Day()); |
|
114 } |
|
115 else |
|
116 { |
|
117 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
118 test(checkDateTime.Day()==0); |
|
119 } |
|
120 |
|
121 |
|
122 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
123 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
124 |
|
125 r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
126 test(r==KErrNone); |
|
127 |
|
128 MakeDir(_L("\\Y2KTEST\\")); |
|
129 r=TheFs.SetModified(_L("\\Y2KTEST\\"),*aTime); |
|
130 test(r==KErrNone); |
|
131 |
|
132 r=TheFs.Modified(_L("\\Y2KTEST\\"),check); |
|
133 test(r==KErrNone); |
|
134 |
|
135 checkDateTime=check.DateTime(); |
|
136 test(checkDateTime.Year()==aDateTime->Year()); |
|
137 if (validDate) |
|
138 { |
|
139 test(checkDateTime.Month()==aDateTime->Month()); |
|
140 test(checkDateTime.Day()==aDateTime->Day()); |
|
141 } |
|
142 else |
|
143 { |
|
144 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
145 test(checkDateTime.Day()==0); |
|
146 } |
|
147 |
|
148 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
149 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
150 |
|
151 r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
|
152 test(r==KErrNone); |
|
153 } |
|
154 |
|
155 |
|
156 static void testRFileSet(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
157 // |
|
158 // Test RFile::Set() and RFile::Modified() |
|
159 // |
|
160 { |
|
161 RFile file; |
|
162 TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
|
163 test(r==KErrNone || r==KErrPathNotFound); |
|
164 |
|
165 r=file.Set(*aTime,KEntryAttHidden,KEntryAttNormal); |
|
166 test(r==KErrNone); |
|
167 file.Close(); |
|
168 |
|
169 TTime check; |
|
170 file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
|
171 r=file.Modified(check); |
|
172 test(r==KErrNone); |
|
173 file.Close(); |
|
174 |
|
175 test.Printf(_L("Date set to ")); |
|
176 test.Printf(_L("Day %d "),aDateTime->Day()); |
|
177 test.Printf(_L("Month %d "),aDateTime->Month()); |
|
178 test.Printf(_L("Year %d \n"),aDateTime->Year()); |
|
179 |
|
180 TDateTime checkDateTime=check.DateTime(); |
|
181 if (checkDateTime.Year()!=aDateTime->Year()) |
|
182 { |
|
183 // Failure occurs for F32 releases before 111 - due to a problem |
|
184 // in SFILE/SF_FILE DoFsFileSet() in which the TTime parameter |
|
185 // was being incorrectly obtained. Not a year 2000 issue. |
|
186 |
|
187 test.Printf(_L("ERROR!\n")); |
|
188 test.Printf(_L("Actually set to ")); |
|
189 test.Printf(_L("Day %d "),checkDateTime.Day()); |
|
190 test.Printf(_L("Month %d "),checkDateTime.Month()); |
|
191 test.Printf(_L("Year %d \n"),checkDateTime.Year()); |
|
192 // test.Printf(_L("Press any key to continue \n")); |
|
193 // test.Getch(); |
|
194 r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
195 return; |
|
196 } |
|
197 else |
|
198 test(checkDateTime.Year()==aDateTime->Year()); |
|
199 if (validDate) |
|
200 { |
|
201 test(checkDateTime.Month()==aDateTime->Month()); |
|
202 test(checkDateTime.Day()==aDateTime->Day()); |
|
203 } |
|
204 else |
|
205 { |
|
206 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
207 test(checkDateTime.Day()==0); |
|
208 } |
|
209 |
|
210 |
|
211 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
212 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
213 |
|
214 r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
215 |
|
216 } |
|
217 |
|
218 |
|
219 static void testRFileSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
220 // |
|
221 // Test RFile::SetModified() and RFile::Modified() |
|
222 // |
|
223 { |
|
224 RFile file; |
|
225 TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
|
226 test(r==KErrNone || r==KErrPathNotFound); |
|
227 |
|
228 r=file.SetModified(*aTime); |
|
229 test(r==KErrNone); |
|
230 file.Close(); |
|
231 |
|
232 TTime check; |
|
233 file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
|
234 r=file.Modified(check); |
|
235 test(r==KErrNone); |
|
236 file.Close(); |
|
237 |
|
238 TDateTime checkDateTime=check.DateTime(); |
|
239 |
|
240 test(checkDateTime.Year()==aDateTime->Year()); |
|
241 if (validDate) |
|
242 { |
|
243 test(checkDateTime.Month()==aDateTime->Month()); |
|
244 test(checkDateTime.Day()==aDateTime->Day()); |
|
245 } |
|
246 else |
|
247 { |
|
248 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
249 test(checkDateTime.Day()==0); |
|
250 } |
|
251 |
|
252 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
253 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
254 |
|
255 r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
256 |
|
257 } |
|
258 |
|
259 static void testCFileManAttribsL(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
|
260 // |
|
261 // Test CFileMan::Attribs() |
|
262 // |
|
263 { |
|
264 MakeFile(_L("Y2KTEST.tst")); |
|
265 |
|
266 CFileMan* fileMan=CFileMan::NewL(TheFs); |
|
267 |
|
268 TInt r=fileMan->Attribs(_L("Y2KTEST.tst"),KEntryAttHidden,KEntryAttNormal,*aTime); |
|
269 test(r==KErrNone); |
|
270 |
|
271 TEntry entry; |
|
272 r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
|
273 test(r==KErrNone); |
|
274 |
|
275 TTime check=entry.iModified; |
|
276 TDateTime checkDateTime=check.DateTime(); |
|
277 |
|
278 test(checkDateTime.Year()==aDateTime->Year()); |
|
279 if (validDate) |
|
280 { |
|
281 test(checkDateTime.Month()==aDateTime->Month()); |
|
282 test(checkDateTime.Day()==aDateTime->Day()); |
|
283 } |
|
284 else |
|
285 { |
|
286 test(checkDateTime.Month()==aDateTime->Month()+1); |
|
287 test(checkDateTime.Day()==0); |
|
288 } |
|
289 |
|
290 |
|
291 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
|
292 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
|
293 |
|
294 r=TheFs.Delete(_L("Y2KTEST.tst")); |
|
295 test(r==KErrNone); |
|
296 |
|
297 delete fileMan; |
|
298 } |
|
299 |
|
300 // Valid dates to be tested for year 2000 compliance |
|
301 // Times are always set at 11.11.00 |
|
302 |
|
303 LOCAL_D TInt testYearValid[KMaxValidDateTimes] = |
|
304 { |
|
305 1998, // December 31 1998 |
|
306 1999, // January 01 1999 |
|
307 1999, // February 27 1999 |
|
308 1999, // February 28 1999 |
|
309 1999, // March 01 1999 |
|
310 1999, // August 31 1999 |
|
311 1999, // September 01 1999 |
|
312 1999, // September 08 1999 |
|
313 1999, // September 09 1999 |
|
314 1999, // September 09 1999 |
|
315 1999, // December 31 1999 |
|
316 2000, // January 01 2000 |
|
317 2000, // February 27 2000 |
|
318 2000, // February 28 2000 |
|
319 2000, // February 29 2000 |
|
320 2000, // March 01 2000 |
|
321 2000, // December 31 2000 |
|
322 2001, // January 01 2001 |
|
323 2001, // February 28 2001 |
|
324 2001, // March 01 2001 |
|
325 2004, // February 28 2004 |
|
326 2004, // February 29 2004 |
|
327 2004, // March 01 2004 |
|
328 2098, // January 01 2098 |
|
329 2099 // January 01 2099 |
|
330 }; |
|
331 |
|
332 LOCAL_D TMonth testMonthValid[KMaxValidDateTimes] = |
|
333 { |
|
334 EDecember, // December 31 1998 |
|
335 EJanuary, // January 01 1999 |
|
336 EFebruary, // February 27 1999 |
|
337 EFebruary, // February 28 1999 |
|
338 EMarch, // March 01 1999 |
|
339 EAugust, // August 31 1999 |
|
340 ESeptember, // September 01 1999 |
|
341 ESeptember, // September 08 1999 |
|
342 ESeptember, // September 09 1999 |
|
343 ESeptember, // September 10 1999 |
|
344 EDecember, // December 31 1999 |
|
345 EJanuary, // January 01 2000 |
|
346 EFebruary, // February 27 2000 |
|
347 EFebruary, // February 28 2000 |
|
348 EFebruary, // February 29 2000 |
|
349 EMarch, // March 01 2000 |
|
350 EDecember, // December 31 2000 |
|
351 EJanuary, // January 01 2001 |
|
352 EFebruary, // February 28 2001 |
|
353 EMarch, // March 01 2001 |
|
354 EFebruary, // February 28 2004 |
|
355 EFebruary, // February 29 2004 |
|
356 EMarch, // March 01 2004 |
|
357 EJanuary, // January 01 2098 |
|
358 EJanuary // January 01 2099 |
|
359 }; |
|
360 |
|
361 LOCAL_D TInt testDayValid[KMaxValidDateTimes] = |
|
362 { |
|
363 30, // December 31 1998 |
|
364 0, // January 01 1999 |
|
365 26, // February 27 1999 |
|
366 27, // February 28 1999 |
|
367 0, // March 01 1999 |
|
368 30, // August 31 1999 |
|
369 0, // September 01 1999 |
|
370 7, // September 08 1999 |
|
371 8, // September 09 1999 |
|
372 8, // September 09 1999 |
|
373 30, // December 31 1999 |
|
374 0, // January 01 2000 |
|
375 26, // February 27 2000 |
|
376 27, // February 28 2000 |
|
377 28, // February 29 2000 |
|
378 0, // March 01 2000 |
|
379 30, // December 31 2000 |
|
380 0, // January 01 2001 |
|
381 27, // February 28 2001 |
|
382 0, // March 01 2001 |
|
383 27, // February 28 2004 |
|
384 28, // February 29 2004 |
|
385 0, // March 01 2004 |
|
386 0, // January 01 2098 |
|
387 0 // January 01 2099 |
|
388 }; |
|
389 |
|
390 |
|
391 // Invalid dates to be tested for year 2000 compliance |
|
392 // Times are always set at 11.11.00 |
|
393 |
|
394 LOCAL_D TInt testYearInvalid[KMaxInvalidDateTimes] = |
|
395 { |
|
396 1998, // April 31 1998 |
|
397 1999, // February 29 1999 |
|
398 2000, // February 30 2000 |
|
399 2001, // February 29 2001 |
|
400 2002, // February 29 2002 |
|
401 2003, // February 29 2003 |
|
402 2004, // February 30 2004 |
|
403 }; |
|
404 |
|
405 LOCAL_D TMonth testMonthInvalid[KMaxValidDateTimes] = |
|
406 { |
|
407 EApril, // April 31 1998 |
|
408 EFebruary, // February 29 1999 |
|
409 EFebruary, // February 30 2000 |
|
410 EFebruary, // February 29 2001 |
|
411 EFebruary, // February 29 2002 |
|
412 EFebruary, // February 29 2003 |
|
413 EFebruary, // February 30 2004 |
|
414 }; |
|
415 |
|
416 LOCAL_D TInt testDayInvalid[KMaxValidDateTimes] = |
|
417 { |
|
418 30, // April 31 1998 |
|
419 28, // February 29 1999 |
|
420 29, // February 30 2000 |
|
421 28, // February 29 2001 |
|
422 28, // February 29 2002 |
|
423 28, // February 29 2003 |
|
424 29, // February 30 2004 |
|
425 }; |
|
426 |
|
427 LOCAL_D TPtrC invalidDates[KMaxValidDateTimes] = |
|
428 { |
|
429 _L("31st April 1998"), |
|
430 _L("29th February 1999"), |
|
431 _L("30th February 2000"), |
|
432 _L("29th February 2001"), |
|
433 _L("29th February 2002"), |
|
434 _L("29th February 2003"), |
|
435 _L("30th February 2004"), |
|
436 }; |
|
437 |
|
438 |
|
439 static void TestValidDates(TDateTime* aDateTime, TTime* aTime) |
|
440 // |
|
441 // Test an array of valid dates for year 2000 compliance |
|
442 // |
|
443 { |
|
444 test.Next(_L("Test RFs::SetEntry() and RFs::Entry()")); |
|
445 |
|
446 TDateTime* tempDateTime=aDateTime; |
|
447 TTime* tempTime=aTime; |
|
448 TInt i=0; |
|
449 |
|
450 for (;i<KMaxValidDateTimes;i++) |
|
451 { |
|
452 testRFsSetEntry(tempDateTime, tempTime, ETrue); |
|
453 tempDateTime++; |
|
454 tempTime++; |
|
455 } |
|
456 |
|
457 test.Next(_L("Test RFs::SetModified() and RFs::Modified()")); |
|
458 |
|
459 tempDateTime=aDateTime; |
|
460 tempTime=aTime; |
|
461 for (i=0;i<KMaxValidDateTimes;i++) |
|
462 { |
|
463 testRFsSetModified(tempDateTime, tempTime, ETrue); |
|
464 tempDateTime++; |
|
465 tempTime++; |
|
466 } |
|
467 |
|
468 test.Next(_L("Test RFile::Set() and RFile::Modified()")); |
|
469 |
|
470 tempDateTime=aDateTime; |
|
471 tempTime=aTime; |
|
472 for (i=0;i<KMaxValidDateTimes;i++) |
|
473 { |
|
474 testRFileSet(tempDateTime, tempTime, ETrue); |
|
475 tempDateTime++; |
|
476 tempTime++; |
|
477 } |
|
478 |
|
479 test.Next(_L("Test RFile::SetModified() and RFile::Modified()")); |
|
480 |
|
481 tempDateTime=aDateTime; |
|
482 tempTime=aTime; |
|
483 for (i=0;i<KMaxValidDateTimes;i++) |
|
484 { |
|
485 testRFileSetModified(tempDateTime, tempTime, ETrue); |
|
486 tempDateTime++; |
|
487 tempTime++; |
|
488 } |
|
489 |
|
490 test.Next(_L("Test CFileMan::Attribs()")); |
|
491 tempDateTime=aDateTime; |
|
492 tempTime=aTime; |
|
493 for (i=0;i<KMaxValidDateTimes;i++) |
|
494 { |
|
495 TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, ETrue)); |
|
496 test(error==KErrNone); |
|
497 tempDateTime++; |
|
498 tempTime++; |
|
499 } |
|
500 } |
|
501 |
|
502 |
|
503 static void TestInvalidDates(TDateTime* aDateTime, TTime* aTime) |
|
504 // |
|
505 // Test an array of invalid dates for year 2000 compliance |
|
506 // aDateTime is set as one day less than the desired invalid |
|
507 // date, because TDateTime correctly prevents us setting invalid dates |
|
508 // aTime is set to TDateTime + 1 day, which should be the next |
|
509 // correct date after TDateTime, NOT the desired invalid date |
|
510 // |
|
511 { |
|
512 test.Next(_L("Test RFs::SetEntry() and RFs::Entry()")); |
|
513 |
|
514 TDateTime* tempDateTime=aDateTime; |
|
515 TTime* tempTime=aTime; |
|
516 TInt i=0; |
|
517 |
|
518 for (;i<KMaxInvalidDateTimes;i++) |
|
519 { |
|
520 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
521 testRFsSetEntry(tempDateTime, tempTime, EFalse); |
|
522 tempDateTime++; |
|
523 tempTime++; |
|
524 } |
|
525 |
|
526 test.Next(_L("Test RFs::SetModified() and RFs::Modified()")); |
|
527 |
|
528 tempDateTime=aDateTime; |
|
529 tempTime=aTime; |
|
530 for (i=0;i<KMaxInvalidDateTimes;i++) |
|
531 { |
|
532 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
533 testRFsSetModified(tempDateTime, tempTime, EFalse); |
|
534 tempDateTime++; |
|
535 tempTime++; |
|
536 } |
|
537 |
|
538 test.Next(_L("Test RFile::Set() and RFile::Modified()")); |
|
539 |
|
540 tempDateTime=aDateTime; |
|
541 tempTime=aTime; |
|
542 for (i=0;i<KMaxInvalidDateTimes;i++) |
|
543 { |
|
544 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
545 testRFileSet(tempDateTime, tempTime, EFalse); |
|
546 tempDateTime++; |
|
547 tempTime++; |
|
548 } |
|
549 |
|
550 test.Next(_L("Test RFile::SetModified() and RFile::Modified()")); |
|
551 |
|
552 tempDateTime=aDateTime; |
|
553 tempTime=aTime; |
|
554 for (i=0;i<KMaxInvalidDateTimes;i++) |
|
555 { |
|
556 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
557 testRFileSetModified(tempDateTime, tempTime, EFalse); |
|
558 tempDateTime++; |
|
559 tempTime++; |
|
560 } |
|
561 |
|
562 test.Next(_L("Test CFileMan::Attribs()")); |
|
563 tempDateTime=aDateTime; |
|
564 tempTime=aTime; |
|
565 for (i=0;i<KMaxInvalidDateTimes;i++) |
|
566 { |
|
567 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
|
568 TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, EFalse)); |
|
569 test(error==KErrNone); |
|
570 tempDateTime++; |
|
571 tempTime++; |
|
572 } |
|
573 } |
|
574 |
|
575 |
|
576 static void CallTests() |
|
577 // |
|
578 // Do tests relative to session path |
|
579 // |
|
580 { |
|
581 |
|
582 // Set up an array of valid TDateTimes and TTimes to be tested for Y2K compliance |
|
583 |
|
584 TDateTime validDateTime[KMaxValidDateTimes]; |
|
585 TTime validTime[KMaxValidDateTimes]; |
|
586 TInt r; |
|
587 TInt i=0; |
|
588 |
|
589 for (;i<KMaxValidDateTimes;i++) |
|
590 { |
|
591 // Dummy time is used to initialise validDateTime[i] before calling SetX() |
|
592 r=validDateTime[i].Set(1998,EJune,23,11,11,11,0); |
|
593 test(r==KErrNone); |
|
594 r=validDateTime[i].SetYear(testYearValid[i]); |
|
595 test(r==KErrNone); |
|
596 r=validDateTime[i].SetMonth(testMonthValid[i]); |
|
597 test(r==KErrNone); |
|
598 r=validDateTime[i].SetDay(testDayValid[i]); |
|
599 test(r==KErrNone); |
|
600 validTime[i]=validDateTime[i]; |
|
601 } |
|
602 |
|
603 // Set up an array of invalid TDateTimes and TTimes to be tested for Y2K compliance |
|
604 |
|
605 TDateTime invalidDateTime[KMaxInvalidDateTimes]; |
|
606 TTime invalidTime[KMaxInvalidDateTimes]; |
|
607 TTimeIntervalDays extraDay(1); |
|
608 |
|
609 for (i=0;i<KMaxInvalidDateTimes;i++) |
|
610 { |
|
611 // Dummy time is used to initialise validDateTime[i] before calling SetX() |
|
612 r=invalidDateTime[i].Set(1998,EJune,22,11,11,11,0); |
|
613 test(r==KErrNone); |
|
614 r=invalidDateTime[i].SetYear(testYearInvalid[i]); |
|
615 test(r==KErrNone); |
|
616 r=invalidDateTime[i].SetMonth(testMonthInvalid[i]); |
|
617 test(r==KErrNone); |
|
618 r=invalidDateTime[i].SetDay(testDayInvalid[i]); |
|
619 test(r==KErrGeneral); // This will fail because it is an invalid date |
|
620 r=invalidDateTime[i].SetDay(testDayInvalid[i]-1); |
|
621 test(r==KErrNone); // Set it one day less |
|
622 invalidTime[i]=invalidDateTime[i]; |
|
623 invalidTime[i]+=extraDay; // Add on an extra day. This should bump the |
|
624 } // date onto the next month, NOT set the day |
|
625 // to the invalid date in invalidDateTime[i] |
|
626 |
|
627 TestValidDates(&validDateTime[0],&validTime[0]); |
|
628 TestInvalidDates(&invalidDateTime[0],&invalidTime[0]); |
|
629 } |
|
630 |
|
631 GLDEF_C void CallTestsL(void) |
|
632 // |
|
633 // Do testing on aDrive |
|
634 // |
|
635 { |
|
636 |
|
637 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
|
638 test(r==KErrNone || r==KErrAlreadyExists); |
|
639 TRAP(r,CallTests()); |
|
640 if (r==KErrNone) |
|
641 TheFs.ResourceCountMarkEnd(); |
|
642 else |
|
643 { |
|
644 test.Printf(_L("Error: Leave %d\n"),r); |
|
645 test(0); |
|
646 } |
|
647 r=TheFs.RmDir(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
|
648 test(r==KErrNone); |
|
649 } |