ReactOS  0.4.13-dev-257-gfabbd7c
SwapTest Class Reference
Inheritance diagram for SwapTest:
Collaboration diagram for SwapTest:

Protected Member Functions

void swap1 ()
 
void swprnge1 ()
 
void swap_container_non_spec ()
 
void swap_container_spec ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (SwapTest)
 
 CPPUNIT_TEST (swap1)
 
 CPPUNIT_TEST (swprnge1)
 
 CPPUNIT_TEST (swap_container_non_spec)
 
 CPPUNIT_TEST (swap_container_spec)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 20 of file swap_test.cpp.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

SwapTest::CPPUNIT_TEST ( swap1  )
private

◆ CPPUNIT_TEST() [2/4]

SwapTest::CPPUNIT_TEST ( swprnge1  )
private

◆ CPPUNIT_TEST() [3/4]

SwapTest::CPPUNIT_TEST ( swap_container_non_spec  )
private

◆ CPPUNIT_TEST() [4/4]

SwapTest::CPPUNIT_TEST ( swap_container_spec  )
private

◆ CPPUNIT_TEST_SUITE()

SwapTest::CPPUNIT_TEST_SUITE ( SwapTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

SwapTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ swap1()

void SwapTest::swap1 ( )
protected

Definition at line 45 of file swap_test.cpp.

46 {
47  int a = 42;
48  int b = 19;
49  swap(a, b);
50 
51  CPPUNIT_ASSERT(a==19);
52  CPPUNIT_ASSERT(b==42);
53 }
#define swap(a, b)
Definition: qsort.c:63
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ swap_container_non_spec()

void SwapTest::swap_container_non_spec ( )
protected

Definition at line 88 of file swap_test.cpp.

89 {
90  queue<Obj> v1;
91  queue<Obj> v2;
92 
93  v1.push( Obj() );
94  v1.back().v = -1;
95  v1.push( Obj() );
96  v1.back().v = -2;
97 
98  v2.push( Obj() );
99  v2.back().v = 10;
100  v2.push( Obj() );
101  v2.back().v = 11;
102  v2.push( Obj() );
103  v2.back().v = 12;
104 
105  CPPUNIT_CHECK( v1.size() == 2 );
106  CPPUNIT_CHECK( v2.size() == 3 );
107 
108  swap( v1, v2 ); // this shouldn't try make it as v1.swap( v2 ), no queue::swap method!
109 
110  CPPUNIT_CHECK( v1.size() == 3 );
111  CPPUNIT_CHECK( v2.size() == 2 );
112 
113  // either copy constructor or assignment operator
114  CPPUNIT_CHECK( v1.front().v == 1 || v1.front().v == 2 );
115  CPPUNIT_CHECK( v1.back().v == 1 || v1.back().v == 2 );
116  CPPUNIT_CHECK( v2.front().v == 1 || v2.front().v == 2 );
117  CPPUNIT_CHECK( v2.back().v == 1 || v2.back().v == 2 );
118 }
#define swap(a, b)
Definition: qsort.c:63
Definition: _queue.h:59
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLfloat GLfloat v1
Definition: glext.h:6062

◆ swap_container_spec()

void SwapTest::swap_container_spec ( )
protected

Definition at line 120 of file swap_test.cpp.

121 {
122 #if 0 /* temporary: investigation of problem with swap */
123  if ( typeid(/* _STLP_PRIV */ _SwapImplemented<vector<Obj> >::_Ret) == typeid(_STLP_PRIV __false_type) ) {
124  cerr << "false type" << endl;
125  } else if ( typeid(/* _STLP_PRIV */ _SwapImplemented<vector<Obj> >::_Ret) == typeid(_STLP_PRIV __true_type) ) {
126  cerr << "true type" << endl;
127  } else {
128  cerr << "unknown type" << endl;
129  }
130 #endif /* end of temporary */
131 #if !defined (STLPORT) || \
132  defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) || defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
133  vector<Obj> v1;
134  vector<Obj> v2;
135 
136  v1.push_back( Obj() );
137  v1.push_back( Obj() );
138 
139  v1[0].v = -1;
140  v1[1].v = -2;
141 
142  v2.push_back( Obj() );
143  v2.push_back( Obj() );
144  v2.push_back( Obj() );
145 
146  v2[0].v = 10;
147  v2[1].v = 11;
148  v2[2].v = 12;
149 
150  CPPUNIT_CHECK( v1.size() == 2 );
151  CPPUNIT_CHECK( v2.size() == 3 );
152 
153  swap( v1, v2 ); // this should has effect v1.swap( v2 )
154 
155  CPPUNIT_CHECK( v1.size() == 3 );
156  CPPUNIT_CHECK( v2.size() == 2 );
157 
158  CPPUNIT_CHECK( v1[0].v == 10 );
159  CPPUNIT_CHECK( v1[1].v == 11 );
160  CPPUNIT_CHECK( v1[2].v == 12 );
161 
162  CPPUNIT_CHECK( v2[0].v == -1 );
163  CPPUNIT_CHECK( v2[1].v == -2 );
164 #endif
165 }
#define swap(a, b)
Definition: qsort.c:63
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
#define _STLP_PRIV
Definition: _dm.h:70
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
const GLdouble * v
Definition: gl.h:2040
GLfloat GLfloat v1
Definition: glext.h:6062

◆ swprnge1()

void SwapTest::swprnge1 ( )
protected

Definition at line 55 of file swap_test.cpp.

56 {
57  char word1[] = "World";
58  char word2[] = "Hello";
59  swap_ranges((char*)word1, (char*)word1 + ::strlen(word1), (char*)word2);
60  CPPUNIT_ASSERT(!strcmp(word1, "Hello"));
61  CPPUNIT_ASSERT(!strcmp(word2, "World"));
62 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_STLP_INLINE_LOOP _ForwardIter2 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2)
Definition: _algo.h:160
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

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