From 4f19a35b7dde335d0cba2c36d8a19f47e4bab516 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 6 Feb 2015 16:35:40 +1100 Subject: [PATCH] fixed: add trivial tests --- test/Makefile.am | 1 + test/fixed.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/fixed.cpp diff --git a/test/Makefile.am b/test/Makefile.am index b1dfc1b1..d7c3bf6d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -7,6 +7,7 @@ TEST_BIN = \ bitwise \ checksum \ colour \ + fixed \ float \ hton \ ip \ diff --git a/test/fixed.cpp b/test/fixed.cpp new file mode 100644 index 00000000..a21ea649 --- /dev/null +++ b/test/fixed.cpp @@ -0,0 +1,37 @@ +#include "fixed.hpp" + +#include "debug.hpp" + +template +void +test_simple (void) +{ + using fixed_t = util::fixed; + using uint_t = typename fixed_t::uint_t; + + const fixed_t lo = uint_t{0}; + const fixed_t hi = uint_t{1}; + + CHECK_EQ (lo, lo); + CHECK_EQ (hi, hi); + + CHECK_NEQ (hi, lo); + CHECK_NEQ (lo, hi); + + CHECK_LT (lo, hi); + CHECK_LE (lo, hi); + CHECK_LE (lo, lo); + + CHECK_GT (hi, lo); + CHECK_GE (lo, lo); + CHECK_GE (hi, lo); +} + + +int +main (void) +{ + test_simple<16,16> (); + test_simple<26, 6> (); + test_simple<32,32> (); +}