fixed: add trivial tests

This commit is contained in:
Danny Robson 2015-02-06 16:35:40 +11:00
parent f0021afc71
commit 4f19a35b7d
2 changed files with 38 additions and 0 deletions

View File

@ -7,6 +7,7 @@ TEST_BIN = \
bitwise \
checksum \
colour \
fixed \
float \
hton \
ip \

37
test/fixed.cpp Normal file
View File

@ -0,0 +1,37 @@
#include "fixed.hpp"
#include "debug.hpp"
template <unsigned I, unsigned E>
void
test_simple (void)
{
using fixed_t = util::fixed<I,E>;
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> ();
}