File: test_cfuncs.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 (45 lines) | stat: -rw-r--r-- 769 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
#include "hippomocks.h"
#include "Framework.h"

// If it's not supported, then don't test it.
#ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT
int a()
{
  return 1;
}

TEST (checkFunctionReplacedAndChecked)
{
	EQUALS(a(), 1);
	MockRepository mocks;
	mocks.ExpectCallFunc(a).Return(2);
	EQUALS(a(), 2);
}

TEST (checkFunctionReturnedToOriginal)
{
	{
		EQUALS(a(), 1);
		MockRepository mocks;
		mocks.ExpectCallFunc(a).Return(2);
		EQUALS(a(), 2);
	}
	EQUALS(a(), 1);
}

#ifdef _WIN32
#include <windows.h>
TEST (checkCanMockGetSystemTime) {
	MockRepository mocks;
	SYSTEMTIME outtime;
	outtime.wDay = 1;
	SYSTEMTIME systime;
	systime.wDay = 0;
	mocks.ExpectCallFunc(GetSystemTime).With(Out(outtime));
	GetSystemTime(&systime);
	EQUALS(systime.wDay, 1);
}
#endif

#endif