From 1e0b05ff992665467f762d61947a51407d1f1c41 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 19 Aug 2011 01:14:09 +0200 Subject: TEST: Add a very tiny and simple unit test for intLog2. --- test/common/math.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/common/math.h (limited to 'test/common') diff --git a/test/common/math.h b/test/common/math.h new file mode 100644 index 0000000000..5da0410e8e --- /dev/null +++ b/test/common/math.h @@ -0,0 +1,18 @@ +#include + +#include "common/math.h" + +class MathTestSuite : public CxxTest::TestSuite +{ + public: + void test_intLog2() { + // Test special case for 0 + TS_ASSERT_EQUALS(Common::intLog2(0), -1); + + // intLog2 should round the result towards 0 + TS_ASSERT_EQUALS(Common::intLog2(7), 2); + + // Some simple test for 2^10 + TS_ASSERT_EQUALS(Common::intLog2(1024), 10); + } +}; -- cgit v1.2.3