Commit 8042a1d1 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #288

Additional tests for range trees.

git-svn-id: file:///svn/tokudb@1743 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2b94f886
......@@ -53,6 +53,11 @@ int main(int argc, const char *argv[]) {
toku_range* buf = (toku_range*)toku_malloc(2*sizeof(toku_range));
unsigned bufsize = 2;
unsigned found;
int stuff[3] = {0,1,2};
range.left = &stuff[0];
range.right = &stuff[1];
range.data = NULL;
r = toku_rt_create(&tree, dummy_cmp, dummy_cmp, FALSE); CKERR(r);
assert(tree != NULL);
......@@ -63,12 +68,23 @@ int main(int argc, const char *argv[]) {
r = toku_rt_find(tree, NULL, 2, &buf, &bufsize, &found);
CKERR2(r, EINVAL);
range.data = &stuff[2];
r = toku_rt_find(tree, &range, 2, &buf, &bufsize, &found);
CKERR2(r, EINVAL);
range.data = NULL;
r = toku_rt_find(tree, &range, 2, NULL, &bufsize, &found);
CKERR2(r, EINVAL);
r = toku_rt_find(tree, &range, 2, &buf, NULL, &found);
CKERR2(r, EINVAL);
unsigned oldbufsize = bufsize;
bufsize = 0;
r = toku_rt_find(tree, &range, 2, &buf, &bufsize, &found);
CKERR2(r, EINVAL);
bufsize = oldbufsize;
r = toku_rt_find(tree, &range, 2, &buf, &bufsize, NULL);
CKERR2(r, EINVAL);
......
......@@ -28,6 +28,9 @@ int main(int argc, const char *argv[]) {
range.data = &letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
/* Try and fail to insert exact same thing. */
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
......@@ -48,6 +51,9 @@ int main(int argc, const char *argv[]) {
range.data = &letters[0];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Try to delete again, make sure it fails. (Not there anymore) */
r = toku_rt_delete(tree, &range); CKERR2(r,EDOM);
range.left = &nums[2];
range.right = &nums[6];
range.data = &letters[0];
......@@ -94,6 +100,22 @@ int main(int argc, const char *argv[]) {
range.data = &letters[0];
r = toku_rt_insert(tree, &range); CKERR(r);
/* Try and fail to insert exact same thing. */
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
/* Try (and fail) to insert an overlapping range in a nooverlap tree. */
range.left = &nums[0];
range.right = &nums[4];
range.data = &letters[0];
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
/* Try (and fail) to insert an overlapping range (different data) in a
nooverlap tree. */
range.left = &nums[0];
range.right = &nums[4];
range.data = &letters[1];
r = toku_rt_insert(tree, &range); CKERR2(r,EDOM);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
......@@ -104,6 +126,9 @@ int main(int argc, const char *argv[]) {
range.data = &letters[1];
r = toku_rt_delete(tree, &range); CKERR(r);
/* Try to delete again, make sure it fails. (Not there anymore) */
r = toku_rt_delete(tree, &range); CKERR2(r,EDOM);
range.left = &nums[4];
range.right = &nums[6];
range.data = &letters[1];
......
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