ReactOS  0.4.14-dev-1256-g2125fec
UninitializedTest Class Reference
Inheritance diagram for UninitializedTest:
Collaboration diagram for UninitializedTest:

Protected Member Functions

void copy_test ()
 
void fill_test ()
 
void fill_n_test ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (UninitializedTest)
 
 CPPUNIT_TEST (copy_test)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 14 of file uninitialized_test.cpp.

Member Function Documentation

◆ copy_test()

void UninitializedTest::copy_test ( )
protected

Note: we use static arrays here so the iterators are always pointers, even in debug mode.

Definition at line 87 of file uninitialized_test.cpp.

88 {
89  {
90  //Random iterators
91  {
92  vector<NotTrivialCopyStruct> src(10);
93  vector<NotTrivialCopyStruct> dst(10);
94  uninitialized_copy(src.begin(), src.end(), dst.begin());
96  for (; it != end; ++it) {
97  CPPUNIT_ASSERT( (*it).member == 1 );
98  }
99  }
100  {
103  size_t const count = 10;
106 
107  TrivialCopyStruct* it = src + 0;
109  for (; it != end; ++it) {
110  (*it).member = 0;
111  }
112 
114  for (it = dst+0, end = dst+count; it != end; ++it) {
115 #if defined (STLPORT)
116  /* If the member is 1, it means that library has not found any
117  optimization oportunity and called the regular copy-ctor instead. */
118  CPPUNIT_ASSERT( (*it).member == 0 );
119 #else
120  CPPUNIT_ASSERT( (*it).member == 1 );
121 #endif
122  }
123  }
124  }
125 
126  {
127  //Bidirectional iterator
128  {
129  vector<NotTrivialCopyStruct> src(10);
130  list<NotTrivialCopyStruct> dst(10);
131 
132  list<NotTrivialCopyStruct>::iterator it(dst.begin()), end(dst.end());
133  for (; it != end; ++it) {
134  (*it).member = -1;
135  }
136 
137  uninitialized_copy(src.begin(), src.end(), dst.begin());
138 
139  for (it = dst.begin(); it != end; ++it) {
140  CPPUNIT_ASSERT( (*it).member == 1 );
141  }
142  }
143 
144  {
145  list<NotTrivialCopyStruct> src(10);
146  vector<NotTrivialCopyStruct> dst(10);
147 
149  for (; it != end; ++it) {
150  (*it).member = -1;
151  }
152 
153  uninitialized_copy(src.begin(), src.end(), dst.begin());
154 
155  for (it = dst.begin(); it != end; ++it) {
156  CPPUNIT_ASSERT( (*it).member == 1 );
157  }
158  }
159  }
160 
161  {
162  //Using containers of native types:
163 #if !defined (STLPORT) || !defined (_STLP_NO_MEMBER_TEMPLATES)
164  {
165  vector<int> src;
166  int i;
167  for (i = -5; i < 6; ++i) {
168  src.push_back(i);
169  }
170 
171  //Building a vector result in a uninitialized_copy call internally
172  vector<unsigned int> dst(src.begin(), src.end());
174  for (i = -5; i < 6; ++i, ++it) {
175  CPPUNIT_ASSERT( *it == (unsigned int)i );
176  }
177  }
178 
179  {
180  vector<char> src;
181  char i;
182  for (i = -5; i < 6; ++i) {
183  src.push_back(i);
184  }
185 
186  //Building a vector result in a uninitialized_copy call internally
187  vector<unsigned int> dst(src.begin(), src.end());
189  for (i = -5; i < 6; ++i, ++it) {
190  CPPUNIT_ASSERT( *it == (unsigned int)i );
191  }
192  }
193 
194  {
195  vector<int> src;
196  int i;
197  for (i = -5; i < 6; ++i) {
198  src.push_back(i);
199  }
200 
201  //Building a vector result in a uninitialized_copy call internally
202  vector<float> dst(src.begin(), src.end());
204  for (i = -5; i < 6; ++i, ++it) {
205  CPPUNIT_ASSERT( *it == (float)i );
206  }
207  }
208 
209  {
210  vector<vector<float>*> src(10);
211  vector<vector<float>*> dst(src.begin(), src.end());
212  }
213 
214  {
215  derived d;
216  //base *pb = &d;
217  derived *pd = &d;
218  //base **ppb = &pd;
219  vector<derived*> src(10, pd);
220  vector<base*> dst(src.begin(), src.end());
221  vector<base*>::iterator it(dst.begin()), end(dst.end());
222  for (; it != end; ++it) {
223  CPPUNIT_ASSERT( (*it) == pd );
224  }
225  }
226 #endif
227  }
228 
229  {
230  //Vector initialization:
231  vector<TrivialInitStruct> vect(10);
232  //Just 1 constructor call for the default value:
234  }
235 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
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
value_type * iterator
Definition: _vector.h:124
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result)
#define d
Definition: ke_i.h:81
_STLP_PRIV _List_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition: _list.h:275
GLenum src
Definition: glext.h:6340
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
const value_type * const_iterator
Definition: _vector.h:125
GLenum GLenum dst
Definition: glext.h:6340
static size_t nbConstructorCalls

◆ CPPUNIT_TEST()

UninitializedTest::CPPUNIT_TEST ( copy_test  )
private

◆ CPPUNIT_TEST_SUITE()

UninitializedTest::CPPUNIT_TEST_SUITE ( UninitializedTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

UninitializedTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ fill_n_test()

void UninitializedTest::fill_n_test ( )
protected

◆ fill_test()

void UninitializedTest::fill_test ( )
protected

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