#include <cstdio>
#include "HCheckConfig.h"
#include "Highs.h"
#include "catch.hpp"
const bool dev_run = false;
TEST_CASE("logging", "[highs_logging]") {
const std::string test_name = Catch::getResultCapture().getCurrentTestName();
const std::string log_file = test_name + ".log";
std::string model;
std::string model_file;
HighsStatus return_status;
model = "avgas";
model_file = std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
Highs highs;
if (!dev_run) highs.setOptionValue("output_flag", false);
return_status = highs.readModel(model_file);
REQUIRE(return_status == HighsStatus::kOk);
highs.setOptionValue(kLogFileString, log_file);
return_status = highs.run();
REQUIRE(return_status == HighsStatus::kOk);
highs.setOptionValue(kLogFileString, "");
highs.setOptionValue("log_to_console", false);
highs.run();
highs.setOptionValue("log_to_console", true);
if (dev_run) printf("After setting log_to_console = true\n");
highs.run();
if (!dev_run) std::remove(log_file.c_str());
highs.resetGlobalScheduler(true);
}
TEST_CASE("no-logging", "[highs_logging]") {
std::string model;
std::string model_file;
std::string log_file;
HighsStatus return_status;
model = "adlittle";
model_file = std::string(HIGHS_DIR) + "/check/instances/" + model + ".mps";
Highs highs;
if (!dev_run) highs.setOptionValue("output_flag", false);
return_status = highs.readModel(model_file);
REQUIRE(return_status == HighsStatus::kOk);
return_status = highs.run();
REQUIRE(return_status == HighsStatus::kOk);
highs.resetGlobalScheduler(true);
}