kerneltest/e32test/buffer/t_bflat.cpp
changeset 247 d8d70de2bd36
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
    16 // Test all aspects of the CBufFlat class.
    16 // Test all aspects of the CBufFlat class.
    17 // API Information:
    17 // API Information:
    18 // CBufFlat.
    18 // CBufFlat.
    19 // Details:
    19 // Details:
    20 // - Test all the operations of the class and see if methods are implemented -- 
    20 // - Test all the operations of the class and see if methods are implemented -- 
    21 // including NewL, Reset, Size, Set Reserve, InsertL, Delete, Ptr, Read, Write and Compress.
    21 // including NewL, Reset, Size, Set Reserve, InsertL, Delete, Ptr, Read, ResizeL, Write and Compress.
    22 // - Test CBufFlat constructor is as expected.
    22 // - Test CBufFlat constructor is as expected.
    23 // - Insert data into the flat storage dynamic buffer and verify that InsertL method
    23 // - Insert data into the flat storage dynamic buffer and verify that InsertL method
    24 // is as expected.
    24 // is as expected.
    25 // - Delete all data in buffer using Reset() method  and check size is zero.
    25 // - Delete all data in buffer using Reset() method  and check size is zero.
    26 // - Test Ptr, Free, Size, Backptr and SetReserveL methods work as expected.
    26 // - Test Ptr, Free, Size, Backptr and SetReserveL methods work as expected.
   104 	test(bf1->Size()==0);
   104 	test(bf1->Size()==0);
   105 	bf1->InsertL(0,tb1); // Insert into a string
   105 	bf1->InsertL(0,tb1); // Insert into a string
   106 	bf1->InsertL(5,tb1);
   106 	bf1->InsertL(5,tb1);
   107 	bf1->Delete(16,bf1->Size()-16);
   107 	bf1->Delete(16,bf1->Size()-16);
   108 	test(bf1->Ptr(0)==TPtrC8((TText8*)"HelloHello World"));
   108 	test(bf1->Ptr(0)==TPtrC8((TText8*)"HelloHello World"));
       
   109 	bf1->InsertL(10,tb1,5);
       
   110 	test(bf1->Ptr(0)==TPtrC8((TText8*)"HelloHelloHello World"));
   109 //
   111 //
   110 	test.Next(_L("SetReserve"));
   112 	test.Next(_L("SetReserve"));
   111 	bf1->SetReserveL(50); // SetReserve > 0
   113 	bf1->SetReserveL(50); // SetReserve > 0
   112 	test(bf1->Size()==16);
   114 	test(bf1->Size()==21);
   113 	test(bf1->Ptr(0).Length()==16);
   115 	test(bf1->Ptr(0).Length()==21);
   114 	bf1->Reset();
   116 	bf1->Reset();
   115 	bf1->SetReserveL(0); // SetReserve = 0
   117 	bf1->SetReserveL(0); // SetReserve = 0
   116 	test(bf1->Size()==0);
   118 	test(bf1->Size()==0);
   117 	test(bf1->Ptr(0).Length()==0);
   119 	test(bf1->Ptr(0).Length()==0);
   118 //
   120 //
   134 	test(bf1->Ptr(0)==TPtrC8((TText8*)"lHellol"));
   136 	test(bf1->Ptr(0)==TPtrC8((TText8*)"lHellol"));
   135 	test(bf1->Size()==7);
   137 	test(bf1->Size()==7);
   136 	bf1->Compress(); // Compress
   138 	bf1->Compress(); // Compress
   137 	test(bf1->Size()==7);
   139 	test(bf1->Size()==7);
   138 
   140 
   139 	test.Next(_L("Read"));
   141 	test.Next(_L("Read, Resize"));
   140 	bf1->Read(4,tb1,bf1->Size()-4);
   142 	bf1->Read(4,tb1,bf1->Size()-4);
   141 	test(tb1.Size()==3);
   143 	test(tb1.Size()==3);
   142 	test(tb1==TPtrC8((TText8*)"lol"));
   144 	test(tb1==TPtrC8((TText8*)"lol"));
       
   145 	TBuf8<0x10> tb4=(TText8*)"Hello Hello Sun ";;
       
   146 	TBuf8<0x10> tb5;
       
   147 	test(bf1->Size()==7);
       
   148 	bf1->ResizeL(64); // ResizeL
       
   149 	test(bf1->Size()==64);
       
   150 	bf1->Write(0,tb4,16);
       
   151 	bf1->Write(16,tb4,16);
       
   152 	bf1->Write(32,tb4,16);
       
   153 	bf1->Write(48,tb4,16);
       
   154 	bf1->Read(0,tb5); //Reads maxlength of tb5 that is 16
       
   155 	bf1->Read(0,tb3); //Reads maxlength of tb3 that is 64
       
   156 	test(tb5==TPtrC8((TText8*)"Hello Hello Sun "));
       
   157 	test(tb3==TPtrC8((TText8*)"Hello Hello Sun Hello Hello Sun Hello Hello Sun Hello Hello Sun "));
   143 //
   158 //
   144 	test.End();
   159 	test.End();
   145 	}
   160 	}
   146 
   161 
   147 LOCAL_C void test_CBufFlat()
   162 LOCAL_C void test_CBufFlat()