ReactOS 0.4.15-dev-7906-g1b85a5f
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 ( swap_container_non_spec  )
private

◆ CPPUNIT_TEST() [3/4]

SwapTest::CPPUNIT_TEST ( swap_container_spec  )
private

◆ CPPUNIT_TEST() [4/4]

SwapTest::CPPUNIT_TEST ( swprnge1  )
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 CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define swap(a, b)
Definition: qsort.c:63

◆ swap_container_non_spec()

void SwapTest::swap_container_non_spec ( )
protected

Definition at line 88 of file swap_test.cpp.

89{
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}
Definition: _queue.h:67
#define CPPUNIT_CHECK(X)
Definition: cppunit_mini.h:195
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063

◆ 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)
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 _STLP_PRIV
Definition: _dm.h:70
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
const GLdouble * v
Definition: gl.h:2040
#define cerr
Definition: iostream.cpp:39

◆ 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}
_STLP_INLINE_LOOP _ForwardIter2 swap_ranges(_ForwardIter1 __first1, _ForwardIter1 __last1, _ForwardIter2 __first2)
Definition: _algo.h:160
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269

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