aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorJohannes Schickel2011-08-19 01:14:09 +0200
committerJohannes Schickel2011-08-19 01:14:09 +0200
commit1e0b05ff992665467f762d61947a51407d1f1c41 (patch)
tree1fbc6cb00445f6e199bada29403d8c190eb91c1c /test/common
parent14c8df76eadbedef36a9691a71c4b80889a5b3cc (diff)
downloadscummvm-rg350-1e0b05ff992665467f762d61947a51407d1f1c41.tar.gz
scummvm-rg350-1e0b05ff992665467f762d61947a51407d1f1c41.tar.bz2
scummvm-rg350-1e0b05ff992665467f762d61947a51407d1f1c41.zip
TEST: Add a very tiny and simple unit test for intLog2.
Diffstat (limited to 'test/common')
-rw-r--r--test/common/math.h18
1 files changed, 18 insertions, 0 deletions
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 <cxxtest/TestSuite.h>
+
+#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);
+ }
+};