7 #include <catch2/catch_test_macros.hpp>
12 return ((a) <= (b)) ? (((a) == (b)) ? 0 : -1) : 1;
15 TEST_CASE(
"Test nrn_mlh_gsort output",
"[nrn_gsort]") {
16 std::vector<double> input{1.2, -2.5, 5.1};
19 std::vector<int> indices(input.size());
21 std::iota(indices.begin(), indices.end(), 0);
24 auto sorted_input = input;
25 std::sort(sorted_input.begin(), sorted_input.end());
27 SECTION(
"Test sorting") {
29 for (
auto i = 0;
i < input.size(); ++
i) {
30 REQUIRE(sorted_input[
i] == input[indices[
i]]);
36 std::vector<int> indices{2, 1, 1};
37 std::vector<int> expected_result{1, 1, 2};
39 SECTION(
"Test sorting with repeated indices") {
41 for (
auto i = 0;
i < input.size(); ++
i) {
42 REQUIRE(indices[
i] == expected_result[
i]);
int nrn_mlh_gsort(double *vec, int *base_ptr, int total_elems, int(*cmp)(double, double))
TEST_CASE("Test nrn_mlh_gsort output", "[nrn_gsort]")
int cmpdfn(double a, double b)
HOC interpreter function declarations (included by hocdec.h)