add tests to improve coverage

parent a414e359
......@@ -1577,8 +1577,8 @@ class binary_reader
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 16, result);
}
default: // LCOV_EXCL_LINE
assert(false); // LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
}
......
......@@ -1092,9 +1092,7 @@ class binary_writer
}
write_number(subtype);
oa->write_characters(
reinterpret_cast<const CharType*>(value.data()),
value.size());
oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
}
/*!
......
......@@ -7104,8 +7104,8 @@ class binary_reader
return get_number(input_format_t::msgpack, result.subtype) and get_binary(input_format_t::msgpack, 16, result);
}
default: // LCOV_EXCL_LINE
assert(false); // LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
}
......@@ -13041,9 +13041,7 @@ class binary_writer
}
write_number(subtype);
oa->write_characters(
reinterpret_cast<const CharType*>(value.data()),
value.size());
oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
}
/*!
......
......@@ -101,6 +101,9 @@ TEST_CASE("JSON pointers")
CHECK(j["/foo/1"_json_pointer] == j["foo"][1]);
CHECK(j.contains(json::json_pointer("/foo/0")));
CHECK(j.contains(json::json_pointer("/foo/1")));
CHECK(not j.contains(json::json_pointer("/foo/3")));
CHECK(not j.contains(json::json_pointer("/foo/+")));
CHECK(not j.contains(json::json_pointer("/foo/1+2")));
CHECK(not j.contains(json::json_pointer("/foo/-")));
// checked array access
......
......@@ -464,6 +464,11 @@ TEST_CASE("regression tests")
s2 = o["name"];
CHECK(s2 == "value");
// improve coverage
o["int"] = 1;
CHECK_THROWS_AS(s2 = o["int"], json::type_error);
CHECK_THROWS_WITH(s2 = o["int"], "[json.exception.type_error.302] type must be string, but is number");
}
SECTION("issue #146 - character following a surrogate pair is skipped")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment