Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LiteCore/RevTrees/VersionVectorWithLegacy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace litecore {
if ( !legacy.empty() ) {
std::string_view delimiter;
if ( !vector.empty() ) {
if ( vector.currentVersions() == vector.count() ) delimiter = "; ";
if ( vector.currentVersions() == 1 ) delimiter = "; ";
else
delimiter = ", ";
}
Expand Down
29 changes: 29 additions & 0 deletions LiteCore/tests/VersionVectorTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,35 @@ TEST_CASE("VersionVector <-> String", "[RevIDs]") {

for ( uint8_t b : v.asBinary() ) fprintf(stderr, "0x%02X, ", b);
fprintf(stderr, "\n");

slice noPVStr = "4@*, 2@AliceAliceAliceAliceAA, 1@DaveDaveDaveDaveDaveDA;"_sl;
VersionVector noPV;
noPV.readASCII(noPVStr);
// The semicolon divides the current versions (the current version and merge versions) from
// the past versions.
CHECK(noPV.currentVersions() == 3);

// It's ASCII representtion ends with the semicolon:
alloc_slice noPVasASCII = noPV.asASCII();
CHECK(noPVasASCII[noPVasASCII.size - 1] == ';');

// The ending semicolon is optional if there is no past versions.
VersionVector noPV2;
noPV2.readASCII(noPVStr.upTo(noPVStr.size - 1));
CHECK(noPV2.currentVersions() == 3);

// However, the ASCII representation still ends with the semicolon
CHECK(noPV2.asASCII() == noPVasASCII);

// Special rule for noPV.currentVersions() == 1: the API genenerated
// ASCII form does not have the ending semicolon
slice cv = "1@DaveDaveDaveDaveDaveDA;"_sl;
VersionVector cvOnly;
cvOnly.readASCII(cv);
REQUIRE(cvOnly.currentVersions() == 1);
REQUIRE(cvOnly.count() == 1);
// The returned ASCII does not have the ending ";"
CHECK(cvOnly.asASCII() == cv.upTo(cv.size - 1));
}

TEST_CASE("VersionVector <-> Binary", "[RevIDs]") {
Expand Down