Skip to content

Commit

Permalink
tests: Fix ignored attributes warning during build
Browse files Browse the repository at this point in the history
Signed-off-by: Gianfranco Costamagna <[email protected]>
  • Loading branch information
Pragyansh Chaturvedi authored and Gianfranco Costamagna committed Feb 27, 2025
1 parent 8215dba commit 7206a82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion tests/src/make_test_data_available.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ namespace utils

inline bool check_testsuite_downloaded()
{
const std::unique_ptr<std::FILE, decltype(&std::fclose)> file(std::fopen(TEST_DATA_DIRECTORY "/README.md", "r"), &std::fclose);
using FilePtr = std::unique_ptr<FILE, int(*)(FILE*)>;
const FilePtr file(std::fopen(TEST_DATA_DIRECTORY "/README.md", "r"), std::fclose);
return file != nullptr;
}

Expand Down
11 changes: 6 additions & 5 deletions tests/src/unit-testsuites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ TEST_CASE("test suite from json-test-suite")
TEST_CASE("json.org examples")
{
// here, we list all JSON values from https://json.org/example
using FilePtr = std::unique_ptr<FILE, int(*)(FILE*)>;

SECTION("1.json")
{
Expand Down Expand Up @@ -363,35 +364,35 @@ TEST_CASE("json.org examples")
}
SECTION("FILE 1.json")
{
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/1.json", "r"), &std::fclose);
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/1.json", "r"), &std::fclose);
json _;
CHECK_NOTHROW(_ = json::parse(f.get()));
}

SECTION("FILE 2.json")
{
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/2.json", "r"), &std::fclose);
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/2.json", "r"), &std::fclose);
json _;
CHECK_NOTHROW(_ = json::parse(f.get()));
}

SECTION("FILE 3.json")
{
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/3.json", "r"), &std::fclose);
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/3.json", "r"), &std::fclose);
json _;
CHECK_NOTHROW(_ = json::parse(f.get()));
}

SECTION("FILE 4.json")
{
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/4.json", "r"), &std::fclose);
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/4.json", "r"), &std::fclose);
json _;
CHECK_NOTHROW(_ = json::parse(f.get()));
}

SECTION("FILE 5.json")
{
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/5.json", "r"), &std::fclose);
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/5.json", "r"), &std::fclose);
json _;
CHECK_NOTHROW(_ = json::parse(f.get()));
}
Expand Down

0 comments on commit 7206a82

Please sign in to comment.