71 CheckDisk(); |
70 CheckDisk(); |
72 test.Printf(_L("bwrite1,len=%u\n"),aLength); |
71 test.Printf(_L("bwrite1,len=%u\n"),aLength); |
73 TInt pos=0; // Relative position zero |
72 TInt pos=0; // Relative position zero |
74 aret=TheFile.Seek(ESeekCurrent,pos); |
73 aret=TheFile.Seek(ESeekCurrent,pos); |
75 test.Printf(_L("bwrite2,pos=%u\n"),pos); |
74 test.Printf(_L("bwrite2,pos=%u\n"),pos); |
76 test_KErrNone(aret); |
75 test(aret==KErrNone); |
77 TInt count=pos&0xff; |
76 TInt count=pos&0xff; |
78 tbuf.SetLength(aLength); |
77 tbuf.SetLength(aLength); |
79 TText8* p=(TText8*)tbuf.Ptr(); |
78 TText8* p=(TText8*)tbuf.Ptr(); |
80 TText8* pE=p+aLength; |
79 TText8* pE=p+aLength; |
81 while (p<pE) |
80 while (p<pE) |
164 bret=KErrAlreadyExists;bcreate(aMode|EFileWrite);bret=0; |
163 bret=KErrAlreadyExists;bcreate(aMode|EFileWrite);bret=0; |
165 bopen(aMode|EFileRead); |
164 bopen(aMode|EFileRead); |
166 bret=KErrAccessDenied; bwrite(1); bret=0; |
165 bret=KErrAccessDenied; bwrite(1); bret=0; |
167 bclose(); |
166 bclose(); |
168 aret=TheFile.Open(TheFs,tzzz,EFileRead); |
167 aret=TheFile.Open(TheFs,tzzz,EFileRead); |
169 test_Value(aret, aret == KErrNotFound); |
168 test(aret==KErrNotFound); |
170 test.End(); |
169 test.End(); |
171 } |
170 } |
172 |
171 |
173 LOCAL_C void btest2(TUint aMode) |
172 LOCAL_C void btest2(TUint aMode) |
174 // |
173 // |
198 bposa(KMaxTInt); |
197 bposa(KMaxTInt); |
199 bwrite(50); |
198 bwrite(50); |
200 bposa(0); |
199 bposa(0); |
201 bret=1100; bread(1100); bret=0; |
200 bret=1100; bread(1100); bret=0; |
202 aret=TheFile.Flush(); |
201 aret=TheFile.Flush(); |
203 test_KErrNone(aret); |
202 test(aret==KErrNone); |
204 aret=TheFile.SetSize(2000); |
203 aret=TheFile.SetSize(2000); |
205 test_KErrNone(aret); |
204 test(aret==KErrNone); |
206 TInt pos=0; |
205 TInt pos=0; |
207 aret=TheFile.Seek(ESeekCurrent,pos); |
206 aret=TheFile.Seek(ESeekCurrent,pos); |
208 test_Value(aret, aret == KErrNone && pos==1100); |
207 test(aret==KErrNone && pos==1100); |
209 pos=0; |
208 pos=0; |
210 aret=TheFile.Seek(ESeekEnd,pos); |
209 aret=TheFile.Seek(ESeekEnd,pos); |
211 test_Value(aret, aret == KErrNone && pos==2000); |
210 test(aret==KErrNone && pos==2000); |
212 bclose(); |
211 bclose(); |
213 test.End(); |
212 test.End(); |
214 } |
213 } |
215 |
214 |
216 LOCAL_C void rndtest(TUint aMode) |
215 LOCAL_C void rndtest(TUint aMode) |
224 |
223 |
225 TInt cnt; |
224 TInt cnt; |
226 test.Start(_L("RNDTEST...")); |
225 test.Start(_L("RNDTEST...")); |
227 TInt64 seed(0),zero(0); |
226 TInt64 seed(0),zero(0); |
228 aret=TheFile.Replace(TheFs,rndm,EFileWrite|aMode); |
227 aret=TheFile.Replace(TheFs,rndm,EFileWrite|aMode); |
229 test_KErrNone(aret); |
228 test(aret==KErrNone); |
230 for (cnt=0;cnt<KRandomNumbers;cnt++) |
229 for (cnt=0;cnt<KRandomNumbers;cnt++) |
231 { |
230 { |
232 TBuf8<0x10> b; |
231 TBuf8<0x10> b; |
233 b.Format(TPtrC8((TUint8*)"%8x"),Math::Rand(seed)); |
232 b.Format(TPtrC8((TUint8*)"%8x"),Math::Rand(seed)); |
234 aret=TheFile.Write(b); |
233 aret=TheFile.Write(b); |
235 test_KErrNone(aret); |
234 test(aret==KErrNone); |
236 } |
235 } |
237 TheFile.Close(); |
236 TheFile.Close(); |
238 // |
237 // |
239 test.Next(_L("Reading back")); |
238 test.Next(_L("Reading back")); |
240 seed=zero; |
239 seed=zero; |
241 aret=TheFile.Open(TheFs,rndm,aMode); |
240 aret=TheFile.Open(TheFs,rndm,aMode); |
242 test_KErrNone(aret); |
241 test(aret==KErrNone); |
243 for (cnt=0;cnt<KRandomNumbers;cnt++) |
242 for (cnt=0;cnt<KRandomNumbers;cnt++) |
244 { |
243 { |
245 TBuf8<8> b; |
244 TBuf8<8> b; |
246 b.Format(TPtrC8((TUint8*)"%8x"),Math::Rand(seed)); |
245 b.Format(TPtrC8((TUint8*)"%8x"),Math::Rand(seed)); |
247 TBuf8<8> r; |
246 TBuf8<8> r; |
248 aret=TheFile.Read(r); |
247 aret=TheFile.Read(r); |
249 test_KErrNone(aret); |
248 test(aret==KErrNone); |
250 test(b==r); |
249 test(b==r); |
251 } |
250 } |
252 TheFile.Close(); |
251 TheFile.Close(); |
253 aret=TheFs.Delete(rndm); |
252 aret=TheFs.Delete(rndm); |
254 test_KErrNone(aret); |
253 test(aret==KErrNone); |
255 // |
254 // |
256 test.End(); |
255 test.End(); |
257 } |
256 } |
258 |
257 |
259 LOCAL_C void testAutoClose() |
258 LOCAL_C void testAutoClose() |
263 { |
262 { |
264 |
263 |
265 test.Start(_L("TAutoClose...")); |
264 test.Start(_L("TAutoClose...")); |
266 TAutoClose<RFile> f; |
265 TAutoClose<RFile> f; |
267 aret=f.iObj.Replace(TheFs,rndm,EFileWrite); |
266 aret=f.iObj.Replace(TheFs,rndm,EFileWrite); |
268 test_KErrNone(aret); |
267 test(aret==KErrNone); |
269 TInt64 seed; |
268 TInt64 seed; |
270 for (TInt cnt=0;cnt<KRandomNumbers;cnt++) |
269 for (TInt cnt=0;cnt<KRandomNumbers;cnt++) |
271 { |
270 { |
272 TBuf8<0x10> b; |
271 TBuf8<0x10> b; |
273 b.Format(TPtrC8((TUint8*)"%8x"),Math::Rand(seed)); |
272 b.Format(TPtrC8((TUint8*)"%8x"),Math::Rand(seed)); |
274 aret=f.iObj.Write(b); |
273 aret=f.iObj.Write(b); |
275 test_KErrNone(aret); |
274 test(aret==KErrNone); |
276 } |
275 } |
277 test.End(); |
276 test.End(); |
278 } |
277 } |
279 |
278 |
280 LOCAL_C void readWithNegativeLengthTest() |
279 LOCAL_C void readWithNegativeLengthTest() |
282 test.Start(_L("Read with Negative Length Test...")); |
281 test.Start(_L("Read with Negative Length Test...")); |
283 TInt ret; |
282 TInt ret; |
284 TRequestStatus status = KRequestPending; |
283 TRequestStatus status = KRequestPending; |
285 TheFile.Open(TheFs,tbin,EFileRead); |
284 TheFile.Open(TheFs,tbin,EFileRead); |
286 ret = TheFile.Read(0,tbuf,-1); // sync |
285 ret = TheFile.Read(0,tbuf,-1); // sync |
287 test_Value(ret, ret == KErrArgument); |
286 test ( ret == KErrArgument); |
288 TheFile.Read(0,tbuf,-1,status); // async |
287 TheFile.Read(0,tbuf,-1,status); // async |
289 User::WaitForRequest(status); |
288 User::WaitForRequest(status); |
290 test(status.Int() == KErrArgument); |
289 test(status.Int() == KErrArgument); |
291 TheFile.Close(); |
290 TheFile.Close(); |
292 test.End(); |
291 test.End(); |
298 |
297 |
299 test.Start(_L("Read with Negative Length Test(For EmptyFile)...")); |
298 test.Start(_L("Read with Negative Length Test(For EmptyFile)...")); |
300 RFile f; |
299 RFile f; |
301 MakeFile(_L("C:\\F32-TST\\TFILE\\hello2.txt")); |
300 MakeFile(_L("C:\\F32-TST\\TFILE\\hello2.txt")); |
302 TInt r=f.Open(TheFs,_L("C:\\F32-TST\\TFILE\\hello2.txt"),EFileRead); |
301 TInt r=f.Open(TheFs,_L("C:\\F32-TST\\TFILE\\hello2.txt"),EFileRead); |
303 test_KErrNone(r); |
302 test(r==KErrNone); |
304 |
303 |
305 TBuf8<0x100> a; |
304 TBuf8<0x100> a; |
306 test.Next(_L("Check Negative length when file is empty")); |
305 test.Next(_L("Check Negative length when file is empty")); |
307 r=f.Read(a, -10); |
306 r=f.Read(a, -10); |
308 test_Value(r, r == KErrArgument); |
307 test(r==KErrArgument); |
309 r=f.Read(0,a, -1); |
308 r=f.Read(0,a, -1); |
310 test_Value(r, r == KErrArgument); |
309 test(r==KErrArgument); |
311 r=f.Read(0,a, -10); |
310 r=f.Read(0,a, -10); |
312 test_Value(r, r == KErrArgument); |
311 test(r==KErrArgument); |
313 TRequestStatus stat1; |
312 TRequestStatus stat1; |
314 f.Read(0,a,-5,stat1); |
313 f.Read(0,a,-5,stat1); |
315 User::WaitForRequest(stat1); |
314 User::WaitForRequest(stat1); |
316 test(stat1.Int() == KErrArgument); |
315 test(stat1.Int() == KErrArgument); |
317 f.Read(a,-5,stat1); |
316 f.Read(a,-5,stat1); |