tests: Fix ignored attributes warning during build

Signed-off-by: Gianfranco Costamagna <locutusofborg@debian.org>
This commit is contained in:
Pragyansh Chaturvedi 2025-02-27 17:47:51 +01:00 committed by Gianfranco Costamagna
parent 8215dbafbd
commit 7206a826b4
2 changed files with 8 additions and 6 deletions

View File

@ -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;
}

View File

@ -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")
{
@ -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()));
}