ReactOS 0.4.15-dev-8145-ga541a46
ioiter_test.cpp
Go to the documentation of this file.
1#include <string>
2#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
3#include <sstream>
4#include <vector>
5#include <iterator>
6
8
9#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
10using namespace std;
11#endif
12
13class IoiterTest : public CPPUNIT_NS::TestCase
14{
20
21protected:
22 void ioiter_test();
23 void assign_test();
24 void assign2_test();
25};
26
28
30{
31
32 char c;
33 const char *pc;
34 const char *strorg = "abcd";
35 string tmp;
36
37 string objStr(strorg);
38
39 istringstream objIStrStrm1(objStr);
40 istringstream objIStrStrm2(objStr);
41 istringstream objIStrStrm3(objStr);
42
43 pc = strorg;
44 string::size_type sz = strlen(strorg);
45 string::size_type i;
46 for ( i = 0; i < sz; ++i ) {
47 c = *pc++;
48 tmp += c;
49 }
50 CPPUNIT_ASSERT( tmp == "abcd" );
51
52 istreambuf_iterator<char, char_traits<char> > objIStrmbIt1( objIStrStrm1.rdbuf() );
54
55 tmp.clear();
56
57 for ( i = 0; i < sz /* objIStrmbIt1 != end */; ++i ) {
58 c = *objIStrmbIt1++;
59 tmp += c;
60 }
61 CPPUNIT_ASSERT( tmp == "abcd" );
62
63 tmp.clear();
64
65 istreambuf_iterator<char, char_traits<char> > objIStrmbIt2( objIStrStrm2.rdbuf() );
66 for ( i = 0; i < sz; ++i ) {
67 c = *objIStrmbIt2;
68 tmp += c;
69 objIStrmbIt2++;
70 }
71 CPPUNIT_ASSERT( tmp == "abcd" );
72
73 tmp.clear();
74
75 istreambuf_iterator<char, char_traits<char> > objIStrmbIt3( objIStrStrm3.rdbuf() );
76
77 while ( objIStrmbIt3 != end ) {
78 c = *objIStrmbIt3++;
79 tmp += c;
80 }
81 CPPUNIT_ASSERT( tmp == "abcd" );
82}
83
85{
86 stringstream s( "1234567890" );
87 vector<char> v;
88
90 CPPUNIT_CHECK( v.size() == 10 );
91 if ( v.size() == 10 ) {
92 CPPUNIT_CHECK( v[0] == '1' );
93 CPPUNIT_CHECK( v[9] == '0' );
94 }
95}
96
98{
99 stringstream s( "1234567890" );
100 vector<char> v;
101
103 CPPUNIT_CHECK( v.size() == 10 );
104 if ( v.size() == 10 ) {
105 CPPUNIT_CHECK( v[0] == '1' );
106 CPPUNIT_CHECK( v[9] == '0' );
107 }
108}
109
110#endif
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void ioiter_test()
Definition: ioiter_test.cpp:29
CPPUNIT_TEST(assign2_test)
void assign2_test()
Definition: ioiter_test.cpp:97
CPPUNIT_TEST(assign_test)
void assign_test()
Definition: ioiter_test.cpp:84
CPPUNIT_TEST_SUITE(IoiterTest)
CPPUNIT_TEST(ioiter_test)
CPPUNIT_TEST_SUITE_END()
basic_stringbuf< _CharT, _Traits, _Alloc > * rdbuf() const
Definition: _sstream.h:138
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
Definition: cppunit_mini.h:193
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define c
Definition: ke_i.h:80
Definition: features.h:417