ReactOS 0.4.15-dev-7918-g2a2556c
IStreamIteratorTest Class Reference
Inheritance diagram for IStreamIteratorTest:
Collaboration diagram for IStreamIteratorTest:

Protected Member Functions

void istmit1 ()
 
void copy_n_test ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (IStreamIteratorTest)
 
 CPPUNIT_TEST (istmit1)
 
 CPPUNIT_TEST (copy_n_test)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Attributes

 CPPUNIT_IGNORE
 

Detailed Description

Definition at line 19 of file istmit_test.cpp.

Member Function Documentation

◆ copy_n_test()

void IStreamIteratorTest::copy_n_test ( )
protected

Definition at line 82 of file istmit_test.cpp.

83{
84#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) && !defined (_STLP_USE_NO_IOSTREAMS)
85 //This test check that no character is lost while reading the istream
86 //through a istream_iterator.
87 {
88 istringstream istr("aabbcd");
89 string chars;
91 2, back_inserter(chars)).first,
92 2, back_inserter(chars)).first;
93 CPPUNIT_ASSERT( chars == "aabb" );
94 copy_n(ite, 2, back_inserter(chars));
95 CPPUNIT_ASSERT( chars == "aabbcd" );
96 }
97
98 {
99 istringstream istr("11 22 AA BB 33 44 CC DD");
102
104 CPPUNIT_ASSERT( ints.size() == 2 );
105 CPPUNIT_ASSERT( ints[0] == 11 );
106 CPPUNIT_ASSERT( ints[1] == 22 );
107 ints.clear();
108 istr.clear();
110 CPPUNIT_ASSERT( strings.size() == 2 );
111 CPPUNIT_ASSERT( strings[0] == "AA" );
112 CPPUNIT_ASSERT( strings[1] == "BB" );
113 strings.clear();
114 istr.clear();
115 /* The following code cannot work, '33' is extracted as a string
116 * in the previous copy_n call, this value is returned in the pair
117 * returned by copy_n but is lost as this istream_iterator is not used.
118 * copy_n and istream_iterator can only be combined safely if:
119 * - you always extract the same type of istream_iterator and you always reuse
120 * the istream_iterator returned by copy_n (see previous test with "aabbcd")
121 * - you extract different type of object and no object is convertible to an other
122 * as in this current test when you extract int and string (when you extract ints
123 * again it fails as int can be converted to strings.
124 *
125 copy_n(istream_int_ite(istr), 2, back_inserter(ints));
126 CPPUNIT_ASSERT( ints.size() == 2 );
127 CPPUNIT_ASSERT( ints[0] == 33 );
128 CPPUNIT_ASSERT( ints[1] == 44 );
129 istr.clear();
130 copy_n(istream_string_ite(istr), 2, back_inserter(strings));
131 CPPUNIT_ASSERT( strings.size() == 2 );
132 CPPUNIT_ASSERT( strings[0] == "CC" );
133 CPPUNIT_ASSERT( strings[1] == "DD" );
134 */
135 }
136
137 {
138 istringstream is("1 2 3 4 5 6 7 8 9 10");
140 istream_iterator<int> itr(is);
141 itr = copy_n(itr, 0, back_inserter(ints)).first;
142 CPPUNIT_ASSERT( ints.empty() );
143 itr = copy_n(itr, -1, back_inserter(ints)).first;
144 CPPUNIT_ASSERT( ints.empty() );
145 itr = copy_n(itr, 2, back_inserter(ints)).first;
146 CPPUNIT_ASSERT( ints.size() == 2 );
147 CPPUNIT_ASSERT( ints[0] == 1 );
148 CPPUNIT_ASSERT( ints[1] == 2 );
149 itr = copy_n(itr, 2, back_inserter(ints)).first;
150 CPPUNIT_ASSERT( ints.size() == 4 );
151 CPPUNIT_ASSERT( ints[2] == 3 );
152 CPPUNIT_ASSERT( ints[3] == 4 );
153 itr = copy_n(itr, 2, back_inserter(ints)).first;
154 CPPUNIT_ASSERT( ints.size() == 6 );
155 CPPUNIT_ASSERT( ints[4] == 5 );
156 CPPUNIT_ASSERT( ints[5] == 6 );
157 }
158#endif
159}
_STLP_MOVE_TO_STD_NAMESPACE pair< _InputIter, _OutputIter > copy_n(_InputIter __first, _Size __count, _OutputIter __result)
Definition: _algobase.h:399
back_insert_iterator< _Container > _STLP_CALL back_inserter(_Container &__x)
Definition: _iterator.h:187
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLsizei const GLchar *const * strings
Definition: glext.h:7622
const GLint * first
Definition: glext.h:5794
istream_iterator< char > istream_char_ite
Definition: istmit_test.cpp:41
istream_iterator< string > istream_string_ite
Definition: istmit_test.cpp:43
istream_iterator< int > istream_int_ite
Definition: istmit_test.cpp:42
static const struct encodedInt ints[]
Definition: encode.c:48

◆ CPPUNIT_TEST() [1/2]

IStreamIteratorTest::CPPUNIT_TEST ( copy_n_test  )
private

◆ CPPUNIT_TEST() [2/2]

IStreamIteratorTest::CPPUNIT_TEST ( istmit1  )
private

◆ CPPUNIT_TEST_SUITE()

IStreamIteratorTest::CPPUNIT_TEST_SUITE ( IStreamIteratorTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

IStreamIteratorTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ istmit1()

void IStreamIteratorTest::istmit1 ( )
protected

Definition at line 54 of file istmit_test.cpp.

55{
56#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
57 const char* buff = "MyString";
58 istringstream istr(buff);
59
60 char buffer[100];
61 size_t i = 0;
62 istr.unsetf(ios::skipws); // Disable white-space skipping.
63 istream_char_ite s(istr), meos;
64 while (!(s == meos) &&
65 //*TY 01/10/1999 - added end of stream check
66 // NOTE operator!= should not be used here ifndef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
67 (*s != '\n') &&
68 (i < sizeof(buffer) / sizeof(buffer[0]))) { //*TY 07/28/98 - added index check
69 buffer[i++] = *s++;
70 }
71 buffer[i] = '\0'; // Null terminate buffer.
72
74
75 {
76 istringstream empty_istr;
78 }
79#endif
80}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static unsigned char buff[32768]
Definition: fatten.c:17
GLdouble s
Definition: gl.h:2039
GLuint buffer
Definition: glext.h:5915
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

Member Data Documentation

◆ CPPUNIT_IGNORE

IStreamIteratorTest::CPPUNIT_IGNORE
private

Definition at line 27 of file istmit_test.cpp.


The documentation for this class was generated from the following file: