expand tests to time_t indexes, found bug in our keyconv!
This commit is contained in:
parent
fd9e5841bc
commit
f977301e94
|
@ -80,13 +80,24 @@ inline std::string keyConv(const std::string& t)
|
|||
template<>
|
||||
inline std::string keyConv(const uint32_t& t)
|
||||
{
|
||||
return std::string((char*)&t, sizeof(4));
|
||||
return std::string((char*)&t, sizeof(t));
|
||||
}
|
||||
template<>
|
||||
inline std::string keyConv(const int32_t& t)
|
||||
{
|
||||
return std::string((char*)&t, sizeof(4));
|
||||
return std::string((char*)&t, sizeof(t));
|
||||
}
|
||||
template<>
|
||||
inline std::string keyConv(const uint64_t& t)
|
||||
{
|
||||
return std::string((char*)&t, sizeof(t));
|
||||
}
|
||||
template<>
|
||||
inline std::string keyConv(const int64_t& t)
|
||||
{
|
||||
return std::string((char*)&t, sizeof(t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** This is a struct that implements index operations, but
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <time.h>
|
||||
#include "catch2/catch.hpp"
|
||||
#include "lmdb-typed.hh"
|
||||
|
||||
|
@ -9,21 +9,22 @@ struct Member
|
|||
{
|
||||
std::string firstName;
|
||||
std::string lastName;
|
||||
time_t enrolled;
|
||||
};
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, Member& g, const unsigned int version)
|
||||
{
|
||||
ar & g.firstName & g.lastName;
|
||||
ar & g.firstName & g.lastName & g.enrolled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_CASE("Basic typed tests", "[basictyped]") {
|
||||
unlink("./tests-typed");
|
||||
typedef TypedDBI<Member,
|
||||
index_on<Member, string, &Member::firstName>,
|
||||
index_on<Member, string, &Member::lastName> > tmembers_t;
|
||||
index_on<Member, string, &Member::firstName>,
|
||||
index_on<Member, string, &Member::lastName>,
|
||||
index_on<Member, time_t, &Member::enrolled>
|
||||
> tmembers_t;
|
||||
|
||||
auto tmembers = tmembers_t(getMDBEnv("./tests-typed", MDB_CREATE | MDB_NOSUBDIR, 0600), "members");
|
||||
|
||||
|
@ -34,6 +35,7 @@ TEST_CASE("Basic typed tests", "[basictyped]") {
|
|||
txn.put(m);
|
||||
m.firstName="bertus";
|
||||
m.lastName = "testperson";
|
||||
m.enrolled = time(0);
|
||||
txn.put(m);
|
||||
|
||||
m.firstName = "other";
|
||||
|
|
Loading…
Reference in New Issue