✅ improve coverage
This commit is contained in:
parent
62487fcf68
commit
623f0e96e2
@ -1851,11 +1851,13 @@ class binary_writer
|
|||||||
case input_format_t::bon8:
|
case input_format_t::bon8:
|
||||||
oa->write_character(get_bon8_float_prefix(static_cast<float>(n)));
|
oa->write_character(get_bon8_float_prefix(static_cast<float>(n)));
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_START
|
||||||
case input_format_t::bson:
|
case input_format_t::bson:
|
||||||
case input_format_t::json:
|
case input_format_t::json:
|
||||||
case input_format_t::ubjson:
|
case input_format_t::ubjson:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
write_number(static_cast<float>(n));
|
write_number(static_cast<float>(n));
|
||||||
}
|
}
|
||||||
@ -1872,11 +1874,13 @@ class binary_writer
|
|||||||
case input_format_t::bon8:
|
case input_format_t::bon8:
|
||||||
oa->write_character(get_bon8_float_prefix(n));
|
oa->write_character(get_bon8_float_prefix(n));
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_START
|
||||||
case input_format_t::bson:
|
case input_format_t::bson:
|
||||||
case input_format_t::json:
|
case input_format_t::json:
|
||||||
case input_format_t::ubjson:
|
case input_format_t::ubjson:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
write_number(n);
|
write_number(n);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15425,11 +15425,13 @@ class binary_writer
|
|||||||
case input_format_t::bon8:
|
case input_format_t::bon8:
|
||||||
oa->write_character(get_bon8_float_prefix(static_cast<float>(n)));
|
oa->write_character(get_bon8_float_prefix(static_cast<float>(n)));
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_START
|
||||||
case input_format_t::bson:
|
case input_format_t::bson:
|
||||||
case input_format_t::json:
|
case input_format_t::json:
|
||||||
case input_format_t::ubjson:
|
case input_format_t::ubjson:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
write_number(static_cast<float>(n));
|
write_number(static_cast<float>(n));
|
||||||
}
|
}
|
||||||
@ -15446,11 +15448,13 @@ class binary_writer
|
|||||||
case input_format_t::bon8:
|
case input_format_t::bon8:
|
||||||
oa->write_character(get_bon8_float_prefix(n));
|
oa->write_character(get_bon8_float_prefix(n));
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_START
|
||||||
case input_format_t::bson:
|
case input_format_t::bson:
|
||||||
case input_format_t::json:
|
case input_format_t::json:
|
||||||
case input_format_t::ubjson:
|
case input_format_t::ubjson:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
write_number(n);
|
write_number(n);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -435,36 +435,61 @@ TEST_CASE("BON8")
|
|||||||
|
|
||||||
SECTION("floating-point numbers")
|
SECTION("floating-point numbers")
|
||||||
{
|
{
|
||||||
SECTION("-1.0")
|
SECTION("special values")
|
||||||
{
|
{
|
||||||
json j = -1.0;
|
SECTION("-1.0")
|
||||||
std::vector<uint8_t> expected = {0xFB};
|
{
|
||||||
const auto result = json::to_bon8(j);
|
json j = -1.0;
|
||||||
CHECK(result == expected);
|
std::vector<uint8_t> expected = {0xFB};
|
||||||
|
const auto result = json::to_bon8(j);
|
||||||
|
CHECK(result == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("0.0")
|
||||||
|
{
|
||||||
|
json j = 0.0;
|
||||||
|
std::vector<uint8_t> expected = {0xFC};
|
||||||
|
const auto result = json::to_bon8(j);
|
||||||
|
CHECK(result == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("1.0")
|
||||||
|
{
|
||||||
|
json j = 1.0;
|
||||||
|
std::vector<uint8_t> expected = {0xFD};
|
||||||
|
const auto result = json::to_bon8(j);
|
||||||
|
CHECK(result == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("-0.0")
|
||||||
|
{
|
||||||
|
json j = -0.0;
|
||||||
|
std::vector<uint8_t> expected = {0x8E, 0x80, 0x00, 0x00, 0x00};
|
||||||
|
const auto result = json::to_bon8(j);
|
||||||
|
CHECK(result == expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("0.0")
|
SECTION("floats")
|
||||||
{
|
{
|
||||||
json j = 0.0;
|
SECTION("2.0")
|
||||||
std::vector<uint8_t> expected = {0xFC};
|
{
|
||||||
const auto result = json::to_bon8(j);
|
json j = 2.0;
|
||||||
CHECK(result == expected);
|
std::vector<uint8_t> expected = {0x8E, 0x40, 0x00, 0x00, 0x00};
|
||||||
|
const auto result = json::to_bon8(j);
|
||||||
|
CHECK(result == expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("1.0")
|
SECTION("doubles")
|
||||||
{
|
{
|
||||||
json j = 1.0;
|
SECTION("100000000.1")
|
||||||
std::vector<uint8_t> expected = {0xFD};
|
{
|
||||||
const auto result = json::to_bon8(j);
|
json j = 100000000.1;
|
||||||
CHECK(result == expected);
|
std::vector<uint8_t> expected = {0x8F, 0x41, 0x97, 0xD7, 0x84, 0x00, 0x66, 0x66, 0x66};
|
||||||
}
|
const auto result = json::to_bon8(j);
|
||||||
|
CHECK(result == expected);
|
||||||
SECTION("-0.0")
|
}
|
||||||
{
|
|
||||||
json j = -0.0;
|
|
||||||
std::vector<uint8_t> expected = {0x8E, 0x80, 0x00, 0x00, 0x00};
|
|
||||||
const auto result = json::to_bon8(j);
|
|
||||||
CHECK(result == expected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user