138 std::vector<uint64_t> arr = {5, 3, 8, 12, 14, 16, 28, 96, 2, 5977};
139 std::vector<uint64_t> arr_sorted = sorting::quick_sort::quick_sort(
140 arr, 0,
int(std::end(arr) - std::begin(arr)) - 1);
142 assert(std::is_sorted(std::begin(arr_sorted), std::end(arr_sorted)));
143 std::cout <<
"\n1st test: passed!\n";
146 std::vector<int64_t> arr2 = {9, 15, 28, 96, 500, -4, -58,
147 -977, -238, -800, -21, -53, -55};
148 std::vector<int64_t> arr_sorted2 = sorting::quick_sort::quick_sort(
149 arr2, 0, std::end(arr2) - std::begin(arr2));
151 assert(std::is_sorted(std::begin(arr_sorted2), std::end(arr_sorted2)));
152 std::cout <<
"2nd test: passed!\n";
155 std::vector<double> arr3 = {29, 36, 1100, 0, 77, 1,
156 6.7, 8.97, 1.74, 950.10, -329.65};
157 std::vector<double> arr_sorted3 = sorting::quick_sort::quick_sort(
158 arr3, 0,
int(std::end(arr3) - std::begin(arr3)) - 1);
160 assert(std::is_sorted(std::begin(arr_sorted3), std::end(arr_sorted3)));
161 std::cout <<
"3rd test: passed!\n";
164 size_t size = std::rand() % 750 + 100;
166 std::vector<float> arr4(size);
167 for (uint64_t i = 0; i < size; i++) {
168 arr4[i] =
static_cast<float>(std::rand()) /
169 static_cast<float>(RAND_MAX / 999.99 - 0.99) -
173 std::vector<float> arr4_sorted = sorting::quick_sort::quick_sort(
174 arr4, 0,
int(std::end(arr4) - std::begin(arr4)) - 1);
175 assert(std::is_sorted(std::begin(arr4_sorted), std::end(arr4_sorted)));
177 std::cout <<
"4th test: passed!\n";
180 std::cout <<
"\n\tPrinting all sorted arrays:\t\n";
182 std::cout <<
"1st array:\n";
183 sorting::quick_sort::show(arr_sorted, std::end(arr) - std::begin(arr));
184 std::cout << std::endl;
185 std::cout <<
"2nd array:\n";
186 sorting::quick_sort::show(arr_sorted2, std::end(arr2) - std::begin(arr2));
187 std::cout << std::endl;
188 std::cout <<
"3rd array:\n";
189 sorting::quick_sort::show(arr_sorted3,
190 int(std::end(arr3) - std::begin(arr3)) - 1);
191 std::cout << std::endl;
192 std::cout <<
"Start: 4th array:\n\n";
193 sorting::quick_sort::show(
194 arr4_sorted,
int(std::end(arr4_sorted) - std::begin(arr4_sorted)) - 1);
195 std::cout <<
"\nEnd: 4th array.\n";