#include #include int main (int, char**) { cruft::TAP::logger tap; // Check casting works between intergral and floating formats { cruft::srgba<4,float> f {1.f}; cruft::srgba<4,uint8_t> u {255}; tap.expect_eq (f.cast (), u, "cast float to u8"); tap.expect_eq (u.cast (), f, "cast u8 to float"); } { cruft::srgba3f white {1, 1, 1}; cruft::srgba3f black {0, 0, 0}; cruft::srgba3f percent_50 { 0.735359f, 0.735356f, 0.735357f }; tap.expect (max (scale_luminance (white, 1.f) - white) < 1e-5f, "unit luminance scaling for white"); tap.expect (max (scale_luminance (white, 0.f) - black) < 1e-5f, "zero luminance scaling for white"); tap.expect (max (scale_luminance (white, .5f) - percent_50) < 1e-5f, "half luminance scaling for white"); } return tap.status (); }