提交 2e0eac0f 编写于 作者: K Khaled Al-Hassanieh

Unit tests for index API's - 2

上级 cb9878c6
......@@ -1027,46 +1027,36 @@ int32_t store_i64i64i64( account_name scope, table_name table, account_name bta,
* @return 1 if the record was updated, 0 if no record with key was found
*/
int32_t update_i64i64i64( account_name scope, table_name table, account_name bta, const void* data, uint32_t len );
///@} dbi64i64i64
int32_t db_store_i64(account_name scope, table_name table, account_name payer, uint64_t id, const void* data, uint32_t len);
void db_update_i64(int32_t iterator, account_name payer, const void* data, uint32_t len);
void db_remove_i64(int32_t iterator);
int32_t db_get_i64(int32_t iterator, const void* data, uint32_t len);
int32_t db_next_i64(int32_t iterator, uint64_t* primary);
int32_t db_previous_i64(int32_t iterator, uint64_t* primary);
int32_t db_find_i64(account_name code, account_name scope, table_name table, uint64_t id);
int32_t db_lowerbound_i64( account_name code, account_name scope, table_name table, uint64_t id);
int32_t db_upperbound_i64( account_name code, account_name scope, table_name table, uint64_t id);
int32_t db_idx64_store(account_name scope, table_name table, account_name payer, uint64_t id, const uint64_t* secondary);
void db_idx64_update(int32_t iterator, account_name payer, const uint64_t* secondary);
void db_idx64_remove(int32_t iterator);
int32_t db_idx64_next(int32_t iterator, uint64_t* primary);
int32_t db_idx64_previous(int32_t iterator, uint64_t* primary);
int32_t db_idx64_find_primary(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t primary);
int32_t db_idx64_find_secondary(account_name code, account_name scope, table_name table, const uint64_t* secondary, uint64_t* primary);
int32_t db_idx64_lowerbound(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t* primary);
int32_t db_idx64_upperbound(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t* primary);
int32_t db_idx128_store(account_name scope, table_name table, account_name payer, uint64_t id, const uint128_t* secondary);
void db_idx128_update(int32_t iterator, account_name payer, const uint128_t* secondary);
void db_idx128_remove(int32_t iterator);
int32_t db_idx128_next(int32_t iterator, uint64_t* primary);
int32_t db_idx128_previous(int32_t iterator, uint64_t* primary);
int32_t db_idx128_find_primary(account_name code, account_name scope, table_name table, uint128_t* secondary, uint64_t primary);
int32_t db_idx128_find_secondary(account_name code, account_name scope, table_name table, const uint128_t* secondary, uint64_t* primary);
int32_t db_idx128_lowerbound(account_name code, account_name scope, table_name table, uint128_t* secondary, uint64_t* primary);
int32_t db_idx128_upperbound(account_name code, account_name scope, table_name table, uint128_t* secondary, uint64_t* primary);
int32_t db_store_i64(account_name scope, table_name table, account_name payer, uint64_t id, const void* data, uint32_t len);
void db_update_i64(int32_t iterator, account_name payer, const void* data, uint32_t len);
void db_remove_i64(int32_t iterator);
int32_t db_get_i64(int32_t iterator, const void* data, uint32_t len);
int32_t db_next_i64(int32_t iterator, uint64_t* primary);
int32_t db_previous_i64(int32_t iterator, uint64_t* primary);
int32_t db_find_i64(account_name code, account_name scope, table_name table, uint64_t id);
int32_t db_lowerbound_i64( account_name code, account_name scope, table_name table, uint64_t id);
int32_t db_upperbound_i64( account_name code, account_name scope, table_name table, uint64_t id);
/*
void db_update_i64( int iterator, uint64_t payer, char* buffer, size_t buffer_size );
int db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
int db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
int db_get_i64( int iterator, char* buffer, size_t buffer_size );
void db_remove_i64( int iterator );
int db_next_i64( int iterator, uint64_t* pk );
int db_previous_i64( int iterator, uint64_t* pk );
*/
int32_t db_idx64_store(account_name scope, table_name table, account_name payer, uint64_t id, const uint64_t* secondary);
void db_idx64_update(int32_t iterator, account_name payer, const uint64_t* secondary);
void db_idx64_remove(int32_t iterator);
int32_t db_idx64_next(int32_t iterator, uint64_t* primary);
int32_t db_idx64_previous(int32_t iterator, uint64_t* primary);
int32_t db_idx64_find_primary(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t primary);
int32_t db_idx64_find_secondary(account_name code, account_name scope, table_name table, const uint64_t* secondary, uint64_t* primary);
int32_t db_idx64_lowerbound(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t* primary);
int32_t db_idx64_upperbound(account_name code, account_name scope, table_name table, uint64_t* secondary, uint64_t* primary);
int db_idx128_next(int iterator, uint64_t* primary);
int db_idx128_prev(int iterator, uint64_t* primary);
int db_idx128_find_primary(uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t primary);
int db_idx128_find_secondary(uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary);
int db_idx128_lowerbound(uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary);
int db_idx128_upperbound(uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary);
void db_idx128_remove(int iterator);
void db_idx128_update(int iterator, uint64_t payer, const uint128_t* secondary);
///@} dbi64i64i64
}
......@@ -14,36 +14,6 @@
#include <eosiolib/db.h>
extern "C" {
/*
int db_store_i64( uint64_t scope, uint64_t table, uint64_t payer, uint64_t id, char* buffer, size_t buffer_size );
void db_update_i64( int iterator, uint64_t payer, char* buffer, size_t buffer_size );
int db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
int db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
int db_get_i64( int iterator, char* buffer, size_t buffer_size );
void db_remove_i64( int iterator );
int db_next_i64( int iterator, uint64_t* pk );
int db_previous_i64( int iterator, uint64_t* pk );
int db_idx64_next( int iterator, uint64_t* primary );
int db_idx64_prev( int iterator, uint64_t* primary );
int db_idx64_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t primary );
int db_idx64_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t* primary );
int db_idx64_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t* primary );
int db_idx64_upperbound( uint64_t code, uint64_t scope, uint64_t table, uint64_t* secondary, uint64_t* primary );
void db_idx64_remove( int iterator );
void db_idx64_update( int iterator, uint64_t payer, const uint64_t* secondary );
int db_idx128_next( int iterator, uint64_t* primary );
int db_idx128_prev( int iterator, uint64_t* primary );
int db_idx128_find_primary( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t primary );
int db_idx128_find_secondary( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary );
int db_idx128_lowerbound( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary );
int db_idx128_upperbound( uint64_t code, uint64_t scope, uint64_t table, uint128_t* secondary, uint64_t* primary );
void db_idx128_remove( int iterator );
void db_idx128_update( int iterator, uint64_t payer, const uint128_t* secondary );
*/
}
namespace eosio {
......@@ -64,7 +34,7 @@ struct secondary_iterator<uint64_t> {
template<>
struct secondary_iterator<uint128_t> {
static int db_idx_next( int iterator, uint64_t* primary ) { return db_idx128_next( iterator, primary ); }
static int db_idx_prev( int iterator, uint64_t* primary ) { return db_idx128_prev( iterator, primary ); }
static int db_idx_prev( int iterator, uint64_t* primary ) { return db_idx128_previous( iterator, primary ); }
static void db_idx_remove( int iterator ) { db_idx128_remove( iterator ); }
};
......
......@@ -1557,76 +1557,82 @@ void test_db::primary_i64_general()
db_store_i64(current_receiver(), table1, current_receiver(), N(charlie), "charlie's info", strlen("charlies's info"));
db_store_i64(current_receiver(), table1, current_receiver(), N(allyson), "allyson's info", strlen("allyson's info"));
// find
{
uint64_t prim = 0;
int itr_next = db_next_i64(alice_itr, &prim);
int itr_next_expected = db_find_i64(current_receiver(), current_receiver(), table1, N(allyson));
assert(itr_next == itr_next_expected);
assert(prim == N(allyson));
eos_assert(itr_next == itr_next_expected && prim == N(allyson), "primary_i64_general - db_find_i64" );
itr_next = db_next_i64(itr_next, &prim);
itr_next_expected = db_find_i64(current_receiver(), current_receiver(), table1, N(bob));
assert(itr_next == itr_next_expected);
assert(prim == N(bob));
eos_assert(itr_next == itr_next_expected && prim == N(bob), "primary_i64_general - db_next_i64");
}
// next
{
int charlie_itr = db_find_i64(current_receiver(), current_receiver(), table1, N(charlie));
// nothing after charlie
uint64_t prim = 0;
int end_itr = db_next_i64(charlie_itr, &prim);
assert(end_itr == -1);
eos_assert(end_itr == -1, "primary_i64_general - db_next_i64");
// prim didn't change
assert(prim == 0);
eos_assert(prim == 0, "primary_i64_general - db_next_i64");
}
// previous
{
int charlie_itr = db_find_i64(current_receiver(), current_receiver(), table1, N(charlie));
uint64_t prim = 0;
int itr_prev = db_previous_i64(charlie_itr, &prim);
int itr_prev_expected = db_find_i64(current_receiver(), current_receiver(), table1, N(bob));
assert(itr_prev == itr_prev_expected);
assert(prim == N(bob));
eos_assert(itr_prev == itr_prev_expected && prim == N(bob), "primary_i64_general - db_previous_i64");
itr_prev = db_previous_i64(itr_prev, &prim);
itr_prev_expected = db_find_i64(current_receiver(), current_receiver(), table1, N(allyson));
assert(itr_prev == itr_prev_expected);
assert(prim == N(allyson));
eos_assert(itr_prev == itr_prev_expected && prim == N(allyson), "primary_i64_general - db_previous_i64");
itr_prev = db_previous_i64(itr_prev, &prim);
itr_prev_expected = db_find_i64(current_receiver(), current_receiver(), table1, N(alice));
assert(itr_prev == itr_prev_expected);
assert(prim == N(alice));
eos_assert(itr_prev == itr_prev_expected && prim == N(alice), "primary_i64_general - db_previous_i64");
itr_prev = db_previous_i64(itr_prev, &prim);
itr_prev_expected = -1;
assert(itr_prev == itr_prev_expected);
assert(prim == N(alice));
eos_assert(itr_prev == itr_prev_expected && prim == N(alice), "primary_i64_general - db_previous_i64");
}
// remove
{
int itr = db_find_i64(current_receiver(), current_receiver(), table1, N(alice));
assert(itr != -1);
eos_assert(itr != -1, "primary_i64_general - db_find_i64");
db_remove_i64(itr);
itr = db_find_i64(current_receiver(), current_receiver(), table1, N(alice));
assert(itr == -1);
eos_assert(itr == -1, "primary_i64_general - db_find_i64");
}
// get
{
int itr = db_find_i64(current_receiver(), current_receiver(), table1, N(bob));
assert(itr != -1);
eos_assert(itr != -1, "");
int buffer_len = 5;
char value[50];
auto len = db_get_i64(itr, value, buffer_len);
value[buffer_len] = '\0';
std::string s(value);
assert(len == strlen("bob's info"));
assert(s == "bob's");
eos_assert(len == strlen("bob's info"), "primary_i64_general - db_get_i64");
eos_assert(s == "bob's", "primary_i64_general - db_get_i64");
buffer_len = 20;
db_get_i64(itr, value, buffer_len);
value[buffer_len] = '\0';
std::string sfull(value);
assert(sfull == "bob's info");
eos_assert(sfull == "bob's info", "primary_i64_general - db_get_i64");
}
// update
{
int itr = db_find_i64(current_receiver(), current_receiver(), table1, N(bob));
assert(itr != -1);
eos_assert(itr != -1, "");
const char* new_value = "bob's new info";
int new_value_len = strlen(new_value);
db_update_i64(itr, current_receiver(), new_value, new_value_len);
......@@ -1634,9 +1640,8 @@ void test_db::primary_i64_general()
auto len = db_get_i64(itr, ret_value, new_value_len);
ret_value[new_value_len] = '\0';
std::string sret(ret_value);
assert(sret == "bob's new info");
eos_assert(sret == "bob's new info", "primary_i64_general - db_update_i64");
}
}
void test_db::primary_i64_lowerbound()
......@@ -1648,64 +1653,66 @@ void test_db::primary_i64_lowerbound()
db_store_i64(current_receiver(), table, current_receiver(), N(emily), "emily's info", strlen("emily's info"));
db_store_i64(current_receiver(), table, current_receiver(), N(allyson), "allyson's info", strlen("allyson's info"));
db_store_i64(current_receiver(), table, current_receiver(), N(joe), "nothing here", strlen("nothing here"));
const std::string err = "primary_i64_lowerbound";
{
int lb = db_lowerbound_i64(current_receiver(), current_receiver(), table, N(alice));
assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(alice)));
eos_assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(alice)), err.c_str());
}
{
int lb = db_lowerbound_i64(current_receiver(), current_receiver(), table, N(billy));
assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(bob)));
eos_assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(bob)), err.c_str());
}
{
int lb = db_lowerbound_i64(current_receiver(), current_receiver(), table, N(frank));
assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(joe)));
eos_assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(joe)), err.c_str());
}
{
int lb = db_lowerbound_i64(current_receiver(), current_receiver(), table, N(joe));
assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(joe)));
eos_assert(lb == db_find_i64(current_receiver(), current_receiver(), table, N(joe)), err.c_str());
}
{
int lb = db_lowerbound_i64(current_receiver(), current_receiver(), table, N(kevin));
assert(lb == -1);
eos_assert(lb == -1, err.c_str());
}
}
void test_db::primary_i64_upperbound()
{
auto table = N(mytable);
const std::string err = "primary_i64_upperbound";
{
int ub = db_upperbound_i64(current_receiver(), current_receiver(), table, N(alice));
assert(ub == db_find_i64(current_receiver(), current_receiver(), table, N(allyson)));
eos_assert(ub == db_find_i64(current_receiver(), current_receiver(), table, N(allyson)), err.c_str());
}
{
int ub = db_upperbound_i64(current_receiver(), current_receiver(), table, N(billy));
assert(ub == db_find_i64(current_receiver(), current_receiver(), table, N(bob)));
eos_assert(ub == db_find_i64(current_receiver(), current_receiver(), table, N(bob)), err.c_str());
}
{
int ub = db_upperbound_i64(current_receiver(), current_receiver(), table, N(frank));
assert(ub == db_find_i64(current_receiver(), current_receiver(), table, N(joe)));
eos_assert(ub == db_find_i64(current_receiver(), current_receiver(), table, N(joe)), err.c_str());
}
{
int ub = db_upperbound_i64(current_receiver(), current_receiver(), table, N(joe));
assert(ub == -1);
eos_assert(ub == -1, err.c_str());
}
{
int ub = db_upperbound_i64(current_receiver(), current_receiver(), table, N(kevin));
assert(ub == -1);
eos_assert(ub == -1, err.c_str());
}
}
void test_db::idx64_general()
{
auto table = N(myindextable);
const auto table = N(myindextable);
typedef uint64_t secondary_type;
struct record {
uint64_t ssn;
secondary_type name;
record(uint64_t s, const secondary_type& n): ssn(s), name(n) { }
};
record records[] = {{265, N(alice)},
......@@ -1725,78 +1732,62 @@ void test_db::idx64_general()
{
secondary_type sec = 0;
int itr = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec, 999);
assert(itr == -1);
assert(sec == 0);
eos_assert(itr == -1 && sec == 0, "idx64_general - db_idx64_find_primary");
itr = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec, 110);
assert(itr != -1);
assert(sec == N(joe));
eos_assert(itr != -1 && sec == N(joe), "idx64_general - db_idx64_find_primary");
uint64_t prim_next = 0;
int itr_next = db_idx64_next(itr, &prim_next);
assert(itr_next == -1);
assert(prim_next == 0);
eos_assert(itr_next == -1 && prim_next == 0, "idx64_general - db_idx64_find_primary");
}
// iterate forward starting with charlie
{
secondary_type sec = 0;
int itr = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec, 234);
assert(itr != -1);
assert(sec == N(charlie));
eos_assert(itr != -1 && sec == N(charlie), "idx64_general - db_idx64_find_primary");
uint64_t prim_next = 0;
int itr_next = db_idx64_next(itr, &prim_next);
assert(itr_next != -1);
assert(prim_next == 976);
eos_assert(itr_next != -1 && prim_next == 976, "idx64_general - db_idx64_next");
secondary_type sec_next = 0;
int itr_next_expected = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec_next, prim_next);
assert(itr_next == itr_next_expected);
assert(sec_next == N(emily));
eos_assert(itr_next == itr_next_expected && sec_next == N(emily), "idx64_general - db_idx64_next");
itr_next = db_idx64_next(itr_next, &prim_next);
assert(itr_next != -1);
assert(prim_next == 110);
eos_assert(itr_next != -1 && prim_next == 110, "idx64_general - db_idx64_next");
itr_next_expected = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec_next, prim_next);
assert(itr_next == itr_next_expected);
assert(sec_next == N(joe));
eos_assert(itr_next == itr_next_expected && sec_next == N(joe), "idx64_general - db_idx64_next");
itr_next = db_idx64_next(itr_next, &prim_next);
assert(itr_next == -1);
assert(prim_next == 110);
eos_assert(itr_next == -1 && prim_next == 110, "idx64_general - db_idx64_next");
}
// iterate backward staring with second bob
{
secondary_type sec = 0;
int itr = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec, 781);
assert(itr != -1);
assert(sec == N(bob));
eos_assert(itr != -1 && sec == N(bob), "idx64_general - db_idx64_find_primary");
uint64_t prim_prev = 0;
int itr_prev = db_idx64_previous(itr, &prim_prev);
assert(itr_prev != -1);
assert(prim_prev == 540);
eos_assert(itr_prev != -1 && prim_prev == 540, "idx64_general - db_idx64_previous");
secondary_type sec_prev = 0;
int itr_prev_expected = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec_prev, prim_prev);
assert(itr_prev == itr_prev_expected);
assert(sec_prev == N(bob));
eos_assert(itr_prev == itr_prev_expected && sec_prev == N(bob), "idx64_general - db_idx64_previous");
itr_prev = db_idx64_previous(itr_prev, &prim_prev);
assert(itr_prev != -1);
assert(prim_prev == 650);
eos_assert(itr_prev != -1 && prim_prev == 650, "idx64_general - db_idx64_previous");
itr_prev_expected = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec_prev, prim_prev);
assert(itr_prev == itr_prev_expected);
assert(sec_prev == N(allyson));
eos_assert(itr_prev == itr_prev_expected && sec_prev == N(allyson), "idx64_general - db_idx64_previous");
itr_prev = db_idx64_previous(itr_prev, &prim_prev);
assert(itr_prev != -1);
assert(prim_prev == 265);
eos_assert(itr_prev != -1 && prim_prev == 265, "idx64_general - db_idx64_previous");
itr_prev_expected = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec_prev, prim_prev);
assert(itr_prev == itr_prev_expected);
assert(sec_prev == N(alice));
eos_assert(itr_prev == itr_prev_expected && sec_prev == N(alice), "idx64_general - db_idx64_previous");
itr_prev = db_idx64_previous(itr_prev, &prim_prev);
assert(itr_prev == -1);
assert(prim_prev == 265);
eos_assert(itr_prev == -1 && prim_prev == 265, "idx64_general - db_idx64_previous");
}
// find_secondary
......@@ -1804,18 +1795,15 @@ void test_db::idx64_general()
uint64_t prim = 0;
auto sec = N(bob);
int itr = db_idx64_find_secondary(current_receiver(), current_receiver(), table, &sec, &prim);
assert(itr != -1);
assert(prim == 540);
eos_assert(itr != -1 && prim == 540, "idx64_general - db_idx64_find_secondary");
sec = N(emily);
itr = db_idx64_find_secondary(current_receiver(), current_receiver(), table, &sec, &prim);
assert(itr != -1);
assert(prim == 976);
eos_assert(itr != -1 && prim == 976, "idx64_general - db_idx64_find_secondary");
sec = N(frank);
itr = db_idx64_find_secondary(current_receiver(), current_receiver(), table, &sec, &prim);
assert(itr == -1);
assert(prim == 976);
eos_assert(itr == -1 && prim == 976, "idx64_general - db_idx64_find_secondary");
}
// update and remove
......@@ -1827,20 +1815,85 @@ void test_db::idx64_general()
db_idx64_update(itr, current_receiver(), &new_name);
secondary_type sec = 0;
int sec_itr = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec, ssn);
assert(sec_itr == itr);
assert(sec == new_name);
eos_assert(sec_itr == itr && sec == new_name, "idx64_general - db_idx64_update");
db_idx64_remove(itr);
int itrf = db_idx64_find_primary(current_receiver(), current_receiver(), table, &sec, ssn);
assert(itrf == -1);
eos_assert(itrf == -1, "idx64_general - db_idx64_remove");
}
}
void test_db::idx64_lowerbound()
{
const auto table = N(myindextable);
typedef uint64_t secondary_type;
const std::string err = "idx64_lowerbound";
{
secondary_type lb_sec = N(alice);
uint64_t lb_prim = 0;
const uint64_t ssn = 265;
int lb = db_idx64_lowerbound(current_receiver(), current_receiver(), table, &lb_sec, &lb_prim);
eos_assert(lb_prim == ssn && lb_sec == N(alice), err.c_str());
eos_assert(lb == db_idx64_find_primary(current_receiver(), current_receiver(), table, &lb_sec, ssn), err.c_str());
}
{
secondary_type lb_sec = N(billy);
uint64_t lb_prim = 0;
const uint64_t ssn = 540;
int lb = db_idx64_lowerbound(current_receiver(), current_receiver(), table, &lb_sec, &lb_prim);
eos_assert(lb_prim == ssn && lb_sec == N(bob), err.c_str());
eos_assert(lb == db_idx64_find_primary(current_receiver(), current_receiver(), table, &lb_sec, ssn), err.c_str());
}
{
secondary_type lb_sec = N(joe);
uint64_t lb_prim = 0;
const uint64_t ssn = 110;
int lb = db_idx64_lowerbound(current_receiver(), current_receiver(), table, &lb_sec, &lb_prim);
eos_assert(lb_prim == ssn && lb_sec == N(joe), err.c_str());
eos_assert(lb == db_idx64_find_primary(current_receiver(), current_receiver(), table, &lb_sec, ssn), err.c_str());
}
{
secondary_type lb_sec = N(kevin);
uint64_t lb_prim = 0;
int lb = db_idx64_lowerbound(current_receiver(), current_receiver(), table, &lb_sec, &lb_prim);
eos_assert(lb_prim == 0 && lb_sec == N(kevin), err.c_str());
eos_assert(lb == -1, "");
}
}
void test_db::idx64_upperbound()
{
const auto table = N(myindextable);
typedef uint64_t secondary_type;
const std::string err = "idx64_upperbound";
{
secondary_type ub_sec = N(alice);
uint64_t ub_prim = 0;
const uint64_t alice_ssn = 265, allyson_ssn = 650;
int ub = db_idx64_upperbound(current_receiver(), current_receiver(), table, &ub_sec, &ub_prim);
eos_assert(ub_prim == allyson_ssn && ub_sec == N(allyson), "");
eos_assert(ub == db_idx64_find_primary(current_receiver(), current_receiver(), table, &ub_sec, allyson_ssn), err.c_str());
}
{
secondary_type ub_sec = N(billy);
uint64_t ub_prim = 0;
const uint64_t bob_ssn = 540;
int ub = db_idx64_upperbound(current_receiver(), current_receiver(), table, &ub_sec, &ub_prim);
eos_assert(ub_prim == bob_ssn && ub_sec == N(bob), "");
eos_assert(ub == db_idx64_find_primary(current_receiver(), current_receiver(), table, &ub_sec, bob_ssn), err.c_str());
}
{
secondary_type ub_sec = N(joe);
uint64_t ub_prim = 0;
const uint64_t ssn = 110;
int ub = db_idx64_upperbound(current_receiver(), current_receiver(), table, &ub_sec, &ub_prim);
eos_assert(ub_prim == 0 && ub_sec == N(joe), err.c_str());
eos_assert(ub == -1, err.c_str());
}
{
secondary_type ub_sec = N(kevin);
uint64_t ub_prim = 0;
int ub = db_idx64_upperbound(current_receiver(), current_receiver(), table, &ub_sec, &ub_prim);
eos_assert(ub_prim == 0 && ub_sec == N(kevin), err.c_str());
eos_assert(ub == -1, err.c_str());
}
}
......@@ -830,7 +830,6 @@ BOOST_FIXTURE_TEST_CASE( check_table_maximum, tester ) try {
} FC_LOG_AND_RETHROW()
#endif
#if 1
BOOST_FIXTURE_TEST_CASE( test_db, tester ) try {
produce_blocks(2);
......@@ -921,6 +920,6 @@ BOOST_FIXTURE_TEST_CASE( test_db, tester ) try {
}
} FC_LOG_AND_RETHROW() /// test_db
#endif
BOOST_AUTO_TEST_SUITE_END()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册