Skip to content

Commit

Permalink
Add missing mutable fake args.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryouze committed Sep 25, 2024
1 parent e15aad9 commit ef30b38
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<char **>(fake_argv)));
// Create mutable copies of the strings
char test_executable_name[] = TEST_EXECUTABLE_NAME;
std::vector<char> 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;
Expand Down

0 comments on commit ef30b38

Please sign in to comment.