Advertisement
Darksider3

Untitled

Oct 15th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include "FileIO.hh"
  2.  
  3. #include <cxxtest/TestSuite.h>
  4. using namespace FileIO;
  5. class MyTestSuite15 : public CxxTest::TestSuite
  6. {
  7.   FileIO<64> *test;
  8. public:
  9.   void setUp()
  10.   {
  11.     this->test=new FileIO<64>((char *)"TestIO.data", (char *)"r+b");
  12.   }
  13.   void tearDown()
  14.   {
  15.     delete this->test;
  16.   }
  17.   void test_StackRead()
  18.   {
  19.     TS_ASSERT_EQUALS(test->StackRead(), (char *)"1 Hello World\n");
  20.     for(int i=1; i < 5; i++)
  21.     {
  22.       test->StackRead();
  23.       std::cout << ".";
  24.     }
  25.    
  26.     TS_ASSERT(test->isEOF()==true);
  27.   }
  28.  
  29.   void testHeapRead()
  30.   {
  31.     delete this->test;
  32.     this->test=new FileIO<64>((char *)"TestIO.data", (char *)"r+b", 64);
  33.     TS_ASSERT_EQUALS(test->HeapRead(), (char *)"1 Hello World\n");
  34.     for(int i=1; i < 5; i++)
  35.     {
  36.       test->HeapRead();
  37.       std::cout << ".";
  38.     }
  39.    
  40.     TS_ASSERT(test->isEOF()==true);
  41.   }
  42.   void test_EOF()
  43.   {    
  44.     for(int i=1; i < 5; i++)
  45.     {
  46.       test->StackRead();
  47.       std::cout << ".";
  48.     }
  49.     TS_ASSERT(test->isEOF()==true);
  50.   }
  51.   //FileExists...
  52.   void test_FileExistsTHIS_TRUE()
  53.   {
  54.     TS_ASSERT(test->file_exists()==true);
  55.   }
  56.   void test_FileExistsSTATIC_TRUE()
  57.   {
  58.     TS_ASSERT(FileIO<1>::file_exists((char *)"FileIO.hh")==true);
  59.   }
  60.   void test_FileExistsSTATIC_FALSE()
  61.   {
  62.     TS_ASSERT(FileIO<1>::file_exists((char *)"blablubxy<z1234.aewawsd")==false);
  63.   }
  64.  
  65. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement