mirror of
https://github.com/nlohmann/json.git
synced 2026-02-23 20:06:25 +00:00
add noexcept checks, and some missing noexcepts
This commit is contained in:
27
test/src/unit-noexcept.cpp
Normal file
27
test/src/unit-noexcept.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
enum test
|
||||
{
|
||||
};
|
||||
|
||||
struct pod {};
|
||||
struct pod_bis {};
|
||||
|
||||
void to_json(json &, pod) noexcept;
|
||||
void to_json(json &, pod_bis);
|
||||
static json j;
|
||||
|
||||
static_assert(noexcept(json{}), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, 2)), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, 2.5)), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, true)), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, test{})), "");
|
||||
static_assert(noexcept(nlohmann::to_json(j, pod{})), "");
|
||||
static_assert(not noexcept(nlohmann::to_json(j, pod_bis{})), "");
|
||||
static_assert(noexcept(json(2)), "");
|
||||
static_assert(noexcept(json(test{})), "");
|
||||
static_assert(noexcept(json(pod{})), "");
|
||||
Reference in New Issue
Block a user