Changeset View
Changeset View
Standalone View
Standalone View
src/test/dbwrapper_tests.cpp
Show First 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | struct StringContentsSerializer { | ||||
StringContentsSerializer &operator+=(const std::string &s) { | StringContentsSerializer &operator+=(const std::string &s) { | ||||
str += s; | str += s; | ||||
return *this; | return *this; | ||||
} | } | ||||
StringContentsSerializer &operator+=(const StringContentsSerializer &s) { | StringContentsSerializer &operator+=(const StringContentsSerializer &s) { | ||||
return *this += s.str; | return *this += s.str; | ||||
} | } | ||||
ADD_SERIALIZE_METHODS; | template <typename Stream> void Serialize(Stream &s) const { | ||||
for (size_t i = 0; i < str.size(); i++) { | |||||
s << str[i]; | |||||
} | |||||
} | |||||
template <typename Stream, typename Operation> | template <typename Stream> void Unserialize(Stream &s) { | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
if (ser_action.ForRead()) { | |||||
str.clear(); | str.clear(); | ||||
char c = 0; | char c = 0; | ||||
while (true) { | while (true) { | ||||
try { | try { | ||||
READWRITE(c); | s >> c; | ||||
str.push_back(c); | str.push_back(c); | ||||
} catch (const std::ios_base::failure &) { | } catch (const std::ios_base::failure &) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} else { | |||||
for (size_t i = 0; i < str.size(); i++) { | |||||
READWRITE(str[i]); | |||||
} | |||||
} | |||||
} | } | ||||
}; | }; | ||||
BOOST_AUTO_TEST_CASE(iterator_string_ordering) { | BOOST_AUTO_TEST_CASE(iterator_string_ordering) { | ||||
char buf[10]; | char buf[10]; | ||||
fs::path ph = GetDataDir() / "iterator_string_ordering"; | fs::path ph = GetDataDir() / "iterator_string_ordering"; | ||||
CDBWrapper dbw(ph, (1 << 20), true, false, false); | CDBWrapper dbw(ph, (1 << 20), true, false, false); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |