diff options
author | Max Horn | 2006-03-29 10:25:48 +0000 |
---|---|---|
committer | Max Horn | 2006-03-29 10:25:48 +0000 |
commit | 3820593bb8dfdca4e2e17c70b278065b7f7894d9 (patch) | |
tree | df3e8bebda3abcd99d0882dc9e8c6410f86850fb /test/cxxtest/sample/mock/TestDice.h | |
parent | 9c94670e22cb68e32fd38c0d2b009539e35d4a71 (diff) | |
download | scummvm-rg350-3820593bb8dfdca4e2e17c70b278065b7f7894d9.tar.gz scummvm-rg350-3820593bb8dfdca4e2e17c70b278065b7f7894d9.tar.bz2 scummvm-rg350-3820593bb8dfdca4e2e17c70b278065b7f7894d9.zip |
bringing cxxtest-3.10.1 to ScummVM's main branch
svn-id: r21488
Diffstat (limited to 'test/cxxtest/sample/mock/TestDice.h')
-rw-r--r-- | test/cxxtest/sample/mock/TestDice.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/cxxtest/sample/mock/TestDice.h b/test/cxxtest/sample/mock/TestDice.h new file mode 100644 index 0000000000..35b3b7eec9 --- /dev/null +++ b/test/cxxtest/sample/mock/TestDice.h @@ -0,0 +1,62 @@ +#include <cxxtest/TestSuite.h> +#include "Dice.h" +#include "MockStdlib.h" + +class TestDice : public CxxTest::TestSuite +{ +public: + MockStdlib *stdlib; + + void setUp() + { + TS_ASSERT( stdlib = new MockStdlib ); + } + + void tearDown() + { + delete stdlib; + } + + void test_Randomize_uses_time() + { + stdlib->nextTime = 12345; + Dice dice; + TS_ASSERT_EQUALS( stdlib->lastSeed, 12345 ); + } + + void test_Roll() + { + Dice dice; + + stdlib->nextRand = 0; + TS_ASSERT_EQUALS( dice.roll(), 1 ); + + stdlib->nextRand = 2; + TS_ASSERT_EQUALS( dice.roll(), 3 ); + + stdlib->nextRand = 5; + TS_ASSERT_EQUALS( dice.roll(), 6 ); + + stdlib->nextRand = 7; + TS_ASSERT_EQUALS( dice.roll(), 2 ); + } + + void test_Temporary_override_of_one_mock_function() + { + Dice dice; + + stdlib->nextRand = 2; + TS_ASSERT_EQUALS( dice.roll(), 3 ); + + class Five : public T::Base_rand { int rand() { return 5; } }; + + Five *five = new Five; + TS_ASSERT_EQUALS( dice.roll(), 6 ); + TS_ASSERT_EQUALS( dice.roll(), 6 ); + TS_ASSERT_EQUALS( dice.roll(), 6 ); + delete five; + + stdlib->nextRand = 1; + TS_ASSERT_EQUALS( dice.roll(), 2 ); + } +}; |