ReactOS 0.4.16-dev-91-g764881a
PartitionTest Class Reference
Inheritance diagram for PartitionTest:
Collaboration diagram for PartitionTest:

Classes

struct  less_n
 

Protected Member Functions

void ptition0 ()
 
void ptition1 ()
 
void stblptn0 ()
 
void stblptn1 ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (PartitionTest)
 
 CPPUNIT_TEST (ptition0)
 
 CPPUNIT_TEST (ptition1)
 
 CPPUNIT_TEST (stblptn0)
 
 CPPUNIT_TEST (stblptn1)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 16 of file partition_test.cpp.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

PartitionTest::CPPUNIT_TEST ( ptition0  )
private

◆ CPPUNIT_TEST() [2/4]

PartitionTest::CPPUNIT_TEST ( ptition1  )
private

◆ CPPUNIT_TEST() [3/4]

PartitionTest::CPPUNIT_TEST ( stblptn0  )
private

◆ CPPUNIT_TEST() [4/4]

PartitionTest::CPPUNIT_TEST ( stblptn1  )
private

◆ CPPUNIT_TEST_SUITE()

PartitionTest::CPPUNIT_TEST_SUITE ( PartitionTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

PartitionTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ ptition0()

void PartitionTest::ptition0 ( )
protected

Definition at line 93 of file partition_test.cpp.

94{
95 int numbers[6] = { 6, 12, 3, 10, 1, 20 };
96 size_t nb_pred_calls = 0;
97 // 6 1 3 10 12 20
98 partition((int*)numbers, (int*)numbers + 6, less_n(10, nb_pred_calls));
99 CPPUNIT_ASSERT(numbers[0]==6);
100 CPPUNIT_ASSERT(numbers[1]==1);
101 CPPUNIT_ASSERT(numbers[2]==3);
102 CPPUNIT_ASSERT(numbers[3]==10);
103 CPPUNIT_ASSERT(numbers[4]==12);
104 CPPUNIT_ASSERT(numbers[5]==20);
105
106 CPPUNIT_ASSERT( nb_pred_calls == sizeof(numbers) / sizeof(numbers[0]) );
107}
static INT partition(list_t &list, INT i, INT j, const CStringW &x)
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ ptition1()

void PartitionTest::ptition1 ( )
protected

Definition at line 108 of file partition_test.cpp.

109{
110 // 19 3 11 14 10 19 8 17 9 6
111 // 6 3 9 8 10 19 14 17 11 19
112
113 int numbers[10] ={ 19, 3, 11, 14, 10, 19, 8, 17, 9, 6 };
114
115 vector <int> v1(numbers, numbers+10);
116 size_t nb_pred_calls = 0;
117 partition(v1.begin(), v1.end(), less_n(11, nb_pred_calls));
118
119 CPPUNIT_ASSERT(v1[0]==6);
120 CPPUNIT_ASSERT(v1[1]==3);
121 CPPUNIT_ASSERT(v1[2]==9);
122 CPPUNIT_ASSERT(v1[3]==8);
123 CPPUNIT_ASSERT(v1[4]==10);
124 CPPUNIT_ASSERT(v1[5]==19);
125 CPPUNIT_ASSERT(v1[6]==14);
126 CPPUNIT_ASSERT(v1[7]==17);
127 CPPUNIT_ASSERT(v1[8]==11);
128 CPPUNIT_ASSERT(v1[9]==19);
129 CPPUNIT_ASSERT( nb_pred_calls == v1.size() );
130}
GLfloat GLfloat v1
Definition: glext.h:6062

◆ stblptn0()

void PartitionTest::stblptn0 ( )
protected

Definition at line 54 of file partition_test.cpp.

55{
56 int numbers[6] = { 10, 5, 11, 20, 6, -2 };
57
58 size_t nb_pred_calls = 0;
59 stable_partition((int*)numbers, (int*)numbers + 6, less_n(10, nb_pred_calls));
60 // 5 6 -2 10 11 20
61 CPPUNIT_ASSERT(numbers[0]==5);
62 CPPUNIT_ASSERT(numbers[1]==6);
63 CPPUNIT_ASSERT(numbers[2]==-2);
64 CPPUNIT_ASSERT(numbers[3]==10);
65 CPPUNIT_ASSERT(numbers[4]==11);
66 CPPUNIT_ASSERT(numbers[5]==20);
67
68 //Complexity check:
69 CPPUNIT_ASSERT( nb_pred_calls == sizeof(numbers) / sizeof(numbers[0]) );
70}
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter stable_partition(_ForwardIter __first, _ForwardIter __last, _Predicate __pred)
Definition: _algo.c:866

◆ stblptn1()

void PartitionTest::stblptn1 ( )
protected

Definition at line 71 of file partition_test.cpp.

72{
73 //5 5 2 10 0 12 5 0 0 19
74 //5 5 2 10 0 5 0 0 12 19
75 int numbers[] = { 5, 5, 2, 10, 0, 12, 5, 0, 0, 19 };
76 vector <int> v1(numbers, numbers+10);
77
78 size_t nb_pred_calls = 0;
79 stable_partition(v1.begin(), v1.end(), less_n(11, nb_pred_calls));
80
81 CPPUNIT_ASSERT(v1[0]==5);
82 CPPUNIT_ASSERT(v1[1]==5);
83 CPPUNIT_ASSERT(v1[2]==2);
84 CPPUNIT_ASSERT(v1[3]==10);
85 CPPUNIT_ASSERT(v1[4]==0);
86 CPPUNIT_ASSERT(v1[5]==5);
87 CPPUNIT_ASSERT(v1[6]==0);
88 CPPUNIT_ASSERT(v1[7]==0);
89 CPPUNIT_ASSERT(v1[8]==12);
90 CPPUNIT_ASSERT(v1[9]==19);
91 CPPUNIT_ASSERT( nb_pred_calls == v1.size() );
92}

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