From ef30b382829ada609527f291dbd05a9abf297abe Mon Sep 17 00:00:00 2001 From: ryouze <98982999+ryouze@users.noreply.github.com> Date: Wed, 25 Sep 2024 21:04:21 +0200 Subject: [PATCH] Add missing mutable fake args. --- tests/test_all.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/test_all.cpp b/tests/test_all.cpp index f83e186..66baecd 100644 --- a/tests/test_all.cpp +++ b/tests/test_all.cpp @@ -216,9 +216,9 @@ int test_args::paths() // Iterate, because the order is not guaranteed for (const auto &path : args.filepaths) { - if (path != temp_file1.string() && path != temp_file2.string()) { + if (!std::filesystem::equivalent(path, temp_file1) && !std::filesystem::equivalent(path, temp_file2)) { fmt::print(stderr, - "Filepaths test failed: expected '{}' or '{}', got {}\n", + "Filepaths test failed: expected '{}' or '{}', got '{}'\n", temp_file1.string(), temp_file2.string(), path.string()); @@ -512,12 +512,16 @@ int test_app::paths() f << examples::unlisted; } - // // Store the string representation of the file path + // Store the string representation of the file path const std::string temp_file_str = temp_file.string(); - const char *fake_argv[] = {TEST_EXECUTABLE_NAME, temp_file_str.c_str()}; - // Pass parsed command-line arguments to the application - app::run(core::args::Args(2, const_cast(fake_argv))); + // Create mutable copies of the strings + char test_executable_name[] = TEST_EXECUTABLE_NAME; + std::vector temp_file_cstr(temp_file_str.cbegin(), temp_file_str.cend()); + temp_file_cstr.emplace_back('\0'); // Ensure null-termination + + char *fake_argv[] = {test_executable_name, temp_file_cstr.data()}; + app::run(core::args::Args(2, fake_argv)); fmt::print("test_app::paths() passed.\n"); return EXIT_SUCCESS;