#include #include using cruft::rational; int main (void) { cruft::TAP::logger tap; { rational val { -3, -2 }; tap.expect (val.n == 3 && val.d == 2, "reduce double negatives at construction"); } { rational val { 5 }; tap.expect (val.n == 5 && val.d == 1, "scalar construction"); } { rational a { 2, 3 }; rational b { 3, 2 }; tap.expect_eq (a.inverse (), b, "inversion and equality"); } { rational val { 8, 12 }; tap.expect_eq (val.reduced (), rational { 2, 3 }, "factorisation"); } return tap.status (); }