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
d65552f3
Commit
d65552f3
authored
Jan 16, 2008
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
increase test coverage. addresses #277
git-svn-id:
file:///svn/tokudb@1695
c7de825b-a66e-492c-adef-691d508d4ae1
parent
ec74f2c8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
12 deletions
+36
-12
cxx/tests/test_cursor_count.cpp
cxx/tests/test_cursor_count.cpp
+19
-0
src/tests/test_reverse_compare_fun.c
src/tests/test_reverse_compare_fun.c
+17
-12
No files found.
cxx/tests/test_cursor_count.cpp
View file @
d65552f3
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <assert.h>
#include <assert.h>
#include <db_cxx.h>
#include <db_cxx.h>
...
@@ -39,6 +40,23 @@ void load(Db *db, int n) {
...
@@ -39,6 +40,23 @@ void load(Db *db, int n) {
}
}
}
}
void
test_cursor_flags
(
Db
*
db
)
{
int
r
;
Dbc
*
cursor
;
r
=
db
->
cursor
(
0
,
&
cursor
,
0
);
assert
(
r
==
0
);
Dbt
key
;
key
.
set_flags
(
DB_DBT_MALLOC
);
Dbt
val
;
val
.
set_flags
(
DB_DBT_MALLOC
);
r
=
cursor
->
get
(
&
key
,
&
val
,
DB_FIRST
);
assert
(
r
==
0
);
if
(
key
.
get_data
())
free
(
key
.
get_data
());
if
(
val
.
get_data
())
free
(
val
.
get_data
());
db_recno_t
n
;
r
=
cursor
->
count
(
&
n
,
1
);
assert
(
r
==
EINVAL
);
r
=
cursor
->
count
(
&
n
,
0
);
assert
(
r
==
0
);
printf
(
"n=%d
\n
"
,
n
);
r
=
cursor
->
close
();
assert
(
r
==
0
);
}
int
my_cursor_count
(
Dbc
*
cursor
,
db_recno_t
*
count
,
Db
*
db
)
{
int
my_cursor_count
(
Dbc
*
cursor
,
db_recno_t
*
count
,
Db
*
db
)
{
int
r
;
int
r
;
Dbt
key
;
key
.
set_flags
(
DB_DBT_REALLOC
);
Dbt
key
;
key
.
set_flags
(
DB_DBT_REALLOC
);
...
@@ -275,6 +293,7 @@ int main(int argc, char *argv[]) {
...
@@ -275,6 +293,7 @@ int main(int argc, char *argv[]) {
r
=
db
.
open
(
0
,
"test.db"
,
0
,
DB_BTREE
,
DB_CREATE
,
0777
);
assert
(
r
==
0
);
r
=
db
.
open
(
0
,
"test.db"
,
0
,
DB_BTREE
,
DB_CREATE
,
0777
);
assert
(
r
==
0
);
load
(
&
db
,
10
);
load
(
&
db
,
10
);
test_cursor_flags
(
&
db
);
walk
(
&
db
,
10
);
walk
(
&
db
,
10
);
test_next_nodup
(
&
db
,
10
);
test_next_nodup
(
&
db
,
10
);
test_next_dup
(
&
db
,
10
);
test_next_dup
(
&
db
,
10
);
...
...
src/tests/test_reverse_compare_fun.c
View file @
d65552f3
...
@@ -52,8 +52,8 @@ void expect(DBC *cursor, int k, int v) {
...
@@ -52,8 +52,8 @@ void expect(DBC *cursor, int k, int v) {
free
(
val
.
data
);
free
(
val
.
data
);
}
}
void
test_reverse_compare
(
int
n
)
{
void
test_reverse_compare
(
int
n
,
int
dup_flags
)
{
if
(
verbose
)
printf
(
"test_reverse_compare:%d
\n
"
,
n
);
if
(
verbose
)
printf
(
"test_reverse_compare:%d
%d
\n
"
,
n
,
dup_flags
);
DB_ENV
*
const
null_env
=
0
;
DB_ENV
*
const
null_env
=
0
;
DB
*
db
;
DB
*
db
;
...
@@ -69,12 +69,14 @@ void test_reverse_compare(int n) {
...
@@ -69,12 +69,14 @@ void test_reverse_compare(int n) {
/* create the dup database file */
/* create the dup database file */
r
=
db_create
(
&
db
,
null_env
,
0
);
r
=
db_create
(
&
db
,
null_env
,
0
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_flags
(
db
,
0
);
r
=
db
->
set_flags
(
db
,
dup_flags
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_pagesize
(
db
,
4096
);
r
=
db
->
set_pagesize
(
db
,
4096
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_bt_compare
(
db
,
reverse_compare
);
r
=
db
->
set_bt_compare
(
db
,
reverse_compare
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_dup_compare
(
db
,
reverse_compare
);
CKERR
(
r
);
r
=
db
->
open
(
db
,
null_txn
,
fname
,
"main"
,
DB_BTREE
,
DB_CREATE
,
0666
);
r
=
db
->
open
(
db
,
null_txn
,
fname
,
"main"
,
DB_BTREE
,
DB_CREATE
,
0666
);
CKERR
(
r
);
CKERR
(
r
);
...
@@ -82,11 +84,11 @@ void test_reverse_compare(int n) {
...
@@ -82,11 +84,11 @@ void test_reverse_compare(int n) {
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
DBT
key
,
val
;
DBT
key
,
val
;
int
k
,
v
;
int
k
,
v
;
k
=
htonl
(
i
);
k
=
htonl
(
dup_flags
?
n
:
i
);
dbt_init
(
&
key
,
&
k
,
sizeof
k
);
dbt_init
(
&
key
,
&
k
,
sizeof
k
);
v
=
i
;
v
=
htonl
(
i
)
;
dbt_init
(
&
val
,
&
v
,
sizeof
v
);
dbt_init
(
&
val
,
&
v
,
sizeof
v
);
r
=
db
->
put
(
db
,
null_txn
,
&
key
,
&
val
,
0
);
r
=
db
->
put
(
db
,
null_txn
,
&
key
,
&
val
,
DB_YESOVERWRITE
);
CKERR
(
r
);
CKERR
(
r
);
}
}
...
@@ -95,12 +97,14 @@ void test_reverse_compare(int n) {
...
@@ -95,12 +97,14 @@ void test_reverse_compare(int n) {
CKERR
(
r
);
CKERR
(
r
);
r
=
db_create
(
&
db
,
null_env
,
0
);
r
=
db_create
(
&
db
,
null_env
,
0
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_flags
(
db
,
0
);
r
=
db
->
set_flags
(
db
,
dup_flags
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_pagesize
(
db
,
4096
);
r
=
db
->
set_pagesize
(
db
,
4096
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_bt_compare
(
db
,
reverse_compare
);
r
=
db
->
set_bt_compare
(
db
,
reverse_compare
);
CKERR
(
r
);
CKERR
(
r
);
r
=
db
->
set_dup_compare
(
db
,
reverse_compare
);
CKERR
(
r
);
r
=
db
->
open
(
db
,
null_txn
,
fname
,
"main"
,
DB_BTREE
,
0
,
0666
);
r
=
db
->
open
(
db
,
null_txn
,
fname
,
"main"
,
DB_BTREE
,
0
,
0666
);
CKERR
(
r
);
CKERR
(
r
);
...
@@ -108,11 +112,11 @@ void test_reverse_compare(int n) {
...
@@ -108,11 +112,11 @@ void test_reverse_compare(int n) {
for
(
i
=
n
;
i
<
2
*
n
;
i
++
)
{
for
(
i
=
n
;
i
<
2
*
n
;
i
++
)
{
DBT
key
,
val
;
DBT
key
,
val
;
int
k
,
v
;
int
k
,
v
;
k
=
htonl
(
i
);
k
=
htonl
(
dup_flags
?
n
:
i
);
dbt_init
(
&
key
,
&
k
,
sizeof
k
);
dbt_init
(
&
key
,
&
k
,
sizeof
k
);
v
=
i
;
v
=
htonl
(
i
)
;
dbt_init
(
&
val
,
&
v
,
sizeof
v
);
dbt_init
(
&
val
,
&
v
,
sizeof
v
);
r
=
db
->
put
(
db
,
null_txn
,
&
key
,
&
val
,
0
);
r
=
db
->
put
(
db
,
null_txn
,
&
key
,
&
val
,
DB_YESOVERWRITE
);
CKERR
(
r
);
CKERR
(
r
);
}
}
...
@@ -123,7 +127,7 @@ void test_reverse_compare(int n) {
...
@@ -123,7 +127,7 @@ void test_reverse_compare(int n) {
//for (i=0; i<2*n; i++)
//for (i=0; i<2*n; i++)
for
(
i
=
2
*
n
-
1
;
i
>=
0
;
i
--
)
for
(
i
=
2
*
n
-
1
;
i
>=
0
;
i
--
)
expect
(
cursor
,
htonl
(
i
),
i
);
expect
(
cursor
,
htonl
(
dup_flags
?
n
:
i
),
htonl
(
i
)
);
r
=
cursor
->
c_close
(
cursor
);
r
=
cursor
->
c_close
(
cursor
);
CKERR
(
r
);
CKERR
(
r
);
...
@@ -138,7 +142,8 @@ int main(int argc, const char *argv[]) {
...
@@ -138,7 +142,8 @@ int main(int argc, const char *argv[]) {
int
i
;
int
i
;
for
(
i
=
1
;
i
<=
(
1
<<
16
);
i
*=
2
)
{
for
(
i
=
1
;
i
<=
(
1
<<
16
);
i
*=
2
)
{
test_reverse_compare
(
i
);
test_reverse_compare
(
i
,
0
);
test_reverse_compare
(
i
,
DB_DUP
+
DB_DUPSORT
);
}
}
return
0
;
return
0
;
}
}
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