libcruft-util/test/map/fixed.cpp

26 lines
609 B
C++
Raw Normal View History

#include <cruft/util/tap.hpp>
2019-03-28 14:27:34 +11:00
#include <cruft/util/map/fixed.hpp>
2019-03-28 14:27:34 +11:00
int main ()
{
cruft::TAP::logger tap;
cruft::map::fixed<4, int,std::string> map;
auto const [pos, success] = map.insert ({ 0, "zero" });
tap.expect (success, "map insertion reports success");
tap.expect_eq (pos->second, "zero", "inserted value is equal");
map.insert ({ 1, "one" });
map.insert ({ 2, "two" });
map.insert ({ 3, "three" });
tap.expect_throw<std::bad_alloc> (
[&] () { map.insert ({ 4, "four" }); },
"over-allocation throws bad_alloc"
);
return tap.status ();
}