Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
a1c8113c
Commit
a1c8113c
authored
Apr 23, 2008
by
Zardosht Kasheff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addresses #724
test delete git-svn-id:
file:///svn/tokudb@3592
c7de825b-a66e-492c-adef-691d508d4ae1
parent
437fb1bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
24 deletions
+73
-24
newbrt/omt-test.c
newbrt/omt-test.c
+73
-24
No files found.
newbrt/omt-test.c
View file @
a1c8113c
...
...
@@ -172,6 +172,8 @@ void test_create_insert_at_almost_random(enum close_when_done close) {
test_create
(
KEEP_WHEN_DONE
);
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
1
);
CKERR2
(
r
,
ERANGE
);
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
2
);
CKERR2
(
r
,
ERANGE
);
for
(
i
=
0
;
i
<
length
/
2
;
i
++
)
{
assert
(
size
==
toku_omt_size
(
omt
));
r
=
toku_omt_insert_at
(
omt
,
values
[
i
],
i
);
...
...
@@ -183,6 +185,8 @@ void test_create_insert_at_almost_random(enum close_when_done close) {
}
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
1
);
CKERR2
(
r
,
ERANGE
);
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
2
);
CKERR2
(
r
,
ERANGE
);
assert
(
size
==
toku_omt_size
(
omt
));
test_close
(
close
);
}
...
...
@@ -195,6 +199,8 @@ void test_create_insert_at_sequential(enum close_when_done close) {
test_create
(
KEEP_WHEN_DONE
);
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
1
);
CKERR2
(
r
,
ERANGE
);
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
2
);
CKERR2
(
r
,
ERANGE
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
assert
(
size
==
toku_omt_size
(
omt
));
r
=
toku_omt_insert_at
(
omt
,
values
[
i
],
i
);
...
...
@@ -203,6 +209,8 @@ void test_create_insert_at_sequential(enum close_when_done close) {
}
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
1
);
CKERR2
(
r
,
ERANGE
);
r
=
toku_omt_insert_at
(
omt
,
values
[
0
],
toku_omt_size
(
omt
)
+
2
);
CKERR2
(
r
,
ERANGE
);
assert
(
size
==
toku_omt_size
(
omt
));
test_close
(
close
);
}
...
...
@@ -294,7 +302,12 @@ void test_iterate_verify(void) {
CKERR
(
r
);
iterate_helper_error_return
=
0xFEEDABBA
;
r
=
toku_omt_iterate
(
omt
,
iterate_helper
,
NULL
);
if
(
!
length
)
{
CKERR2
(
r
,
0
);
}
else
{
CKERR2
(
r
,
iterate_helper_error_return
);
}
}
void
test_create_iterate_verify
(
enum
create_type
create_choice
,
enum
close_when_done
close
)
{
...
...
@@ -304,6 +317,25 @@ void test_create_iterate_verify(enum create_type create_choice, enum close_when_
}
void
permute_array
(
u_int32_t
*
arr
,
u_int32_t
len
)
{
//
// create a permutation of 0...size-1
//
u_int32_t
i
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
arr
[
i
]
=
i
;
}
for
(
i
=
0
;
i
<
len
-
1
;
i
++
)
{
u_int32_t
choices
=
len
-
i
;
u_int32_t
choice
=
random
()
%
choices
;
if
(
choice
!=
i
)
{
u_int32_t
temp
=
arr
[
i
];
arr
[
i
]
=
arr
[
choice
];
arr
[
choice
]
=
temp
;
}
}
}
void
test_create_set_at
(
enum
create_type
create_choice
,
enum
close_when_done
close
)
{
u_int32_t
i
=
0
;
...
...
@@ -319,21 +351,8 @@ void test_create_set_at(enum create_type create_choice, enum close_when_done clo
MALLOC_N
(
length
,
old_values
);
assert
(
old_values
);
//
// permute an array that holds elements 0...length-1
//
for
(
i
=
0
;
i
<
length
;
i
++
)
{
perm
[
i
]
=
i
;
}
for
(
i
=
0
;
i
<
length
-
1
;
i
++
)
{
u_int32_t
choices
=
length
-
i
;
u_int32_t
choice
=
random
()
%
choices
;
if
(
choice
!=
i
)
{
u_int32_t
temp
=
perm
[
i
];
perm
[
i
]
=
perm
[
choice
];
perm
[
choice
]
=
temp
;
}
}
permute_array
(
perm
,
length
);
//
// These are going to be the new values
//
...
...
@@ -343,12 +362,11 @@ void test_create_set_at(enum create_type create_choice, enum close_when_done clo
values
[
i
]
=
&
old_nums
[
i
];
}
test_create_from_sorted_array
(
create_choice
,
KEEP_WHEN_DONE
);
//
//
//
int
r
;
r
=
toku_omt_set_at
(
omt
,
values
[
0
],
length
);
CKERR2
(
r
,
ERANGE
);
r
=
toku_omt_set_at
(
omt
,
values
[
0
],
length
+
1
);
CKERR2
(
r
,
ERANGE
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
u_int32_t
choice
=
perm
[
i
];
values
[
choice
]
=
&
nums
[
choice
];
...
...
@@ -360,12 +378,45 @@ void test_create_set_at(enum create_type create_choice, enum close_when_done clo
}
r
=
toku_omt_set_at
(
omt
,
values
[
0
],
length
);
CKERR2
(
r
,
ERANGE
);
r
=
toku_omt_set_at
(
omt
,
values
[
0
],
length
+
1
);
CKERR2
(
r
,
ERANGE
);
test_close
(
close
);
}
void
test_create_delete_at
(
enum
create_type
create_choice
,
enum
close_when_done
close
)
{
u_int32_t
i
=
0
;
int
r
=
ENOSYS
;
test_create_from_sorted_array
(
create_choice
,
KEEP_WHEN_DONE
);
assert
(
length
==
toku_omt_size
(
omt
));
r
=
toku_omt_delete_at
(
omt
,
length
);
CKERR2
(
r
,
ERANGE
);
assert
(
length
==
toku_omt_size
(
omt
));
r
=
toku_omt_delete_at
(
omt
,
length
+
1
);
CKERR2
(
r
,
ERANGE
);
while
(
length
>
0
)
{
assert
(
length
==
toku_omt_size
(
omt
));
u_int32_t
index_to_delete
=
random
()
%
length
;
r
=
toku_omt_delete_at
(
omt
,
index_to_delete
);
CKERR
(
r
);
for
(
i
=
index_to_delete
+
1
;
i
<
length
;
i
++
)
{
values
[
i
-
1
]
=
values
[
i
];
}
length
--
;
test_fetch_verify
();
test_iterate_verify
();
}
assert
(
length
==
0
);
assert
(
length
==
toku_omt_size
(
omt
));
r
=
toku_omt_delete_at
(
omt
,
length
);
CKERR2
(
r
,
ERANGE
);
assert
(
length
==
toku_omt_size
(
omt
));
r
=
toku_omt_delete_at
(
omt
,
length
+
1
);
CKERR2
(
r
,
ERANGE
);
test_close
(
close
);
}
void
test_create_array
(
enum
create_type
create_choice
,
enum
rand_type
rand_choice
)
{
if
(
rand_choice
==
TEST_RANDOM
)
{
...
...
@@ -388,6 +439,8 @@ void test_create_array(enum create_type create_choice, enum rand_type rand_choic
/* ********************************************************************** */
test_create_set_at
(
create_choice
,
CLOSE_WHEN_DONE
);
/* ********************************************************************** */
test_create_delete_at
(
create_choice
,
CLOSE_WHEN_DONE
);
/* ********************************************************************** */
}
typedef
struct
{
...
...
@@ -607,9 +660,5 @@ int toku_omt_insert(OMT omt, OMTVALUE value, int(*h)(OMTVALUE, void*v), void *v,
// omt_insert_at(tree, value, i);
// If index!=NULL then i is stored in *index
int toku_omt_delete_at(OMT omt, u_int32_t index);
// Effect: Delete the item in slot index.
// Decreases indexes of all items at slot >= index by 1.
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment