Skip to content

Commit

Permalink
Rename fuzz test and remove hardcoded path from example program
Browse files Browse the repository at this point in the history
  • Loading branch information
ewarchul committed Jun 29, 2024
1 parent 24aed89 commit 61cf74a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 3 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
find_package(fmt REQUIRED)

add_compile_definitions(DATA_STORAGE_PATH="${CMAKE_SOURCE_DIR}/data")

add_executable(main main.cpp)
target_link_libraries(main PRIVATE cecxx fmt::fmt)
set_target_properties(main PROPERTIES CXX_STANDARD 20)
target_compile_options(main PRIVATE -Wall -Wextra -Wpedantic -O3)
target_compile_options(main PRIVATE -Wall -Wextra -Wpedantic -Werror -O3)

7 changes: 3 additions & 4 deletions example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "cecxx/benchmark/evaluator.hpp"

constexpr auto CEC_STORAGE{"/home/ewarchul/open-source/optim/cecxx/data"};

namespace rv = ranges::views;
using namespace cecxx;

Expand All @@ -20,8 +18,9 @@ auto main() -> int {
const auto dimensions = std::vector{10ul, 30ul, 50ul, 100ul};

// Create an evaluator object for the CEC2017 benchmark
auto cec2017_eval = benchmark::evaluator(
cecxx::benchmark::cec_edition_t::cec2017, dimensions, CEC_STORAGE);
auto cec2017_eval =
benchmark::evaluator(cecxx::benchmark::cec_edition_t::cec2017,
dimensions, DATA_STORAGE_PATH);

// create problem grid [problem_number X dimension]
const auto problem_grid =
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fuzztest_setup_fuzzing_flags()

add_compile_definitions(DATA_STORAGE_PATH="${CMAKE_SOURCE_DIR}/data")

add_executable(cecxx-fuzz gtest/cec2017_oracle_test.cpp oracle/cec2017.cpp)
add_executable(cecxx-fuzz gtest/cec2017_oracle_compliance_test.cpp oracle/cec2017.cpp)
target_include_directories(cecxx-fuzz PUBLIC .)
target_link_libraries(cecxx-fuzz PRIVATE cecxx)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ constexpr auto MAX_ABS_ERROR = 1e-8;
constexpr auto CEC_2017_LOWER_BOUND = -100.0;
constexpr auto CEC_2017_UPPER_BOUND = 100.0;

class Cec2017ConformanceTest
class Cec2017ComplianceTest
: public PerFuzzTestFixtureAdapter<
CecTestFixture<cec_edition_t::cec2017, 10, 30, 50, 100>> {
public:
Expand Down Expand Up @@ -51,25 +51,25 @@ class Cec2017ConformanceTest
}
};

FUZZ_TEST_F(Cec2017ConformanceTest, Cec2017D10ImplsAreEquiv)
FUZZ_TEST_F(Cec2017ComplianceTest, Cec2017D10ImplsAreEquiv)
.WithDomains(PositiveVectorOf<double>(InRange(CEC_2017_LOWER_BOUND,
CEC_2017_UPPER_BOUND))
.WithSize(10),
InCecProblemRange(cec_edition_t::cec2017));

FUZZ_TEST_F(Cec2017ConformanceTest, Cec2017D30ImplsAreEquiv)
FUZZ_TEST_F(Cec2017ComplianceTest, Cec2017D30ImplsAreEquiv)
.WithDomains(PositiveVectorOf<double>(InRange(CEC_2017_LOWER_BOUND,
CEC_2017_UPPER_BOUND))
.WithSize(30),
InCecProblemRange(cec_edition_t::cec2017));

FUZZ_TEST_F(Cec2017ConformanceTest, Cec2017D50ImplsAreEquiv)
FUZZ_TEST_F(Cec2017ComplianceTest, Cec2017D50ImplsAreEquiv)
.WithDomains(PositiveVectorOf<double>(InRange(CEC_2017_LOWER_BOUND,
CEC_2017_UPPER_BOUND))
.WithSize(50),
InCecProblemRange(cec_edition_t::cec2017));

FUZZ_TEST_F(Cec2017ConformanceTest, Cec2017D100ImplsAreEquiv)
FUZZ_TEST_F(Cec2017ComplianceTest, Cec2017D100ImplsAreEquiv)
.WithDomains(PositiveVectorOf<double>(InRange(CEC_2017_LOWER_BOUND,
CEC_2017_UPPER_BOUND))
.WithSize(100),
Expand Down

0 comments on commit 61cf74a

Please sign in to comment.