@@ -88,3 +88,32 @@ TEST_CASE("log-callback", "[highs_io]") {
8888 REQUIRE (strlen (alt_printed_log) <= sizeof (alt_printed_log));
8989 }
9090}
91+
92+ HighsCallbackFunctionType userLoggingCallback =
93+ [](int callback_type, const std::string& message,
94+ const HighsCallbackOutput* data_out, HighsCallbackInput* data_in,
95+ void * user_callback_data) {
96+ fprintf (static_cast <FILE*>(user_callback_data), " %s" , message.c_str ());
97+ };
98+
99+ TEST_CASE (" log-independence" , " [highs_io]" ) {
100+ const std::string test_name = Catch::getResultCapture ().getCurrentTestName ();
101+ const std::string test_highs_log = test_name + " .log" ;
102+ const std::string test_user_log = test_name + " .ulog" ;
103+ std::string filename = std::string (HIGHS_DIR) + " /check/instances/avgas.mps" ;
104+ Highs h;
105+ // h.setOptionValue("output_flag", dev_run);
106+ h.setOptionValue (" log_file" , test_highs_log);
107+ FILE* file = fopen (test_user_log.c_str (), " w" );
108+ // void* p_user_callback_data = file;
109+
110+ h.setCallback (userLoggingCallback, file); // p_user_callback_data);
111+ h.startCallback (kCallbackLogging );
112+
113+ h.readModel (filename);
114+ h.run ();
115+
116+ std::remove (test_highs_log.c_str ());
117+ std::remove (test_user_log.c_str ());
118+ h.resetGlobalScheduler (true );
119+ }
0 commit comments