libcruft-util/test/strongdef.cpp
Danny Robson 279af4c796 strongdef: significantly tighten restrictions on usage
It turns out that equality in particular was triggering implicit
construction of strongdef types. We make it much harder for these types
to spontaneously emerge.
2018-06-22 17:41:56 +10:00

24 lines
758 B
C++

#include "tap.hpp"
#include "strongdef.hpp"
using util::strongdef;
int
main (void)
{
util::TAP::logger tap;
// These tests are less about functional testing, and more about link testing.
strongdef<unsigned,void> fortytwo (42u);
tap.expect_eq (fortytwo.data, 42u, "raw data equality");
tap.expect_eq (fortytwo, decltype(fortytwo) (42u), "passthrough equality");
// Ensure numeric_limits has been specialised. Unknown types are default initialised, so check if we get non-zero for maximum.
tap.expect_eq (std::numeric_limits<decltype(fortytwo)>::max (),
std::numeric_limits<decltype(fortytwo)::value_type>::max (),
"numeric_limits has been specialised");
return tap.status ();
}