ReactOS 0.4.16-dev-122-g325d74c
PartialTest Class Reference
Inheritance diagram for PartialTest:
Collaboration diagram for PartialTest:

Protected Member Functions

void parsrt0 ()
 
void parsrt1 ()
 
void parsrt2 ()
 
void parsrtc0 ()
 
void parsrtc1 ()
 
void parsrtc2 ()
 
void partsum0 ()
 
void partsum1 ()
 
void partsum2 ()
 
void bad_predicate_detected ()
 

Static Protected Member Functions

static bool str_compare (const char *a_, const char *b_)
 

Private Member Functions

 CPPUNIT_TEST_SUITE (PartialTest)
 
 CPPUNIT_TEST (parsrt0)
 
 CPPUNIT_TEST (parsrt1)
 
 CPPUNIT_TEST (parsrt2)
 
 CPPUNIT_TEST (parsrtc0)
 
 CPPUNIT_TEST (parsrtc1)
 
 CPPUNIT_TEST (parsrtc2)
 
 CPPUNIT_TEST (partsum0)
 
 CPPUNIT_TEST (partsum1)
 
 CPPUNIT_TEST (partsum2)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 21 of file partial_test.cpp.

Member Function Documentation

◆ bad_predicate_detected()

void PartialTest::bad_predicate_detected ( )
protected

◆ CPPUNIT_TEST() [1/9]

PartialTest::CPPUNIT_TEST ( parsrt0  )
private

◆ CPPUNIT_TEST() [2/9]

PartialTest::CPPUNIT_TEST ( parsrt1  )
private

◆ CPPUNIT_TEST() [3/9]

PartialTest::CPPUNIT_TEST ( parsrt2  )
private

◆ CPPUNIT_TEST() [4/9]

PartialTest::CPPUNIT_TEST ( parsrtc0  )
private

◆ CPPUNIT_TEST() [5/9]

PartialTest::CPPUNIT_TEST ( parsrtc1  )
private

◆ CPPUNIT_TEST() [6/9]

PartialTest::CPPUNIT_TEST ( parsrtc2  )
private

◆ CPPUNIT_TEST() [7/9]

PartialTest::CPPUNIT_TEST ( partsum0  )
private

◆ CPPUNIT_TEST() [8/9]

PartialTest::CPPUNIT_TEST ( partsum1  )
private

◆ CPPUNIT_TEST() [9/9]

PartialTest::CPPUNIT_TEST ( partsum2  )
private

◆ CPPUNIT_TEST_SUITE()

PartialTest::CPPUNIT_TEST_SUITE ( PartialTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

PartialTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ parsrt0()

void PartialTest::parsrt0 ( )
protected

Definition at line 61 of file partial_test.cpp.

62{
63 int numbers[6] = { 5, 2, 4, 3, 1, 6 };
64
65 partial_sort((int*)numbers, (int*)numbers + 3, (int*)numbers + 6);
66
67 // 1 2 3 5 4 6
68 CPPUNIT_ASSERT(numbers[0]==1);
69 CPPUNIT_ASSERT(numbers[1]==2);
70 CPPUNIT_ASSERT(numbers[2]==3);
71 CPPUNIT_ASSERT(numbers[3]==5);
72 CPPUNIT_ASSERT(numbers[4]==4);
73 CPPUNIT_ASSERT(numbers[5]==6);
74}
_STLP_MOVE_TO_STD_NAMESPACE void partial_sort(_RandomAccessIter __first, _RandomAccessIter __middle, _RandomAccessIter __last)
Definition: _algo.c:1236
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ parsrt1()

void PartialTest::parsrt1 ( )
protected

Definition at line 76 of file partial_test.cpp.

77{
78 // 8 8 5 3 7 6 5 3 2 4
79 // 2 3 3 4 5 8 8 7 6 5
80 int numbers[10] ={ 8, 8, 5, 3, 7, 6, 5, 3, 2, 4 };
81
82 vector <int> v1(numbers, numbers+10);
83 partial_sort(v1.begin(), v1.begin() + v1.size() / 2, v1.end());
84
85 CPPUNIT_ASSERT(v1[0]==2);
86 CPPUNIT_ASSERT(v1[1]==3);
87 CPPUNIT_ASSERT(v1[2]==3);
88 CPPUNIT_ASSERT(v1[3]==4);
89 CPPUNIT_ASSERT(v1[4]==5);
90 CPPUNIT_ASSERT(v1[5]==8);
91 CPPUNIT_ASSERT(v1[6]==8);
92 CPPUNIT_ASSERT(v1[7]==7);
93 CPPUNIT_ASSERT(v1[8]==6);
94 CPPUNIT_ASSERT(v1[9]==5);
95}
GLfloat GLfloat v1
Definition: glext.h:6062

◆ parsrt2()

void PartialTest::parsrt2 ( )
protected

Definition at line 97 of file partial_test.cpp.

98{
99 char const* names[] = { "aa", "ff", "dd", "ee", "cc", "bb" };
100
101 const unsigned nameSize = sizeof(names) / sizeof(names[0]);
102 vector <char const*> v1(nameSize);
103 for(size_t i = 0; i < v1.size(); i++)
104 v1[i] = names[i];
105
106 partial_sort(v1.begin(), v1.begin() + nameSize / 2, v1.end(), str_compare);
107
108 // aa bb cc ff ee dd
109 CPPUNIT_ASSERT( strcmp(v1[0], "aa") == 0 );
110 CPPUNIT_ASSERT( v1[0] == names[0] );
111 CPPUNIT_ASSERT( strcmp(v1[1], "bb") == 0 );
112 CPPUNIT_ASSERT( v1[1] == names[5] );
113 CPPUNIT_ASSERT( strcmp(v1[2], "cc") == 0 );
114 CPPUNIT_ASSERT( v1[2] == names[4] );
115 CPPUNIT_ASSERT( strcmp(v1[3], "ff") == 0 );
116 CPPUNIT_ASSERT( v1[3] == names[1] );
117 CPPUNIT_ASSERT( strcmp(v1[4], "ee") == 0 );
118 CPPUNIT_ASSERT( v1[4] == names[3] );
119 CPPUNIT_ASSERT( strcmp(v1[5], "dd") == 0 );
120 CPPUNIT_ASSERT( v1[5] == names[2] );
121}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static bool str_compare(const char *a_, const char *b_)
GLuint GLuint * names
Definition: glext.h:11545
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

◆ parsrtc0()

void PartialTest::parsrtc0 ( )
protected

Definition at line 123 of file partial_test.cpp.

124{
125 int numbers[6] = { 5, 2, 4, 3, 1, 6 };
126
127 int result[3];
128 partial_sort_copy((int*)numbers, (int*)numbers + 6, (int*)result, (int*)result + 3);
129 //1 2 3
130 CPPUNIT_ASSERT(result[0]==1);
131 CPPUNIT_ASSERT(result[1]==2);
132 CPPUNIT_ASSERT(result[2]==3);
133}
_STLP_MOVE_TO_STD_NAMESPACE _RandomAccessIter partial_sort_copy(_InputIter __first, _InputIter __last, _RandomAccessIter __result_first, _RandomAccessIter __result_last)
Definition: _algo.c:1287
GLuint64EXT * result
Definition: glext.h:11304

◆ parsrtc1()

void PartialTest::parsrtc1 ( )
protected

Definition at line 135 of file partial_test.cpp.

136{
137 int numbers[10] ={ 3, 0, 4, 3, 2, 8, 2, 7, 7, 5 };
138
139 //3 0 4 3 2 8 2 7 7 5
140 //0 2 2 3 3
141
142 vector <int> v1(numbers, numbers+10);
143 vector <int> result(5);
144
145 partial_sort_copy(v1.begin(), v1.end(), result.begin(), result.end());
146 CPPUNIT_ASSERT(result[0]==0);
147 CPPUNIT_ASSERT(result[1]==2);
148 CPPUNIT_ASSERT(result[2]==2);
149 CPPUNIT_ASSERT(result[3]==3);
150 CPPUNIT_ASSERT(result[4]==3);
151}

◆ parsrtc2()

void PartialTest::parsrtc2 ( )
protected

Definition at line 153 of file partial_test.cpp.

154{
155 char const* names[] = { "aa", "ff", "dd", "ee", "cc", "bb" };
156
157 const unsigned nameSize = sizeof(names) / sizeof(names[0]);
158 vector <char const*> v1(nameSize);
159 for(size_t i = 0; i < v1.size(); i++)
160 v1[i] = names[i];
161 vector <char const*> result(3);
162 partial_sort_copy(v1.begin(), v1.end(), result.begin(), result.end(), str_compare);
163
164 // aa bb cc
165 CPPUNIT_ASSERT( strcmp( result[0], "aa" ) == 0 );
166 CPPUNIT_ASSERT( result[0] == names[0] );
167 CPPUNIT_ASSERT( strcmp( result[1], "bb" ) == 0 );
168 CPPUNIT_ASSERT( result[1] == names[5] );
169 CPPUNIT_ASSERT( strcmp( result[2], "cc" ) == 0 );
170 CPPUNIT_ASSERT( result[2] == names[4] );
171}

◆ partsum0()

void PartialTest::partsum0 ( )
protected

Definition at line 200 of file partial_test.cpp.

201{
202 int numbers[6] = { 1, 2, 3, 4, 5, 6 };
203
204 int result[6];
205 partial_sum((int*)numbers, (int*)numbers + 6, (int*)result);
206
207 // 1 3 6 10 15 21
208 CPPUNIT_ASSERT(result[0]==1);
209 CPPUNIT_ASSERT(result[1]==3);
210 CPPUNIT_ASSERT(result[2]==6);
211 CPPUNIT_ASSERT(result[3]==10);
212 CPPUNIT_ASSERT(result[4]==15);
213 CPPUNIT_ASSERT(result[5]==21);
214}
_STLP_MOVE_TO_STD_NAMESPACE _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
Definition: _numeric.h:94

◆ partsum1()

void PartialTest::partsum1 ( )
protected

Definition at line 216 of file partial_test.cpp.

217{
218 vector <int> v1(10);
219 __iota(v1.begin(), v1.end(), 0);
220 vector <int> v2(v1.size());
221 partial_sum(v1.begin(), v1.end(), v2.begin());
222
223 // 0 1 3 6 10 15 21 28 36 45
224 CPPUNIT_ASSERT(v2[0]==0);
225 CPPUNIT_ASSERT(v2[1]==1);
226 CPPUNIT_ASSERT(v2[2]==3);
227 CPPUNIT_ASSERT(v2[3]==6);
228 CPPUNIT_ASSERT(v2[4]==10);
229 CPPUNIT_ASSERT(v2[5]==15);
230 CPPUNIT_ASSERT(v2[6]==21);
231 CPPUNIT_ASSERT(v2[7]==28);
232 CPPUNIT_ASSERT(v2[8]==36);
233 CPPUNIT_ASSERT(v2[9]==45);
234}
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
void __iota(_It __first, _It __last, _Tp __val)
Definition: iota.h:8

◆ partsum2()

void PartialTest::partsum2 ( )
protected

Definition at line 236 of file partial_test.cpp.

237{
238 vector <int> v1(5);
239 __iota(v1.begin(), v1.end(), 1);
240 vector <int> v2(v1.size());
241 partial_sum(v1.begin(), v1.end(), v2.begin(), multiplies<int>());
242 // 1 2 6 24 120
243 CPPUNIT_ASSERT(v2[0]==1);
244 CPPUNIT_ASSERT(v2[1]==2);
245 CPPUNIT_ASSERT(v2[2]==6);
246 CPPUNIT_ASSERT(v2[3]==24);
247 CPPUNIT_ASSERT(v2[4]==120);
248}

◆ str_compare()

static bool PartialTest::str_compare ( const char a_,
const char b_ 
)
inlinestaticprotected

Definition at line 50 of file partial_test.cpp.

51 {
52 return strcmp(a_, b_) < 0 ? 1 : 0;
53 }

Referenced by parsrt2(), and parsrtc2().


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