diff --git a/ConflictSet.cpp b/ConflictSet.cpp index a9ef1c5..963fca6 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -260,6 +260,18 @@ void lastLeqMulti(Node *root, std::span keys, Iterator *results) { fprintf(file, "}\n"); } +[[maybe_unused]] Key toKey(int n) { + constexpr int kMaxLength = 4; + static unsigned char itoaBuf[kMaxLength]; + int i = kMaxLength; + memset(itoaBuf, '0', kMaxLength); + do { + itoaBuf[--i] = "0123456789abcdef"[n % 16]; + n /= 16; + } while (n); + return Key{itoaBuf, kMaxLength}; +} + } // namespace struct ConflictSet::Impl { @@ -378,12 +390,13 @@ ConflictSet &ConflictSet::operator=(ConflictSet &&other) noexcept { #ifdef ENABLE_TESTS int main(void) { ConflictSet::Impl cs{0}; - ConflictSet::WriteRange write; - write.begin.p = (const uint8_t *)"0000"; - write.begin.len = 4; - write.end.len = 0; - write.writeVersion = 1; - cs.addWrites(&write, 1); + for (int i = 0; i < 10; ++i) { + ConflictSet::WriteRange write; + write.begin = toKey(i); + write.end.len = 0; + write.writeVersion = i; + cs.addWrites(&write, 1); + } debugPrintDot(stdout, cs.root); } #endif \ No newline at end of file