2017-11-22 16:49:37 +11:00
|
|
|
#include "../tap.hpp"
|
2017-05-29 17:21:11 +10:00
|
|
|
|
2017-11-22 16:49:37 +11:00
|
|
|
#include "../typeidx.hpp"
|
2017-05-29 17:21:11 +10:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main (int, char**)
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::TAP::logger tap;
|
2017-05-29 17:21:11 +10:00
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
tap.expect_eq (cruft::typeidx<int> (), cruft::typeidx<int> (), "equality for int");
|
|
|
|
tap.expect_eq (cruft::typeidx<float> (), cruft::typeidx<float> (), "equality for float");
|
|
|
|
tap.expect_neq (cruft::typeidx<int> (), cruft::typeidx<float> (), "inequality for int/float");
|
2017-05-29 17:21:11 +10:00
|
|
|
|
2019-09-04 08:06:29 +10:00
|
|
|
struct tag_a {};
|
|
|
|
struct tag_b {};
|
|
|
|
|
|
|
|
// Register an unequal number of types (that don't include f32) to each
|
|
|
|
// tag before we get to testing in the expectation that will force f32 to
|
|
|
|
// be different in the following tests.
|
|
|
|
cruft::typeidx<i16, tag_a> ();
|
|
|
|
cruft::typeidx<i32, tag_a> ();
|
|
|
|
cruft::typeidx<i08, tag_b> ();
|
|
|
|
cruft::typeidx<i16, tag_b> ();
|
|
|
|
cruft::typeidx<i32, tag_b> ();
|
|
|
|
|
|
|
|
// We test using f32 rather than int because we're pretty sure it's not
|
|
|
|
// going to have the first index (and hence give us false results) given
|
|
|
|
// int was registered first just above here.
|
|
|
|
tap.expect_neq (
|
|
|
|
cruft::typeidx<f32,tag_a> (),
|
|
|
|
cruft::typeidx<f32> (),
|
|
|
|
"inequality for f32/f32, tag_a"
|
|
|
|
);
|
|
|
|
|
|
|
|
tap.expect_neq (
|
|
|
|
cruft::typeidx<f32,tag_a> (),
|
|
|
|
cruft::typeidx<f32,tag_b> (),
|
|
|
|
"inequality for f32/f32, tag_a/tag_b"
|
|
|
|
);
|
|
|
|
|
|
|
|
tap.expect_neq (
|
|
|
|
cruft::typeidx<f32,tag_a> (),
|
|
|
|
cruft::typeidx<f32, tag_b> (),
|
|
|
|
"equality for f32/f32, tag_a/tag_a"
|
|
|
|
);
|
|
|
|
|
2017-05-29 17:21:11 +10:00
|
|
|
return tap.status ();
|
|
|
|
}
|