summaryrefslogtreecommitdiffstats
path: root/cxxtest/sample/mock
diff options
context:
space:
mode:
Diffstat (limited to 'cxxtest/sample/mock')
-rw-r--r--cxxtest/sample/mock/Dice.cpp14
-rw-r--r--cxxtest/sample/mock/Dice.h13
-rw-r--r--cxxtest/sample/mock/Makefile22
-rw-r--r--cxxtest/sample/mock/MockStdlib.h31
-rw-r--r--cxxtest/sample/mock/T/stdlib.h13
-rw-r--r--cxxtest/sample/mock/TestDice.h62
-rw-r--r--cxxtest/sample/mock/mock_stdlib.cpp2
-rw-r--r--cxxtest/sample/mock/real_stdlib.cpp2
-rw-r--r--cxxtest/sample/mock/roll.cpp11
9 files changed, 0 insertions, 170 deletions
diff --git a/cxxtest/sample/mock/Dice.cpp b/cxxtest/sample/mock/Dice.cpp
deleted file mode 100644
index 161b80fa2..000000000
--- a/cxxtest/sample/mock/Dice.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <T/stdlib.h>
-#include "Dice.h"
-
-Dice::Dice()
-{
- T::srand( T::time( 0 ) );
-}
-
-unsigned Dice::roll()
-{
- return (T::rand() % 6) + 1;
-}
-
-
diff --git a/cxxtest/sample/mock/Dice.h b/cxxtest/sample/mock/Dice.h
deleted file mode 100644
index 94271417e..000000000
--- a/cxxtest/sample/mock/Dice.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __DICE_H
-#define __DICE_H
-
-class Dice
-{
-public:
- Dice();
-
- unsigned roll();
-};
-
-#endif // __DICE_H
-
diff --git a/cxxtest/sample/mock/Makefile b/cxxtest/sample/mock/Makefile
deleted file mode 100644
index 709b7cbe9..000000000
--- a/cxxtest/sample/mock/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-all: roll run
-
-clean:
- rm -f *~ *.o roll test test.cpp
-
-CXXTEST = ../..
-CCFLAGS = -I. -I$(CXXTEST)
-
-roll: roll.o Dice.o real_stdlib.o
- g++ -o $@ $^
-
-run: test
- ./test
-
-test: test.o Dice.o mock_stdlib.o
- g++ -o $@ $^
-
-.cpp.o:
- g++ -c -o $@ $(CCFLAGS) $<
-
-test.cpp: TestDice.h
- $(CXXTEST)/cxxtestgen.pl -o $@ --error-printer $<
diff --git a/cxxtest/sample/mock/MockStdlib.h b/cxxtest/sample/mock/MockStdlib.h
deleted file mode 100644
index aee62bafe..000000000
--- a/cxxtest/sample/mock/MockStdlib.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <T/stdlib.h>
-
-class MockStdlib :
- public T::Base_srand,
- public T::Base_rand,
- public T::Base_time
-{
-public:
- unsigned lastSeed;
-
- void srand( unsigned seed )
- {
- lastSeed = seed;
- }
-
- int nextRand;
-
- int rand()
- {
- return nextRand;
- }
-
- time_t nextTime;
-
- time_t time( time_t *t )
- {
- if ( t )
- *t = nextTime;
- return nextTime;
- }
-};
diff --git a/cxxtest/sample/mock/T/stdlib.h b/cxxtest/sample/mock/T/stdlib.h
deleted file mode 100644
index 30306ba22..000000000
--- a/cxxtest/sample/mock/T/stdlib.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __T__STDLIB_H
-#define __T__STDLIB_H
-
-#include <stdlib.h>
-#include <time.h>
-
-#include <cxxtest/Mock.h>
-
-CXXTEST_MOCK_VOID_GLOBAL( srand, ( unsigned seed ), ( seed ) );
-CXXTEST_MOCK_GLOBAL( int, rand, ( void ), () );
-CXXTEST_MOCK_GLOBAL( time_t, time, ( time_t *t ), ( t ) );
-
-#endif // __T__STDLIB_H
diff --git a/cxxtest/sample/mock/TestDice.h b/cxxtest/sample/mock/TestDice.h
deleted file mode 100644
index 35b3b7eec..000000000
--- a/cxxtest/sample/mock/TestDice.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#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 );
- }
-};
diff --git a/cxxtest/sample/mock/mock_stdlib.cpp b/cxxtest/sample/mock/mock_stdlib.cpp
deleted file mode 100644
index 148a044d2..000000000
--- a/cxxtest/sample/mock/mock_stdlib.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-#define CXXTEST_MOCK_TEST_SOURCE_FILE
-#include <T/stdlib.h>
diff --git a/cxxtest/sample/mock/real_stdlib.cpp b/cxxtest/sample/mock/real_stdlib.cpp
deleted file mode 100644
index db02f3a15..000000000
--- a/cxxtest/sample/mock/real_stdlib.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-#define CXXTEST_MOCK_REAL_SOURCE_FILE
-#include <T/stdlib.h>
diff --git a/cxxtest/sample/mock/roll.cpp b/cxxtest/sample/mock/roll.cpp
deleted file mode 100644
index 20ea967af..000000000
--- a/cxxtest/sample/mock/roll.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdio.h>
-#include "Dice.h"
-
-int main()
-{
- Dice dice;
- printf( "First roll: %u\n", dice.roll() );
- printf( "Second roll: %u\n", dice.roll() );
-
- return 0;
-}