Merge branch 'develop' of https://github.com/nlohmann/json into comments

This commit is contained in:
Niels Lohmann 2020-06-21 12:40:21 +02:00
commit 139a0258cc
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
9 changed files with 110 additions and 57 deletions

View file

@ -11,8 +11,10 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.11.0")
)
set_tests_properties(cmake_fetch_content_configure PROPERTIES
FIXTURES_SETUP cmake_fetch_content
LABELS git_required
)
set_tests_properties(cmake_fetch_content_build PROPERTIES
FIXTURES_REQUIRED cmake_fetch_content
LABELS git_required
)
endif()

View file

@ -4,9 +4,8 @@ project(DummyImport CXX)
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY ${CMAKE_CURRENT_SOURCE_DIR}/../../..
GIT_TAG HEAD)
get_filename_component(GIT_REPOSITORY_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. ABSOLUTE)
FetchContent_Declare(json GIT_REPOSITORY ${GIT_REPOSITORY_DIRECTORY} GIT_TAG HEAD)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)

View file

@ -783,6 +783,40 @@ TEST_CASE("MessagePack")
CHECK(json::from_msgpack(result) == v);
CHECK(json::from_msgpack(result, true, false) == j);
}
SECTION("1.0")
{
double v = 1.0;
json j = v;
std::vector<uint8_t> expected =
{
0xca, 0x3f, 0x80, 0x00, 0x00
};
const auto result = json::to_msgpack(j);
CHECK(result == expected);
// roundtrip
CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result) == v);
CHECK(json::from_msgpack(result, true, false) == j);
}
SECTION("128.128")
{
double v = 128.1280059814453125;
json j = v;
std::vector<uint8_t> expected =
{
0xca, 0x43, 0x00, 0x20, 0xc5
};
const auto result = json::to_msgpack(j);
CHECK(result == expected);
// roundtrip
CHECK(json::from_msgpack(result) == j);
CHECK(json::from_msgpack(result) == v);
CHECK(json::from_msgpack(result, true, false) == j);
}
}
}