ReactOS  0.4.14-dev-57-g333b8f1
cstring_test.cpp
Go to the documentation of this file.
1 #define _STLP_DO_IMPORT_CSTD_FUNCTIONS
2 
3 #include <cstring>
4 
6 
7 //This test purpose is to check the right import of math.h C symbols
8 //into the std namespace so we do not use the using namespace std
9 //specification
10 
11 //
12 // TestCase class
13 //
14 class CStringTest : public CPPUNIT_NS::TestCase
15 {
17 #if defined (STLPORT) && !defined (_STLP_USE_NAMESPACES)
19 #endif
22 
23  protected:
24  void import_checks();
25 };
26 
28 
29 #if defined (_MSC_VER) && (_MSC_VER >= 1400)
30 //For deprecated symbols like strcat, strtok...
31 # pragma warning (disable : 4996)
32 #endif
33 
34 //
35 // tests implementation
36 //
38 {
39 #if !defined (STLPORT) || defined (_STLP_USE_NAMESPACES)
40  std::size_t bar = 0;
41  CPPUNIT_CHECK( bar == 0 );
42 
43  CPPUNIT_CHECK( std::memchr("foo", 'o', 3) != NULL );
44  CPPUNIT_CHECK( std::memcmp("foo1", "foo2", 3) == 0 );
45  char buf1[1], buf2[1];
46  CPPUNIT_CHECK( std::memcpy(buf1, buf2, 0) != NULL );
47  CPPUNIT_CHECK( std::memmove(buf1, buf2, 0) != NULL );
48  CPPUNIT_CHECK( std::memset(buf1, 0, 1) != NULL );
49  char buf[16]; buf[0] = 0;
50  const char* foo = "foo";
51 # if !defined(_WIN32_WCE)
52  CPPUNIT_CHECK( std::strcoll("foo", "foo") == 0 );
54 # endif
55  CPPUNIT_CHECK( std::strcat((char*)buf, foo) == (char*)buf ); // buf <- foo
56  CPPUNIT_CHECK( std::strchr(foo, 'o') != NULL );
57  CPPUNIT_CHECK( std::strcmp("foo1", "foo2") < 0 );
58  CPPUNIT_CHECK( std::strcpy((char*)buf, foo) == (char*)buf ); // buf <- foo
59  CPPUNIT_CHECK( std::strcspn("foo", "o") == 1 );
60  CPPUNIT_CHECK( std::strlen("foo") == 3 );
61  CPPUNIT_CHECK( std::strncat((char*)buf, foo, 2) == (char*)buf ); // buf <- foofo
62  CPPUNIT_CHECK( std::strncmp("foo1", "foo2", 3) == 0 );
63  CPPUNIT_CHECK( std::strncpy((char*)buf, foo, 3) == (char*)buf ); // buf <- foo
64  CPPUNIT_CHECK( std::strpbrk(foo, "abcdo") == foo + 1 );
65  const char* foofoo = "foofoo";
66  CPPUNIT_CHECK( std::strrchr(foofoo, 'f') == foofoo + 3 );
67  CPPUNIT_CHECK( std::strspn(foofoo, "aofz") == 6 );
68  CPPUNIT_CHECK( std::strstr(foo, "") == foo );
69  char foofoobuf[] = "foofoo";
70  CPPUNIT_CHECK( std::strtok(foofoobuf, "z") != NULL );
71 # if !defined(_WIN32_WCE)
72  CPPUNIT_CHECK( std::strxfrm((char*)buf, foo, 3) != 0 );
73 # endif
74 #endif
75 }
CPPUNIT_TEST(import_checks)
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:605
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define memchr(s, c, n)
Definition: mkisofs.h:875
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strpbrk(const char *String, const char *Delimiters)
Definition: utclib.c:302
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
const char * strerror(int err)
Definition: compat_str.c:23
CPPUNIT_TEST_SUITE(CStringTest)
#define strcoll
Definition: util.h:34
smooth NULL
Definition: ftsmooth.c:416
__kernel_size_t size_t
Definition: linux.h:237
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
CPPUNIT_TEST_SUITE_REGISTRATION(CStringTest)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void import_checks()
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char * strchr(const char *String, int ch)
Definition: utclib.c:501
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
CPPUNIT_TEST_SUITE_END()
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define CPPUNIT_IGNORE
Definition: cppunit_mini.h:185
_Check_return_opt_ _CRTIMP size_t __cdecl strxfrm(_Out_writes_opt_(_MaxCount) _Post_maybez_ char *_Dst, _In_z_ const char *_Src, _In_ size_t _MaxCount)
#define memset(x, y, z)
Definition: compat.h:39