Skip to content

Commit

Permalink
fmt:format for command string building
Browse files Browse the repository at this point in the history
  • Loading branch information
AVMatthews committed Nov 22, 2024
1 parent 1a16528 commit 01ca9ca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions components/core/tests/test-end_to_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>

#include <Catch2/single_include/catch2/catch.hpp>
#include <fmt/format.h>

#include "../src/clp_s/JsonConstructor.hpp"
#include "../src/clp_s/JsonParser.hpp"
Expand Down Expand Up @@ -104,17 +105,23 @@ TEST_CASE("clp-s_compression_and_extraction_no_floats", "[clp-s][end-to-end]") {

int result = std::system("command -v jq >/dev/null 2>&1");
REQUIRE(0 == result);
std::string command = "jq -S -c '.' " + std::string(cTestEndToEndOutputDirectory)
+ "/original | sort > " + std::string(cTestEndToEndOutputSortedJson);
std::string command = fmt::format(
"jq --sort-keys --compact-output '.' {}/original | sort > {}",
cTestEndToEndOutputDirectory,
cTestEndToEndOutputSortedJson
);
result = std::system(command.c_str());
REQUIRE(0 == result);

REQUIRE(false == std::filesystem::is_empty(cTestEndToEndOutputSortedJson));

result = std::system("command -v diff >/dev/null 2>&1");
REQUIRE(0 == result);
command = "diff -u " + std::string(cTestEndToEndOutputSortedJson) + " "
+ get_test_input_local_path() + " > /dev/null";
command = fmt::format(
"diff -u {} {} > /dev/null",
cTestEndToEndOutputSortedJson,
get_test_input_local_path()
);
result = std::system(command.c_str());
REQUIRE(0 == WEXITSTATUS(result));
}

0 comments on commit 01ca9ca

Please sign in to comment.