Skip to content

Commit e9eadbc

Browse files
committed
💚 add fixes from #4490
1 parent 0d87e3a commit e9eadbc

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

.github/workflows/ubuntu.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ jobs:
249249
steps:
250250
- uses: actions/checkout@v4
251251
- uses: actions/setup-python@v5
252+
with:
253+
python-version: '3.11'
252254
- name: Install REUSE tool
253255
run: python -m pip install reuse
254256
- name: Run REUSE lint

tests/src/unit-deserialization.cpp

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ using nlohmann::json;
2020
#include <sstream>
2121
#include <valarray>
2222

23+
2324
namespace
2425
{
2526
struct SaxEventLogger : public nlohmann::json_sax<json>
@@ -1131,18 +1132,15 @@ TEST_CASE("deserialization")
11311132
}
11321133
}
11331134

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__
11351137
#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)
11431141
#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)
11461144
{
11471145
std::vector<T> const v = {'t', 'r', 'u', 'e'};
11481146
CHECK(json::parse(v) == json(true));
@@ -1154,8 +1152,7 @@ TEST_CASE_TEMPLATE("deserialization of different character types (ASCII)", T, //
11541152
CHECK(l.events == std::vector<std::string>({"boolean(true)"}));
11551153
}
11561154

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)
11591156
{
11601157
// a star emoji
11611158
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, //
11671164
CHECK(l.events.size() == 1);
11681165
}
11691166

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)
11761168
{
11771169
// a star emoji
11781170
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, /
11841176
CHECK(l.events.size() == 1);
11851177
}
11861178

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)
11931180
{
11941181
// a star emoji
11951182
std::vector<T> const v = {static_cast<T>('"'), static_cast<T>(0x2b50), static_cast<T>(0xfe0f), static_cast<T>('"')};

0 commit comments

Comments
 (0)