mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
add boundary tests. addresses #121
git-svn-id: file:///svn/tokudb@940 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
bab5a29155
commit
bacd9f5bdf
1 changed files with 19 additions and 12 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <db.h>
|
||||
|
@ -78,19 +79,21 @@ void expect_cursor_set(DBC *cursor, int k, int expectv) {
|
|||
assert(expectv == vv);
|
||||
}
|
||||
|
||||
void expect_cursor_get(DBC *cursor, int expectk, int expectv, int op) {
|
||||
int expect_cursor_get(DBC *cursor, int expectk, int expectv, int op) {
|
||||
DBT key, val;
|
||||
int r = cursor->c_get(cursor, dbt_init_zero(&key), dbt_init_zero(&val), op);
|
||||
assert(r == 0);
|
||||
assert(key.size == sizeof expectk);
|
||||
int kk;
|
||||
memcpy(&kk, key.data, key.size);
|
||||
assert(val.size == sizeof expectv);
|
||||
int vv;
|
||||
memcpy(&vv, val.data, val.size);
|
||||
if (kk != expectk || vv != expectv) printf("expect key %d got %d - %d %d\n", htonl(expectk), htonl(kk), htonl(expectv), htonl(vv));
|
||||
assert(kk == expectk);
|
||||
assert(vv == expectv);
|
||||
if (r == 0) {
|
||||
assert(key.size == sizeof expectk);
|
||||
int kk;
|
||||
memcpy(&kk, key.data, key.size);
|
||||
assert(val.size == sizeof expectv);
|
||||
int vv;
|
||||
memcpy(&vv, val.data, val.size);
|
||||
if (kk != expectk || vv != expectv) printf("expect key %d got %d - %d %d\n", htonl(expectk), htonl(kk), htonl(expectv), htonl(vv));
|
||||
assert(kk == expectk);
|
||||
assert(vv == expectv);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void test_dup_next(int n, int dup_mode) {
|
||||
|
@ -124,12 +127,16 @@ void test_dup_next(int n, int dup_mode) {
|
|||
DBC *cursor;
|
||||
r = db->cursor(db, null_txn, &cursor, 0); assert(r == 0);
|
||||
|
||||
r = expect_cursor_get(cursor, htonl(1), htonl(0), DB_NEXT_DUP); assert(r == EINVAL);
|
||||
|
||||
expect_cursor_set(cursor, htonl(1), htonl(0));
|
||||
|
||||
for (i=1; i<n; i++) {
|
||||
expect_cursor_get(cursor, htonl(1), htonl(i), DB_NEXT_DUP);
|
||||
r = expect_cursor_get(cursor, htonl(1), htonl(i), DB_NEXT_DUP); assert(r == 0);
|
||||
}
|
||||
|
||||
r = expect_cursor_get(cursor, htonl(1), htonl(i), DB_NEXT_DUP); assert(r == DB_NOTFOUND);
|
||||
|
||||
r = cursor->c_close(cursor); assert(r == 0);
|
||||
|
||||
r = db->close(db, 0); assert(r == 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue