Add some tests for operator<()

This commit is contained in:
Daniel Smith 2020-02-10 12:47:06 -05:00
parent 7aebe05ff9
commit 3c4b93650d
1 changed files with 34 additions and 4 deletions

View File

@ -936,13 +936,43 @@ void miniConflictSetTest() {
printf("miniConflictSetTest complete\n");
}
void operatorLessThanTest() {
{ // Longer strings before shorter strings.
KeyInfo a(LiteralStringRef("hello"), /*begin=*/false, /*write=*/true, -1);
KeyInfo b(LiteralStringRef("hello\0"), /*begin=*/false, /*write=*/false, 0);
ASSERT(a < b);
ASSERT(!(b < a));
ASSERT(!(a == b));
}
{ // Reads before writes.
KeyInfo a(LiteralStringRef("hello"), /*begin=*/false, /*write=*/false, -1);
KeyInfo b(LiteralStringRef("hello"), /*begin=*/false, /*write=*/true, 0);
ASSERT(a < b);
ASSERT(!(b < a));
ASSERT(!(a == b));
}
{ // Begin reads after writes.
KeyInfo a(LiteralStringRef("hello"), /*begin=*/false, /*write=*/true, -1);
KeyInfo b(LiteralStringRef("hello"), /*begin=*/true, /*write=*/false, 0);
ASSERT(a < b);
ASSERT(!(b < a));
ASSERT(!(a == b));
}
{ // Begin writes after writes.
KeyInfo a(LiteralStringRef("hello"), /*begin=*/false, /*write=*/true, -1);
KeyInfo b(LiteralStringRef("hello"), /*begin=*/true, /*write=*/true, 0);
ASSERT(a < b);
ASSERT(!(b < a));
ASSERT(!(a == b));
}
}
void skipListTest() {
printf("Skip list test\n");
// A test case that breaks the old operator<
// KeyInfo a( LiteralStringRef("hello"), true, false, true, -1 );
// KeyInfo b( LiteralStringRef("hello\0"), false, false, false, 0 );
miniConflictSetTest();
setAffinity(0);