Skip to content

Commit cd92c09

Browse files
LocutusOfBorgPragyansh Chaturvedi
andauthored
tests: Fix ignored attributes warning during build (#4670)
Signed-off-by: Gianfranco Costamagna <[email protected]> Co-authored-by: Pragyansh Chaturvedi <[email protected]>
1 parent b477d2b commit cd92c09

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/src/make_test_data_available.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ namespace utils
1818

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

tests/src/unit-testsuites.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ TEST_CASE("test suite from json-test-suite")
326326
TEST_CASE("json.org examples")
327327
{
328328
// here, we list all JSON values from https://json.org/example
329+
using FilePtr = std::unique_ptr<FILE, int(*)(FILE*)>;
329330

330331
SECTION("1.json")
331332
{
@@ -363,35 +364,35 @@ TEST_CASE("json.org examples")
363364
}
364365
SECTION("FILE 1.json")
365366
{
366-
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/1.json", "r"), &std::fclose);
367+
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/1.json", "r"), &std::fclose);
367368
json _;
368369
CHECK_NOTHROW(_ = json::parse(f.get()));
369370
}
370371

371372
SECTION("FILE 2.json")
372373
{
373-
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/2.json", "r"), &std::fclose);
374+
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/2.json", "r"), &std::fclose);
374375
json _;
375376
CHECK_NOTHROW(_ = json::parse(f.get()));
376377
}
377378

378379
SECTION("FILE 3.json")
379380
{
380-
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/3.json", "r"), &std::fclose);
381+
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/3.json", "r"), &std::fclose);
381382
json _;
382383
CHECK_NOTHROW(_ = json::parse(f.get()));
383384
}
384385

385386
SECTION("FILE 4.json")
386387
{
387-
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/4.json", "r"), &std::fclose);
388+
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/4.json", "r"), &std::fclose);
388389
json _;
389390
CHECK_NOTHROW(_ = json::parse(f.get()));
390391
}
391392

392393
SECTION("FILE 5.json")
393394
{
394-
const std::unique_ptr<std::FILE, decltype(&std::fclose)> f(std::fopen(TEST_DATA_DIRECTORY "/json.org/5.json", "r"), &std::fclose);
395+
const FilePtr f(std::fopen(TEST_DATA_DIRECTORY "/json.org/5.json", "r"), &std::fclose);
395396
json _;
396397
CHECK_NOTHROW(_ = json::parse(f.get()));
397398
}

0 commit comments

Comments
 (0)