diff --git a/check/TestBasisSolves.cpp b/check/TestBasisSolves.cpp index 8d550f56bd..af0a051ca5 100644 --- a/check/TestBasisSolves.cpp +++ b/check/TestBasisSolves.cpp @@ -5,36 +5,6 @@ #include -#if defined(__linux__) or defined(__APPLE__) -#include -#elif defined(_WIN32) -#define NOGDI -#define NOMINMAX -#include -#else - -#endif - -std::string GetBasisSolvesCurrentWorkingDir(void) { - char buff[FILENAME_MAX]; - - #if defined(__linux__) or defined(__APPLE__) - auto result = getcwd(buff, FILENAME_MAX); - if (result) { - std::string current_working_dir(buff); - return current_working_dir; - } - #elif defined(_WIN32) - GetModuleFileName( NULL, buff, FILENAME_MAX ); - string::size_type pos = string( buff ).find_last_of( "\\/" ); - return string( buff ).substr( 0, pos); - #else - - #endif - - return ""; -} - bool GetBasisSolvesSolutionNzOk(int numRow, double* pass_solution_vector, int* solution_num_nz, int* solution_indices) { double* solution_vector = (double*)malloc(sizeof(double) * numRow); if (solution_num_nz == NULL) return true; @@ -147,22 +117,21 @@ void GetBasisSolvesFormRHS(HighsLp& lp, int* basic_variables, double* solution, // No commas in test case name. TEST_CASE("Basis-solves", "[highs_basis_solves]") { - - std::string dir = GetBasisSolvesCurrentWorkingDir(); - - std::cout << dir << std::endl; + std::cout << std::string(HIGHS_DIR) << std::endl; // For debugging use the latter. std::string filename; - filename = dir + "/../../check/instances/chip.mps"; - // filename = dir + "/../../check/instances/blending.mps"; - filename = dir + "/../../check/instances/avgas.mps"; - filename = dir + "/../../check/instances/adlittle.mps"; - // filename = dir + "/../../check/instances/25fv47.mps"; + filename = std::string(HIGHS_DIR) + "/check/instances/chip.mps"; + // filename = std::string(HIGHS_DIR) + "/../../check/instances/blending.mps"; + filename = std::string(HIGHS_DIR) + "/check/instances/avgas.mps"; + filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps"; + + // printf("CMAKE %s\n", HIGHS_DIR); + // filename = std::string(HIGHS_DIR) + "/check/instances/25fv47.mps"; //For debugging - // filename = dir + "/check/instances/adlittle.mps"; + // filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps"; Highs highs; diff --git a/check/TestFilereader.cpp b/check/TestFilereader.cpp index d2d861ffbe..cc9642db0e 100644 --- a/check/TestFilereader.cpp +++ b/check/TestFilereader.cpp @@ -9,43 +9,12 @@ #include "LoadProblem.h" #include "catch.hpp" -#if defined(__linux__) or defined(__APPLE__) -#include -#elif defined(_WIN32) -#define NOGDI -#include -#else - -#endif - -std::string GetCurrentWorkingDir(void) { - char buff[FILENAME_MAX]; - - #if defined(__linux__) or defined(__APPLE__) - auto result = getcwd(buff, FILENAME_MAX); - if (result) { - std::string current_working_dir(buff); - return current_working_dir; - } - #elif defined(_WIN32) - GetModuleFileName( NULL, buff, FILENAME_MAX ); - string::size_type pos = string( buff ).find_last_of( "\\/" ); - return string( buff ).substr( 0, pos); - #else - - #endif - - return ""; -} - TEST_CASE("free-format-parser", "[highs_filereader]") { - std::string dir = GetCurrentWorkingDir(); - - std::cout << dir << std::endl; + std::cout << std::string(HIGHS_DIR) << std::endl; // For debugging use the latter. std::string filename; - filename = dir + "/../../check/instances/adlittle.mps"; + filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps"; // filename = dir + "/check/instances/adlittle.mps"; // Read mps. @@ -82,12 +51,11 @@ TEST_CASE("free-format-parser", "[highs_filereader]") { // No commas in test case name. TEST_CASE("read-mps-ems", "[highs_filereader]") { HighsOptions options; - std::string dir = GetCurrentWorkingDir(); - std::cout << dir << std::endl; + std::cout << std::string(HIGHS_DIR) << std::endl; // For debugging use the latter. - options.model_file = dir + "/../../check/instances/adlittle.mps"; + options.model_file = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps"; // options.model_file = dir + "/check/instances/adlittle.mps"; // Read mps. @@ -113,10 +81,8 @@ TEST_CASE("read-mps-ems", "[highs_filereader]") { } TEST_CASE("integrality-constraints", "[highs_filereader]") { - std::string dir = GetCurrentWorkingDir(); - // For debugging use the latter. - std::string filename = dir + "/../../check/instances/small_mip.mps"; + std::string filename = std::string(HIGHS_DIR) + "/check/instances/small_mip.mps"; // std::string filename = dir + "/check/instances/small_mip.mps"; HighsOptions options; @@ -144,11 +110,8 @@ TEST_CASE("integrality-constraints", "[highs_filereader]") { } TEST_CASE("dualize", "[highs_data]") { - - std::string dir = GetCurrentWorkingDir(); - // For debugging use the latter. - std::string filename = dir + "/../../check/instances/adlittle.mps"; + std::string filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps"; //std::string filename = dir + "/check/instances/adlittle.mps"; //std::string filename = "/home/s1131817/test-problems/qaps/qap04"; diff --git a/check/TestOptions.cpp b/check/TestOptions.cpp index 1f5f8e3011..7de0909088 100644 --- a/check/TestOptions.cpp +++ b/check/TestOptions.cpp @@ -9,44 +9,13 @@ #include "LoadOptions.h" #include "catch.hpp" -#if defined(__linux__) or defined(__APPLE__) -#include -#elif defined(_WIN32) -#define NOGDI -#include -#else - -#endif - -std::string GetCurrentWorkingDirOptions(void) { - char buff[FILENAME_MAX]; - - #if defined(__linux__) or defined(__APPLE__) - auto result = getcwd(buff, FILENAME_MAX); - if (result) { - std::string current_working_dir(buff); - return current_working_dir; - } - #elif defined(_WIN32) - GetModuleFileName( NULL, buff, FILENAME_MAX ); - string::size_type pos = string( buff ).find_last_of( "\\/" ); - return string( buff ).substr( 0, pos); - #else - - #endif - - return ""; -} - TEST_CASE("options", "[highs_options]") { - std::string dir = GetCurrentWorkingDirOptions(); - HighsOptions options; OptionStatus return_status = checkOptions(options.records); REQUIRE(return_status == OptionStatus::OK); // For debugging use the latter. - options.options_file= dir + "/../../check/sample_options_file"; + options.options_file= std::string(HIGHS_DIR) + "/check/sample_options_file"; // options.options_file = dir + "/check/sample_options_file"; bool success = loadOptionsFromFile(options); diff --git a/src/HConfig.h.in b/src/HConfig.h.in index bde1ab9d21..1d27dfeb07 100644 --- a/src/HConfig.h.in +++ b/src/HConfig.h.in @@ -13,5 +13,6 @@ #define HIGHS_VERSION_MAJOR @HIGHS_VERSION_MAJOR@ #define HIGHS_VERSION_MINOR @HIGHS_VERSION_MINOR@ #define HIGHS_VERSION_PATCH @HIGHS_VERSION_PATCH@ +#define HIGHS_DIR "@CMAKE_SOURCE_DIR@" #endif /* HCONFIG_H_ */