#include <gtest/gtest.h>
#include <partition.hxx>
#include <functional>
#include <vector>
#include <string>
Go to the source code of this file.
|
| TEST (TestPartition, Partitions) |
|
| TEST (TestPartition, PartitionString) |
|
| TEST (TestPartition, PartitionBoudaryPivots) |
|
| TEST (TestPartition, PartitionGreaterComparator) |
|
TEST |
( |
TestPartition |
, |
|
|
Partitions |
|
|
) |
| |
Definition at line 71 of file TestPartition.cxx.
75 Container vector(ArrayRand);
76 auto pivot = vector.begin() + 5;
77 auto pivotVal = *pivot;
80 auto newPivot = Partition<IT>(vector.begin(), pivot, vector.end());
81 CheckPartition<IT>(vector.begin(), vector.end(), newPivot, pivotVal);
86 Container vector(ArraySort);
87 auto pivot = vector.begin() + 5;
89 Partition<IT>(vector.begin(), pivot, vector.end());
92 for (
auto it = vector.begin(); it < vector.end(); ++it, ++i)
93 EXPECT_EQ(ArraySort[i], *it);
98 Container vector(ArrayRand);
99 auto pivot = vector.begin() + 5;
101 Partition<IT>(vector.end(), pivot, vector.begin());
104 for (
auto it = vector.begin(); it < vector.end(); ++it, ++i)
105 EXPECT_EQ(ArrayRand[i], *it);
TEST |
( |
TestPartition |
, |
|
|
PartitionString |
|
|
) |
| |
Definition at line 110 of file TestPartition.cxx.
112 std::string str = StrRand;
113 auto pivot = str.begin() + 5;
114 auto pivotVal = *pivot;
116 auto newPivot = Partition<std::string::iterator>(str.begin(), pivot, str.end());
117 CheckPartition<std::string::iterator>(str.begin(), str.end(), newPivot, pivotVal);
TEST |
( |
TestPartition |
, |
|
|
PartitionBoudaryPivots |
|
|
) |
| |
Definition at line 121 of file TestPartition.cxx.
125 Container vector(ArrayRand);
126 auto pivot = vector.begin();
127 const int pivotVal = *pivot;
130 auto newPivot = Partition<IT>(vector.begin(), pivot, vector.end());
131 CheckPartition<IT>(vector.begin(), vector.end(), newPivot, pivotVal);
137 Container vector(ArrayRand);
138 auto pivot = vector.end() - 1;
139 const int pivotVal = *pivot;
142 auto newPivot = Partition<IT>(vector.begin(), pivot, vector.end());
143 CheckPartition<IT>(vector.begin(), vector.end(), newPivot, pivotVal);
148 Container vector(ArrayRand);
149 auto pivot = vector.end();
152 Partition<IT>(vector.begin(), pivot, vector.end());
155 for (
auto it = vector.begin(); it < vector.end(); ++it, ++i)
156 EXPECT_EQ(ArrayRand[i], *it);
TEST |
( |
TestPartition |
, |
|
|
PartitionGreaterComparator |
|
|
) |
| |
Definition at line 161 of file TestPartition.cxx.
165 Container vector(ArrayRand);
166 auto pivot = vector.begin() + 5;
167 const auto pivotVal = *pivot;
170 auto newPivot = Partition<IT, GE_Compare>(vector.begin(), pivot, vector.end());
171 CheckPartition<IT>(vector.begin(), vector.end(), newPivot, pivotVal,
false);
176 Container invSortedArray(ArrayInvSort);
177 auto pivot = invSortedArray.begin() + 5;
179 Partition<IT, GE_Compare>(invSortedArray.begin(), pivot, invSortedArray.end());
182 for (
auto it = invSortedArray.begin(); it < invSortedArray.end(); ++it, ++i)
183 EXPECT_EQ(invSortedArray[i], *it);
188 std::string str = StrRand;
189 auto pivot = str.begin() + 5;
190 const auto pivotVal = *pivot;
194 Partition<std::string::iterator, std::greater_equal<char>>(str.begin(), pivot, str.end());
195 CheckPartition<std::string::iterator>(str.begin(), str.end(), newPivot, pivotVal,
false);