File: test_class_args.cpp

package info (click to toggle)
hippomocks 5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 672 kB
  • sloc: cpp: 7,791; ansic: 31; makefile: 28
file content (49 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "hippomocks.h"
#include "Framework.h"
#include <string>

// non-reference is bad, but should work
class IC {
public:
	virtual ~IC() {}
	virtual void f(std::string s);
	virtual void g(std::string s) = 0;
};

TEST (checkClassArgumentsAccepted)
{
	MockRepository mocks;
	IC *iamock = mocks.Mock<IC>();
	mocks.OnCall(iamock, IC::f).With("hi");
	mocks.OnCall(iamock, IC::g).With("bye");
	iamock->f("hi");
	iamock->g("bye");
}

TEST (checkClassArgumentsChecked)
{
	MockRepository mocks;
	IC *iamock = mocks.Mock<IC>();
	mocks.OnCall(iamock, IC::f).With("hi");
	mocks.OnCall(iamock, IC::g).With("bye");
	bool exceptionCaught = false;
	try 
	{
		iamock->f("bye");
	}
	catch (HippoMocks::ExpectationException)
	{
		exceptionCaught = true;
	}
	CHECK(exceptionCaught);
	mocks.reset();
}

TEST (checkClassArgumentsIgnored)
{
	MockRepository mocks;
	IC *iamock = mocks.Mock<IC>();
	mocks.OnCall(iamock, IC::f);
	iamock->f("bye");
}