@@ -20,6 +20,7 @@ using nlohmann::json;
20
20
#include < sstream>
21
21
#include < valarray>
22
22
23
+
23
24
namespace
24
25
{
25
26
struct SaxEventLogger : public nlohmann ::json_sax<json>
@@ -1131,18 +1132,15 @@ TEST_CASE("deserialization")
1131
1132
}
1132
1133
}
1133
1134
1134
- TEST_CASE_TEMPLATE (" deserialization of different character types (ASCII)" , T, // NOLINT(readability-math-missing-parentheses)
1135
+ // select the types to test - char8_t is only available in C++20
1136
+ #define TYPE_LIST (...) __VA_ARGS__
1135
1137
#ifdef JSON_HAS_CPP_20
1136
- char8_t ,
1137
- #endif
1138
- #ifndef _LIBCPP_VERSION // see https://github.com/nlohmann/json/issues/4490
1139
- unsigned char , signed char ,
1140
- std::uint8_t , std::int8_t ,
1141
- std::int16_t , std::uint16_t ,
1142
- std::int32_t , std::uint32_t ,
1138
+ #define ASCII_TYPES TYPE_LIST (char , wchar_t , char16_t , char32_t , char8_t )
1139
+ #else
1140
+ #define ASCII_TYPES TYPE_LIST (char , wchar_t , char16_t , char32_t )
1143
1141
#endif
1144
- char , wchar_t , char16_t , char32_t
1145
- )
1142
+
1143
+ TEST_CASE_TEMPLATE ( " deserialization of different character types (ASCII) " , T, ASCII_TYPES) // NOLINT(readability-math-missing-parentheses )
1146
1144
{
1147
1145
std::vector<T> const v = {' t' , ' r' , ' u' , ' e' };
1148
1146
CHECK (json::parse (v) == json (true ));
@@ -1154,8 +1152,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T, //
1154
1152
CHECK (l.events == std::vector<std::string>({" boolean(true)" }));
1155
1153
}
1156
1154
1157
- TEST_CASE_TEMPLATE (" deserialization of different character types (UTF-8)" , T, // NOLINT(readability-math-missing-parentheses)
1158
- char , unsigned char , std::uint8_t )
1155
+ TEST_CASE_TEMPLATE (" deserialization of different character types (UTF-8)" , T, char , unsigned char , std::uint8_t ) // NOLINT(readability-math-missing-parentheses)
1159
1156
{
1160
1157
// a star emoji
1161
1158
std::vector<T> const v = {' "' , static_cast <T>(0xe2u ), static_cast <T>(0xadu ), static_cast <T>(0x90u ), static_cast <T>(0xefu ), static_cast <T>(0xb8u ), static_cast <T>(0x8fu ), ' "' };
@@ -1167,12 +1164,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (UTF-8)", T, //
1167
1164
CHECK (l.events .size () == 1 );
1168
1165
}
1169
1166
1170
- TEST_CASE_TEMPLATE (" deserialization of different character types (UTF-16)" , T, // NOLINT(readability-math-missing-parentheses)
1171
- #ifndef _LIBCPP_VERSION // see https://github.com/nlohmann/json/issues/4490
1172
- std::uint16_t ,
1173
- #endif
1174
- char16_t
1175
- )
1167
+ TEST_CASE_TEMPLATE (" deserialization of different character types (UTF-16)" , T, char16_t ) // NOLINT(readability-math-missing-parentheses)
1176
1168
{
1177
1169
// a star emoji
1178
1170
std::vector<T> const v = {static_cast <T>(' "' ), static_cast <T>(0x2b50 ), static_cast <T>(0xfe0f ), static_cast <T>(' "' )};
@@ -1184,12 +1176,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (UTF-16)", T, /
1184
1176
CHECK (l.events .size () == 1 );
1185
1177
}
1186
1178
1187
- TEST_CASE_TEMPLATE (" deserialization of different character types (UTF-32)" , T, // NOLINT(readability-math-missing-parentheses)
1188
- #ifndef _LIBCPP_VERSION // see https://github.com/nlohmann/json/issues/4490
1189
- std::uint32_t ,
1190
- #endif
1191
- char32_t
1192
- )
1179
+ TEST_CASE_TEMPLATE (" deserialization of different character types (UTF-32)" , T, char32_t ) // NOLINT(readability-math-missing-parentheses)
1193
1180
{
1194
1181
// a star emoji
1195
1182
std::vector<T> const v = {static_cast <T>(' "' ), static_cast <T>(0x2b50 ), static_cast <T>(0xfe0f ), static_cast <T>(' "' )};
0 commit comments