ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cstring_test.cpp
Go to the documentation of this file.
00001 #define _STLP_DO_IMPORT_CSTD_FUNCTIONS
00002 
00003 #include <cstring>
00004 
00005 #include "cppunit/cppunit_proxy.h"
00006 
00007 //This test purpose is to check the right import of math.h C symbols
00008 //into the std namespace so we do not use the using namespace std
00009 //specification
00010 
00011 //
00012 // TestCase class
00013 //
00014 class CStringTest : public CPPUNIT_NS::TestCase
00015 {
00016   CPPUNIT_TEST_SUITE(CStringTest);
00017 #if defined (STLPORT) && !defined (_STLP_USE_NAMESPACES)
00018   CPPUNIT_IGNORE;
00019 #endif
00020   CPPUNIT_TEST(import_checks);
00021   CPPUNIT_TEST_SUITE_END();
00022 
00023   protected:
00024     void import_checks();
00025 };
00026 
00027 CPPUNIT_TEST_SUITE_REGISTRATION(CStringTest);
00028 
00029 #if defined (_MSC_VER) && (_MSC_VER >= 1400)
00030 //For deprecated symbols like strcat, strtok...
00031 #  pragma warning (disable : 4996)
00032 #endif
00033 
00034 //
00035 // tests implementation
00036 //
00037 void CStringTest::import_checks()
00038 {
00039 #if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES)
00040   std::size_t bar = 0;
00041   CPPUNIT_CHECK( bar == 0 );
00042 
00043   CPPUNIT_CHECK( std::memchr("foo", 'o', 3) != NULL );
00044   CPPUNIT_CHECK( std::memcmp("foo1", "foo2", 3) == 0 );
00045   char buf1[1], buf2[1];
00046   CPPUNIT_CHECK( std::memcpy(buf1, buf2, 0) != NULL );
00047   CPPUNIT_CHECK( std::memmove(buf1, buf2, 0) != NULL );
00048   CPPUNIT_CHECK( std::memset(buf1, 0, 1) != NULL );
00049   char buf[16]; buf[0] = 0;
00050   const char* foo = "foo";
00051 #  if !defined(_WIN32_WCE)
00052   CPPUNIT_CHECK( std::strcoll("foo", "foo") == 0 );
00053   CPPUNIT_CHECK( std::strerror(0) != NULL );
00054 #  endif
00055   CPPUNIT_CHECK( std::strcat((char*)buf, foo) == (char*)buf ); // buf <- foo
00056   CPPUNIT_CHECK( std::strchr(foo, 'o') != NULL );
00057   CPPUNIT_CHECK( std::strcmp("foo1", "foo2") < 0 );
00058   CPPUNIT_CHECK( std::strcpy((char*)buf, foo) == (char*)buf ); // buf <- foo
00059   CPPUNIT_CHECK( std::strcspn("foo", "o") == 1 );
00060   CPPUNIT_CHECK( std::strlen("foo") == 3 );
00061   CPPUNIT_CHECK( std::strncat((char*)buf, foo, 2) == (char*)buf ); // buf <- foofo
00062   CPPUNIT_CHECK( std::strncmp("foo1", "foo2", 3) == 0 );
00063   CPPUNIT_CHECK( std::strncpy((char*)buf, foo, 3) == (char*)buf ); // buf <- foo
00064   CPPUNIT_CHECK( std::strpbrk(foo, "abcdo") == foo + 1 );
00065   const char* foofoo = "foofoo";
00066   CPPUNIT_CHECK( std::strrchr(foofoo, 'f') == foofoo + 3 );
00067   CPPUNIT_CHECK( std::strspn(foofoo, "aofz") == 6 );
00068   CPPUNIT_CHECK( std::strstr(foo, "") == foo );
00069   char foofoobuf[] = "foofoo";
00070   CPPUNIT_CHECK( std::strtok(foofoobuf, "z") != NULL );
00071 #  if !defined(_WIN32_WCE)
00072   CPPUNIT_CHECK( std::strxfrm((char*)buf, foo, 3) != 0 );
00073 #  endif
00074 #endif
00075 }

Generated on Sun May 27 2012 04:35:20 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.