Harden and fully cover the C++ translation
Add an exhaustive readable-instance sweep and a coverage gate requiring 100% line coverage of the summarised implementation. Delete branches that are unreachable under `Readable`, centralise and assert the 32-bit offset contract at the public entry points, and stop materialising `n` zero bytes when deciding `keyAfterN n k < upper`. Also add the extreme-offset regression test, harden the corpus parsers, remove unused model helpers, document the literal-total / fast-readable split, and refresh the validation and benchmark numbers.
This commit is contained in:
1 parent
e32e42d933
commit
3bb5d062ff
15 files changed
+620
-196
No files matched your search
+12
-11
@@ -23,7 +23,8 @@ struct Case {
|
||||
Result res;
|
||||
const char* name = "";
|
||||
|
||||
// Build the borrowed views once the case sits at its final address.
|
||||
// Build the borrowed views in place. `Case` is move-only (through
|
||||
// `Instance`), and the views must be rebuilt after any move.
|
||||
void prepare() {
|
||||
inst.finish();
|
||||
r = inst.read();
|
||||
@@ -38,9 +39,7 @@ std::vector<Key> makeDb(std::size_t n, std::size_t len) {
|
||||
Key k;
|
||||
k.reserve(len);
|
||||
for (std::size_t j = 0; j < len; ++j)
|
||||
k.push_back(static_cast<Byte>((i >> (8 * j)) & 0xff));
|
||||
// Ensure strict ordering is preserved for the multi-byte encoding.
|
||||
if (!db.empty() && !keyLt(db.back(), k)) k.push_back(static_cast<Byte>(i));
|
||||
k.push_back(static_cast<char>(static_cast<Byte>((i >> (8 * j)) & 0xff)));
|
||||
db.push_back(std::move(k));
|
||||
}
|
||||
std::sort(db.begin(), db.end());
|
||||
@@ -117,10 +116,12 @@ int main() {
|
||||
// A short truncated read (cross-free).
|
||||
cases.push_back(makeCase(smallDb, smallDb[1], 1, top, 1, false, true,
|
||||
"small truncated fwd"));
|
||||
// A crossed read: the end selector resolves before the begin selector.
|
||||
cases.push_back(makeCase(mediumDb, mediumDb[40], 1, mediumDb[3], 1, false,
|
||||
// A crossed read: the end *key* is below the begin key, but the offsets move
|
||||
// the resolved anchors back into order, so the range is nonempty and the
|
||||
// dispatch takes the crossed branch.
|
||||
cases.push_back(makeCase(mediumDb, mediumDb[40], -30, mediumDb[3], 40, false,
|
||||
true, "crossed truncated fwd"));
|
||||
cases.push_back(makeCase(mediumDb, mediumDb[40], 1, mediumDb[3], 1, true,
|
||||
cases.push_back(makeCase(mediumDb, mediumDb[40], -30, mediumDb[3], 40, true,
|
||||
true, "crossed truncated rev"));
|
||||
// Long complete / truncated reads.
|
||||
cases.push_back(
|
||||
@@ -130,10 +131,10 @@ int main() {
|
||||
cases.push_back(makeCase(longDb, bot, 1, top, 1, true, true,
|
||||
"long truncated rev"));
|
||||
|
||||
// The case vector is final now, so the borrowed views can point at it.
|
||||
for (Case& c : cases) c.prepare();
|
||||
|
||||
for (const Case& c : cases) {
|
||||
// Prepare each case in place (its views borrow from the instance) and check
|
||||
// that both implementations agree before timing them.
|
||||
for (Case& c : cases) {
|
||||
c.prepare();
|
||||
check(c);
|
||||
Bench bench;
|
||||
bench.title(c.name).relative(true).warmup(20).minEpochIterations(200);
|
||||
|
||||
Reference in new issue
Block a user