Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

O3DBIClobTest.cpp

Go to the documentation of this file.
00001 
00012 #include "O3DBIClobTest.h"
00013 
00014 #define     ONEHUNDREDMEGABYTE      100000000
00015 
00016 // ----------------------------------------------------------------------------
00017 // Register the fixture into the 'registry'
00018 
00019 CPPUNIT_TEST_SUITE_REGISTRATION(O3DBIClobTest);
00020 
00021 // ----------------------------------------------------------------------------
00022 // Test initialization and clean up
00023 
00024 void O3DBIClobTest::setUp()
00025 {
00026     _lpszTest = new TCHAR[ONEHUNDREDMEGABYTE];
00027     if (_lpszTest != NULL)
00028     {
00029         PC_TCHAR lpszTest = _T("The big brown fox jumps over the lazy dog. ");
00030         size_t nLength = ::_tcslen(lpszTest);
00031         P_TCHAR p = _lpszTest;
00032         for (unsigned int i = 0;
00033             i < (ONEHUNDREDMEGABYTE - nLength);
00034             i += nLength)
00035         {
00036             p = ::_tcsncpy(p, lpszTest, nLength);
00037             p += nLength;
00038         }
00039         *(p--) = _T('\0');
00040     }
00041 }
00042 
00043 void O3DBIClobTest::tearDown()
00044 {
00045     delete [] _lpszTest;
00046     _lpszTest = NULL;
00047 }
00048 
00049 // ----------------------------------------------------------------------------
00050 // Test cases
00051 
00052 void O3DBIClobTest::TestContructors()
00053 {
00054     PC_TCHAR lpszTest = _T("The big brown fox jumps over the lazy dog.");
00055     size_t nLength = ::_tcslen(lpszTest);
00056 
00057     O3DBIClob clob1;
00058     CPPUNIT_ASSERT(clob1.GetRaw() == NULL);
00059 
00060     O3DBIClob clob2(lpszTest);
00061     CPPUNIT_ASSERT(::_tcscmp(clob2.GetRaw(), lpszTest) == 0);
00062     CPPUNIT_ASSERT(::_tcslen(clob2.GetRaw()) == nLength);
00063 
00064     O3DBIClob clob3(clob2);
00065     CPPUNIT_ASSERT(::_tcscmp(clob2.GetRaw(), clob3.GetRaw()) == 0);
00066     CPPUNIT_ASSERT(::_tcslen(clob3.GetRaw()) == nLength);
00067 
00068     O3DBIClob* pClob = new O3DBIClob(lpszTest);
00069     CPPUNIT_ASSERT(pClob != NULL);
00070     CPPUNIT_ASSERT(::_tcscmp((*pClob).GetRaw(), lpszTest) == 0);
00071     CPPUNIT_ASSERT(::_tcslen((*pClob).GetRaw()) == nLength);
00072     delete pClob;
00073 }
00074 
00075 void O3DBIClobTest::TestComparisonOperator()
00076 {
00077     O3DBIClob clob1(_lpszTest);
00078     O3DBIClob clob2(_lpszTest);
00079     CPPUNIT_ASSERT(clob1 == clob2);
00080 }
00081 
00082 void O3DBIClobTest::TestSetterAndGetter()
00083 {
00084     O3DBIClob clob;
00085     clob.SetRaw(_lpszTest);
00086     CPPUNIT_ASSERT(::_tcscmp(clob.GetRaw(), _lpszTest) == 0);
00087     clob.SetRaw(NULL);
00088     CPPUNIT_ASSERT(clob.GetRaw() == NULL);
00089 }



SourceForge.net Logo Generated on Sun Jan 23 11:36:34 2005 for Oracle Object Oriented Database Interface (O3DBI) by  doxygen 1.3.9.1