kerneltest/f32test/server/b_rep.cpp
changeset 149 d9f1e5bfe28c
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
135:5e441a173c63 149:d9f1e5bfe28c
    13 // Description:
    13 // Description:
    14 // f32test\server\b_rep.cpp
    14 // f32test\server\b_rep.cpp
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
       
    18 #define __E32TEST_EXTENSION__
    18 #include <f32file.h>
    19 #include <f32file.h>
    19 #include <e32test.h>
    20 #include <e32test.h>
    20 #include "t_server.h"
    21 #include "t_server.h"
    21 
    22 
    22 GLDEF_D RTest test(_L("B_REP"));
    23 GLDEF_D RTest test(_L("B_REP"));
    40 		if ((numb&0x1f)==0)
    41 		if ((numb&0x1f)==0)
    41             test.Printf(_L("%d\r"),numb);
    42             test.Printf(_L("%d\r"),numb);
    42 
    43 
    43         // Replace file and write data
    44         // Replace file and write data
    44 		r=TheFile.Replace(TheFs,nameBuf1,EFileStream);
    45 		r=TheFile.Replace(TheFs,nameBuf1,EFileStream);
    45 		test(r==KErrNone);
    46 		test_KErrNone(r);
    46 		r=TheFile.Write(testPat1);
    47 		r=TheFile.Write(testPat1);
    47 		test(r==KErrNone);
    48 		test_KErrNone(r);
    48 		
    49 		
    49 		Mem::Copy(&buf[0],&numb,sizeof(TInt));
    50 		Mem::Copy(&buf[0],&numb,sizeof(TInt));
    50 		r=TheFile.Write(buf);
    51 		r=TheFile.Write(buf);
    51 		test(r==KErrNone);
    52 		test_KErrNone(r);
    52 
    53 
    53         // Seek to 0 and check data
    54         // Seek to 0 and check data
    54 		TInt pos=0; 
    55 		TInt pos=0; 
    55 		r=TheFile.Seek(ESeekStart,pos);
    56 		r=TheFile.Seek(ESeekStart,pos);
    56 		test(r==KErrNone);
    57 		test_KErrNone(r);
    57 		test(pos==0);
    58 		test(pos==0);
    58 		r=TheFile.Read(chkPat1,len);
    59 		r=TheFile.Read(chkPat1,len);
    59         test(r==KErrNone);
    60         test_KErrNone(r);
    60         test(chkPat1==testPat1);
    61         test(chkPat1==testPat1);
    61 		r=TheFile.Read(testBuf,sizeof(TInt));
    62 		r=TheFile.Read(testBuf,sizeof(TInt));
    62         test(r==KErrNone);
    63         test_KErrNone(r);
    63 		TInt chkNumb=*((TInt*)testBuf.Ptr());
    64 		TInt chkNumb=*((TInt*)testBuf.Ptr());
    64         test(chkNumb==numb);
    65         test(chkNumb==numb);
    65 
    66 
    66         // Close, then re-open file and check data
    67         // Close, then re-open file and check data
    67 		TheFile.Close();
    68 		TheFile.Close();
    68 		r=TheFile.Open(TheFs,nameBuf1,EFileStream);
    69 		r=TheFile.Open(TheFs,nameBuf1,EFileStream);
    69 		test(r==KErrNone);
    70 		test_KErrNone(r);
    70 		r=TheFile.Read(chkPat1,len);
    71 		r=TheFile.Read(chkPat1,len);
    71         test(r==KErrNone);
    72         test_KErrNone(r);
    72         test(chkPat1==testPat1);
    73         test(chkPat1==testPat1);
    73 		r=TheFile.Read(testBuf,sizeof(TInt));
    74 		r=TheFile.Read(testBuf,sizeof(TInt));
    74         test(r==KErrNone);
    75         test_KErrNone(r);
    75 		chkNumb=*((TInt*)testBuf.Ptr());
    76 		chkNumb=*((TInt*)testBuf.Ptr());
    76         test(chkNumb==numb);
    77         test(chkNumb==numb);
    77 		TheFile.Close();
    78 		TheFile.Close();
    78 		}
    79 		}
    79 	test.Printf(_L("\n"));
    80 	test.Printf(_L("\n"));
    80 	r=TheFs.Delete(nameBuf1);
    81 	r=TheFs.Delete(nameBuf1);
    81 	test(r==KErrNone);
    82 	test_KErrNone(r);
    82 	}
    83 	}
    83 
    84 
    84 GLDEF_C void CallTestsL(void)
    85 GLDEF_C void CallTestsL(void)
    85     {
    86     {
    86     testPat1=_L8("TextProcessorPa");
    87     testPat1=_L8("TextProcessorPa");
    99 	DoTest();
   100 	DoTest();
   100 
   101 
   101 	test.Next(_L("Subdirectory"));
   102 	test.Next(_L("Subdirectory"));
   102 	gSessionPath=_L("\\F32-TST\\TEST1\\");
   103 	gSessionPath=_L("\\F32-TST\\TEST1\\");
   103 	TInt r=TheFs.SetSessionPath(gSessionPath);
   104 	TInt r=TheFs.SetSessionPath(gSessionPath);
   104 	test(r==KErrNone);
   105 	test_KErrNone(r);
   105 	r=TheFs.MkDirAll(gSessionPath);
   106 	r=TheFs.MkDirAll(gSessionPath);
   106 	test(r==KErrNone || r==KErrAlreadyExists);
   107 	test_Value(r, r == KErrNone || r==KErrAlreadyExists);
   107 
   108 
   108 	DoTest();
   109 	DoTest();
   109 
   110 
   110 	test.End();
   111 	test.End();
   111 	}
   112 	}