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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
67564afc
Commit
67564afc
authored
Dec 07, 2007
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test case. closes #153
git-svn-id:
file:///svn/tokudb@1014
c7de825b-a66e-492c-adef-691d508d4ae1
parent
55243e2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
src/tests/test_cursor_db_current.c
src/tests/test_cursor_db_current.c
+15
-12
src/tests/test_cursor_nonleaf_expand.c
src/tests/test_cursor_nonleaf_expand.c
+9
-0
No files found.
src/tests/test_cursor_db_current.c
View file @
67564afc
...
...
@@ -13,8 +13,6 @@
#include "test.h"
void
db_put
(
DB
*
db
,
int
k
,
int
v
)
{
DB_TXN
*
const
null_txn
=
0
;
DBT
key
,
val
;
...
...
@@ -22,18 +20,17 @@ void db_put(DB *db, int k, int v) {
assert
(
r
==
0
);
}
void
test_
db
_current
()
{
if
(
verbose
)
printf
(
"test_
db
_current
\n
"
);
void
test_
cursor
_current
()
{
if
(
verbose
)
printf
(
"test_
cursor
_current
\n
"
);
DB_ENV
*
const
null_env
=
0
;
DB
*
db
;
DB_TXN
*
const
null_txn
=
0
;
const
char
*
const
fname
=
DIR
"/"
"test.
db
.current.brt"
;
const
char
*
const
fname
=
DIR
"/"
"test.
cursor
.current.brt"
;
int
r
;
unlink
(
fname
);
/* create the dup database file */
r
=
db_create
(
&
db
,
null_env
,
0
);
assert
(
r
==
0
);
r
=
db
->
open
(
db
,
null_txn
,
fname
,
"main"
,
DB_BTREE
,
DB_CREATE
,
0666
);
...
...
@@ -42,7 +39,7 @@ void test_db_current() {
/* insert <1,1> */
int
k
=
1
,
v
=
1
;
db_put
(
db
,
k
,
v
);
DBC
*
cursor
;
r
=
db
->
cursor
(
db
,
null_txn
,
&
cursor
,
0
);
...
...
@@ -57,22 +54,28 @@ void test_db_current() {
assert
(
r
==
0
);
assert
(
key
.
size
==
sizeof
kk
);
memcpy
(
&
kk
,
key
.
data
,
sizeof
kk
);
assert
(
kk
==
1
);
assert
(
kk
==
k
);
assert
(
data
.
size
==
sizeof
vv
);
memcpy
(
&
vv
,
data
.
data
,
data
.
size
);
assert
(
vv
==
1
);
assert
(
vv
==
v
);
free
(
key
.
data
);
free
(
data
.
data
);
r
=
cursor
->
c_get
(
cursor
,
dbt_init_malloc
(
&
key
),
dbt_init_malloc
(
&
data
),
DB_CURRENT
);
assert
(
r
==
0
);
assert
(
key
.
size
==
sizeof
kk
);
memcpy
(
&
kk
,
key
.
data
,
sizeof
kk
);
assert
(
kk
==
1
);
assert
(
kk
==
k
);
assert
(
data
.
size
==
sizeof
vv
);
memcpy
(
&
vv
,
data
.
data
,
data
.
size
);
assert
(
vv
==
1
);
assert
(
vv
==
v
);
free
(
key
.
data
);
free
(
data
.
data
);
r
=
cursor
->
c_del
(
cursor
,
0
);
assert
(
r
==
0
);
r
=
cursor
->
c_get
(
cursor
,
dbt_init_malloc
(
&
key
),
dbt_init_malloc
(
&
data
),
DB_CURRENT
);
assert
(
r
==
DB_KEYEMPTY
);
r
=
cursor
->
c_close
(
cursor
);
assert
(
r
==
0
);
...
...
@@ -86,7 +89,7 @@ int main(int argc, const char *argv[]) {
system
(
"rm -rf "
DIR
);
mkdir
(
DIR
,
0777
);
test_
db
_current
();
test_
cursor
_current
();
return
0
;
}
src/tests/test_cursor_nonleaf_expand.c
View file @
67564afc
...
...
@@ -37,6 +37,14 @@ int db_put(DB *db, int k, int v) {
return
r
;
}
/* use inserts and cursors to test the brt_nonleaf_expand function
insert keys 0 and n and set cursors to them
then insert keys 1 .. n-1. this should cause leaf splits, new root nodes, nonleaf expands
and nonleaf splits as the tree grows.
the reverse parameter controls where in insertions are made to test the <, =, >
cases in the brt_nonleaf_expand function */
void
test_cursor_nonleaf_expand
(
int
n
,
int
reverse
)
{
if
(
verbose
)
printf
(
"test_cursor_nonleaf_expand:%d %d
\n
"
,
n
,
reverse
);
...
...
@@ -69,6 +77,7 @@ void test_cursor_nonleaf_expand(int n, int reverse) {
}
}
/* make sure the cursors did not move */
expect_cursor_get
(
cursor0
,
htonl
(
0
),
0
,
DB_CURRENT
);
expect_cursor_get
(
cursorn
,
htonl
(
n
),
n
,
DB_CURRENT
);
...
...
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