mirror of
https://github.com/nlohmann/json.git
synced 2024-12-12 03:49:22 +08:00
🔊 add test for type traits
This commit is contained in:
parent
bffa18b46e
commit
23496a3abf
@ -13,6 +13,7 @@
|
|||||||
#include <nlohmann/detail/input/input_adapters.hpp>
|
#include <nlohmann/detail/input/input_adapters.hpp>
|
||||||
#include <nlohmann/detail/input/position_t.hpp>
|
#include <nlohmann/detail/input/position_t.hpp>
|
||||||
#include <nlohmann/detail/macro_scope.hpp>
|
#include <nlohmann/detail/macro_scope.hpp>
|
||||||
|
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
{
|
{
|
||||||
@ -918,10 +919,6 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
f = std::strtold(str, endptr);
|
f = std::strtold(str, endptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NumberType>
|
|
||||||
struct is_64_bit : std::integral_constant < bool, (sizeof(NumberType) <= 8) >
|
|
||||||
{};
|
|
||||||
|
|
||||||
JSON_HEDLEY_NON_NULL(2)
|
JSON_HEDLEY_NON_NULL(2)
|
||||||
unsigned long long strtoull(const char* str, char** str_end, std::true_type)
|
unsigned long long strtoull(const char* str, char** str_end, std::true_type)
|
||||||
{
|
{
|
||||||
|
@ -327,6 +327,10 @@ template<typename BasicJsonType, typename ConstructibleArrayType>
|
|||||||
struct is_constructible_array_type
|
struct is_constructible_array_type
|
||||||
: is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
|
: is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
|
||||||
|
|
||||||
|
template<typename NumberType>
|
||||||
|
struct is_64_bit : std::integral_constant < bool, (sizeof(NumberType) <= 8) >
|
||||||
|
{};
|
||||||
|
|
||||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType,
|
template<typename RealIntegerType, typename CompatibleNumberIntegerType,
|
||||||
typename = void>
|
typename = void>
|
||||||
struct is_compatible_integer_type_impl : std::false_type {};
|
struct is_compatible_integer_type_impl : std::false_type {};
|
||||||
|
@ -3142,6 +3142,10 @@ template<typename BasicJsonType, typename ConstructibleArrayType>
|
|||||||
struct is_constructible_array_type
|
struct is_constructible_array_type
|
||||||
: is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
|
: is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
|
||||||
|
|
||||||
|
template<typename NumberType>
|
||||||
|
struct is_64_bit : std::integral_constant < bool, (sizeof(NumberType) <= 8) >
|
||||||
|
{};
|
||||||
|
|
||||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType,
|
template<typename RealIntegerType, typename CompatibleNumberIntegerType,
|
||||||
typename = void>
|
typename = void>
|
||||||
struct is_compatible_integer_type_impl : std::false_type {};
|
struct is_compatible_integer_type_impl : std::false_type {};
|
||||||
@ -8118,6 +8122,8 @@ class binary_reader
|
|||||||
|
|
||||||
// #include <nlohmann/detail/macro_scope.hpp>
|
// #include <nlohmann/detail/macro_scope.hpp>
|
||||||
|
|
||||||
|
// #include <nlohmann/detail/meta/type_traits.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace nlohmann
|
namespace nlohmann
|
||||||
{
|
{
|
||||||
@ -9023,10 +9029,6 @@ class lexer : public lexer_base<BasicJsonType>
|
|||||||
f = std::strtold(str, endptr);
|
f = std::strtold(str, endptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NumberType>
|
|
||||||
struct is_64_bit : std::integral_constant < bool, (sizeof(NumberType) <= 8) >
|
|
||||||
{};
|
|
||||||
|
|
||||||
JSON_HEDLEY_NON_NULL(2)
|
JSON_HEDLEY_NON_NULL(2)
|
||||||
unsigned long long strtoull(const char* str, char** str_end, std::true_type)
|
unsigned long long strtoull(const char* str, char** str_end, std::true_type)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +101,14 @@ TEST_CASE("Alternative number types")
|
|||||||
|
|
||||||
// 128-bit arithmetic does not work with sanitizers
|
// 128-bit arithmetic does not work with sanitizers
|
||||||
#if defined(__SIZEOF_INT128__) && !defined(__SANITIZE_ADDRESS__)
|
#if defined(__SIZEOF_INT128__) && !defined(__SANITIZE_ADDRESS__)
|
||||||
|
SECTION("type traits")
|
||||||
|
{
|
||||||
|
CHECK(std::is_integral<__int128_t>::value);
|
||||||
|
CHECK(std::is_integral<__uint128_t>::value);
|
||||||
|
CHECK(std::numeric_limits<__int128_t>::is_integer);
|
||||||
|
CHECK(std::numeric_limits<__uint128_t>::is_integer);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("128 bit integers")
|
SECTION("128 bit integers")
|
||||||
{
|
{
|
||||||
using json128 = nlohmann::basic_json<std::map, std::vector, std::string, bool, __int128_t, __uint128_t>;
|
using json128 = nlohmann::basic_json<std::map, std::vector, std::string, bool, __int128_t, __uint128_t>;
|
||||||
|
Loading…
Reference in New Issue
Block a user