35 // |
34 // |
36 { |
35 { |
37 MakeFile(_L("Y2KTEST.tst")); |
36 MakeFile(_L("Y2KTEST.tst")); |
38 |
37 |
39 TInt r=TheFs.SetEntry(_L("Y2KTEST.tst"),*aTime,KEntryAttHidden,KEntryAttArchive); |
38 TInt r=TheFs.SetEntry(_L("Y2KTEST.tst"),*aTime,KEntryAttHidden,KEntryAttArchive); |
40 test_KErrNone(r); |
39 test(r==KErrNone); |
41 |
40 |
42 TEntry entry; |
41 TEntry entry; |
43 r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
42 r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
44 test_KErrNone(r); |
43 test(r==KErrNone); |
45 |
44 |
46 TDateTime checkDateTime=(entry.iModified).DateTime(); |
45 TDateTime checkDateTime=(entry.iModified).DateTime(); |
47 test(checkDateTime.Year()==aDateTime->Year()); |
46 test(checkDateTime.Year()==aDateTime->Year()); |
48 if (validDate) |
47 if (validDate) |
49 { |
48 { |
58 |
57 |
59 (entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
58 (entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
60 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
59 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
61 |
60 |
62 r=TheFs.Delete(_L("Y2KTEST.tst")); |
61 r=TheFs.Delete(_L("Y2KTEST.tst")); |
63 test_KErrNone(r); |
62 test(r==KErrNone); |
64 |
63 |
65 MakeDir(_L("\\Y2KTEST\\")); |
64 MakeDir(_L("\\Y2KTEST\\")); |
66 r=TheFs.SetEntry(_L("\\Y2KTEST\\"),*aTime,KEntryAttHidden,KEntryAttArchive); |
65 r=TheFs.SetEntry(_L("\\Y2KTEST\\"),*aTime,KEntryAttHidden,KEntryAttArchive); |
67 test_KErrNone(r); |
66 test(r==KErrNone); |
68 |
67 |
69 r=TheFs.Entry(_L("\\Y2KTEST\\"),entry); |
68 r=TheFs.Entry(_L("\\Y2KTEST\\"),entry); |
70 test_KErrNone(r); |
69 test(r==KErrNone); |
71 |
70 |
72 checkDateTime=(entry.iModified).DateTime(); |
71 checkDateTime=(entry.iModified).DateTime(); |
73 test(checkDateTime.Year()==aDateTime->Year()); |
72 test(checkDateTime.Year()==aDateTime->Year()); |
74 if (validDate) |
73 if (validDate) |
75 { |
74 { |
84 |
83 |
85 (entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
84 (entry.iModified).FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
86 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
85 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
87 |
86 |
88 r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
87 r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
89 test_KErrNone(r); |
88 test(r==KErrNone); |
90 |
89 |
91 } |
90 } |
92 |
91 |
93 |
92 |
94 static void testRFsSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
93 static void testRFsSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
97 // |
96 // |
98 { |
97 { |
99 MakeFile(_L("Y2KTEST.tst")); |
98 MakeFile(_L("Y2KTEST.tst")); |
100 |
99 |
101 TInt r=TheFs.SetModified(_L("Y2KTEST.tst"),*aTime); |
100 TInt r=TheFs.SetModified(_L("Y2KTEST.tst"),*aTime); |
102 test_KErrNone(r); |
101 test(r==KErrNone); |
103 |
102 |
104 TTime check; |
103 TTime check; |
105 r=TheFs.Modified(_L("Y2KTEST.tst"),check); |
104 r=TheFs.Modified(_L("Y2KTEST.tst"),check); |
106 test_KErrNone(r); |
105 test(r==KErrNone); |
107 |
106 |
108 TDateTime checkDateTime=check.DateTime(); |
107 TDateTime checkDateTime=check.DateTime(); |
109 |
108 |
110 test(checkDateTime.Year()==aDateTime->Year()); |
109 test(checkDateTime.Year()==aDateTime->Year()); |
111 if (validDate) |
110 if (validDate) |
122 |
121 |
123 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
122 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
124 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
123 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
125 |
124 |
126 r=TheFs.Delete(_L("Y2KTEST.tst")); |
125 r=TheFs.Delete(_L("Y2KTEST.tst")); |
127 test_KErrNone(r); |
126 test(r==KErrNone); |
128 |
127 |
129 MakeDir(_L("\\Y2KTEST\\")); |
128 MakeDir(_L("\\Y2KTEST\\")); |
130 r=TheFs.SetModified(_L("\\Y2KTEST\\"),*aTime); |
129 r=TheFs.SetModified(_L("\\Y2KTEST\\"),*aTime); |
131 test_KErrNone(r); |
130 test(r==KErrNone); |
132 |
131 |
133 r=TheFs.Modified(_L("\\Y2KTEST\\"),check); |
132 r=TheFs.Modified(_L("\\Y2KTEST\\"),check); |
134 test_KErrNone(r); |
133 test(r==KErrNone); |
135 |
134 |
136 checkDateTime=check.DateTime(); |
135 checkDateTime=check.DateTime(); |
137 test(checkDateTime.Year()==aDateTime->Year()); |
136 test(checkDateTime.Year()==aDateTime->Year()); |
138 if (validDate) |
137 if (validDate) |
139 { |
138 { |
148 |
147 |
149 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
148 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
150 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
149 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
151 |
150 |
152 r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
151 r=TheFs.RmDir(_L("\\Y2KTEST\\")); |
153 test_KErrNone(r); |
152 test(r==KErrNone); |
154 } |
153 } |
155 |
154 |
156 |
155 |
157 static void testRFileSet(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
156 static void testRFileSet(TDateTime* aDateTime, TTime* aTime, TBool validDate) |
158 // |
157 // |
159 // Test RFile::Set() and RFile::Modified() |
158 // Test RFile::Set() and RFile::Modified() |
160 // |
159 // |
161 { |
160 { |
162 RFile file; |
161 RFile file; |
163 TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
162 TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
164 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
163 test(r==KErrNone || r==KErrPathNotFound); |
165 |
164 |
166 r=file.Set(*aTime,KEntryAttHidden,KEntryAttNormal); |
165 r=file.Set(*aTime,KEntryAttHidden,KEntryAttNormal); |
167 test_KErrNone(r); |
166 test(r==KErrNone); |
168 file.Close(); |
167 file.Close(); |
169 |
168 |
170 TTime check; |
169 TTime check; |
171 file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
170 file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
172 r=file.Modified(check); |
171 r=file.Modified(check); |
173 test_KErrNone(r); |
172 test(r==KErrNone); |
174 file.Close(); |
173 file.Close(); |
175 |
174 |
176 test.Printf(_L("Date set to ")); |
175 test.Printf(_L("Date set to ")); |
177 test.Printf(_L("Day %d "),aDateTime->Day()); |
176 test.Printf(_L("Day %d "),aDateTime->Day()); |
178 test.Printf(_L("Month %d "),aDateTime->Month()); |
177 test.Printf(_L("Month %d "),aDateTime->Month()); |
222 // Test RFile::SetModified() and RFile::Modified() |
221 // Test RFile::SetModified() and RFile::Modified() |
223 // |
222 // |
224 { |
223 { |
225 RFile file; |
224 RFile file; |
226 TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
225 TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0); |
227 test_Value(r, r == KErrNone || r==KErrPathNotFound); |
226 test(r==KErrNone || r==KErrPathNotFound); |
228 |
227 |
229 r=file.SetModified(*aTime); |
228 r=file.SetModified(*aTime); |
230 test_KErrNone(r); |
229 test(r==KErrNone); |
231 file.Close(); |
230 file.Close(); |
232 |
231 |
233 TTime check; |
232 TTime check; |
234 file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
233 file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite); |
235 r=file.Modified(check); |
234 r=file.Modified(check); |
236 test_KErrNone(r); |
235 test(r==KErrNone); |
237 file.Close(); |
236 file.Close(); |
238 |
237 |
239 TDateTime checkDateTime=check.DateTime(); |
238 TDateTime checkDateTime=check.DateTime(); |
240 |
239 |
241 test(checkDateTime.Year()==aDateTime->Year()); |
240 test(checkDateTime.Year()==aDateTime->Year()); |
265 MakeFile(_L("Y2KTEST.tst")); |
264 MakeFile(_L("Y2KTEST.tst")); |
266 |
265 |
267 CFileMan* fileMan=CFileMan::NewL(TheFs); |
266 CFileMan* fileMan=CFileMan::NewL(TheFs); |
268 |
267 |
269 TInt r=fileMan->Attribs(_L("Y2KTEST.tst"),KEntryAttHidden,KEntryAttNormal,*aTime); |
268 TInt r=fileMan->Attribs(_L("Y2KTEST.tst"),KEntryAttHidden,KEntryAttNormal,*aTime); |
270 test_KErrNone(r); |
269 test(r==KErrNone); |
271 |
270 |
272 TEntry entry; |
271 TEntry entry; |
273 r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
272 r=TheFs.Entry(_L("Y2KTEST.tst"),entry); |
274 test_KErrNone(r); |
273 test(r==KErrNone); |
275 |
274 |
276 TTime check=entry.iModified; |
275 TTime check=entry.iModified; |
277 TDateTime checkDateTime=check.DateTime(); |
276 TDateTime checkDateTime=check.DateTime(); |
278 |
277 |
279 test(checkDateTime.Year()==aDateTime->Year()); |
278 test(checkDateTime.Year()==aDateTime->Year()); |
291 |
290 |
292 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
291 check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3")); |
293 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
292 test.Printf(_L("Valid date: %S\n"),&gDateBuf); |
294 |
293 |
295 r=TheFs.Delete(_L("Y2KTEST.tst")); |
294 r=TheFs.Delete(_L("Y2KTEST.tst")); |
296 test_KErrNone(r); |
295 test(r==KErrNone); |
297 |
296 |
298 delete fileMan; |
297 delete fileMan; |
299 } |
298 } |
300 |
299 |
301 // Valid dates to be tested for year 2000 compliance |
300 // Valid dates to be tested for year 2000 compliance |
492 tempDateTime=aDateTime; |
491 tempDateTime=aDateTime; |
493 tempTime=aTime; |
492 tempTime=aTime; |
494 for (i=0;i<KMaxValidDateTimes;i++) |
493 for (i=0;i<KMaxValidDateTimes;i++) |
495 { |
494 { |
496 TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, ETrue)); |
495 TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, ETrue)); |
497 test_KErrNone(error); |
496 test(error==KErrNone); |
498 tempDateTime++; |
497 tempDateTime++; |
499 tempTime++; |
498 tempTime++; |
500 } |
499 } |
501 } |
500 } |
502 |
501 |
565 tempTime=aTime; |
564 tempTime=aTime; |
566 for (i=0;i<KMaxInvalidDateTimes;i++) |
565 for (i=0;i<KMaxInvalidDateTimes;i++) |
567 { |
566 { |
568 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
567 test.Printf(_L("Invalid date: %S\n"),&invalidDates[i]); |
569 TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, EFalse)); |
568 TRAPD(error,testCFileManAttribsL(tempDateTime, tempTime, EFalse)); |
570 test_KErrNone(error); |
569 test(error==KErrNone); |
571 tempDateTime++; |
570 tempDateTime++; |
572 tempTime++; |
571 tempTime++; |
573 } |
572 } |
574 } |
573 } |
575 |
574 |
589 |
588 |
590 for (;i<KMaxValidDateTimes;i++) |
589 for (;i<KMaxValidDateTimes;i++) |
591 { |
590 { |
592 // Dummy time is used to initialise validDateTime[i] before calling SetX() |
591 // Dummy time is used to initialise validDateTime[i] before calling SetX() |
593 r=validDateTime[i].Set(1998,EJune,23,11,11,11,0); |
592 r=validDateTime[i].Set(1998,EJune,23,11,11,11,0); |
594 test_KErrNone(r); |
593 test(r==KErrNone); |
595 r=validDateTime[i].SetYear(testYearValid[i]); |
594 r=validDateTime[i].SetYear(testYearValid[i]); |
596 test_KErrNone(r); |
595 test(r==KErrNone); |
597 r=validDateTime[i].SetMonth(testMonthValid[i]); |
596 r=validDateTime[i].SetMonth(testMonthValid[i]); |
598 test_KErrNone(r); |
597 test(r==KErrNone); |
599 r=validDateTime[i].SetDay(testDayValid[i]); |
598 r=validDateTime[i].SetDay(testDayValid[i]); |
600 test_KErrNone(r); |
599 test(r==KErrNone); |
601 validTime[i]=validDateTime[i]; |
600 validTime[i]=validDateTime[i]; |
602 } |
601 } |
603 |
602 |
604 // Set up an array of invalid TDateTimes and TTimes to be tested for Y2K compliance |
603 // Set up an array of invalid TDateTimes and TTimes to be tested for Y2K compliance |
605 |
604 |
609 |
608 |
610 for (i=0;i<KMaxInvalidDateTimes;i++) |
609 for (i=0;i<KMaxInvalidDateTimes;i++) |
611 { |
610 { |
612 // Dummy time is used to initialise validDateTime[i] before calling SetX() |
611 // Dummy time is used to initialise validDateTime[i] before calling SetX() |
613 r=invalidDateTime[i].Set(1998,EJune,22,11,11,11,0); |
612 r=invalidDateTime[i].Set(1998,EJune,22,11,11,11,0); |
614 test_KErrNone(r); |
613 test(r==KErrNone); |
615 r=invalidDateTime[i].SetYear(testYearInvalid[i]); |
614 r=invalidDateTime[i].SetYear(testYearInvalid[i]); |
616 test_KErrNone(r); |
615 test(r==KErrNone); |
617 r=invalidDateTime[i].SetMonth(testMonthInvalid[i]); |
616 r=invalidDateTime[i].SetMonth(testMonthInvalid[i]); |
618 test_KErrNone(r); |
617 test(r==KErrNone); |
619 r=invalidDateTime[i].SetDay(testDayInvalid[i]); |
618 r=invalidDateTime[i].SetDay(testDayInvalid[i]); |
620 test_Value(r, r == KErrGeneral); // This will fail because it is an invalid date |
619 test(r==KErrGeneral); // This will fail because it is an invalid date |
621 r=invalidDateTime[i].SetDay(testDayInvalid[i]-1); |
620 r=invalidDateTime[i].SetDay(testDayInvalid[i]-1); |
622 test_KErrNone(r); // Set it one day less |
621 test(r==KErrNone); // Set it one day less |
623 invalidTime[i]=invalidDateTime[i]; |
622 invalidTime[i]=invalidDateTime[i]; |
624 invalidTime[i]+=extraDay; // Add on an extra day. This should bump the |
623 invalidTime[i]+=extraDay; // Add on an extra day. This should bump the |
625 } // date onto the next month, NOT set the day |
624 } // date onto the next month, NOT set the day |
626 // to the invalid date in invalidDateTime[i] |
625 // to the invalid date in invalidDateTime[i] |
627 |
626 |
634 // Do testing on aDrive |
633 // Do testing on aDrive |
635 // |
634 // |
636 { |
635 { |
637 |
636 |
638 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
637 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
639 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
638 test(r==KErrNone || r==KErrAlreadyExists); |
640 TRAP(r,CallTests()); |
639 TRAP(r,CallTests()); |
641 if (r==KErrNone) |
640 if (r==KErrNone) |
642 TheFs.ResourceCountMarkEnd(); |
641 TheFs.ResourceCountMarkEnd(); |
643 else |
642 else |
644 { |
643 { |
645 test.Printf(_L("Error: Leave %d\n"),r); |
644 test.Printf(_L("Error: Leave %d\n"),r); |
646 test(0); |
645 test(0); |
647 } |
646 } |
648 r=TheFs.RmDir(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
647 r=TheFs.RmDir(_L("\\F32-TST\\YEAR 2000 TESTS\\")); |
649 test_KErrNone(r); |
648 test(r==KErrNone); |
650 } |
649 } |