forked from FabioBatSilva/ArduinoFake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_OverrideableArduinoFake_t.cpp
More file actions
40 lines (33 loc) · 997 Bytes
/
test_OverrideableArduinoFake_t.cpp
File metadata and controls
40 lines (33 loc) · 997 Bytes
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
#include <Arduino.h>
#include "SimpleArduinoFake.h"
#include <unity.h>
#include "unity_filename_helper.h"
using namespace fakeit;
struct IDummy
{
virtual void foo(void) { }
};
struct IArduino
{
virtual void bar(void) {}
};
static void test_getFake(void)
{
SimpleArduinoFake::details::FakeOverride_t overrides;
SimpleArduinoFake::details::OverrideableArduinoFake_t<IDummy> subject(overrides);
// No override, should get the real fake
IArduino proxy;
TEST_ASSERT_EQUAL_PTR(&subject.get(), subject.getFake<IArduino>(&proxy));
// Should return the alternate, since it's now overriden
SimpleArduinoFake::details::ArduinoFake_t<IArduino> alternateFake;
overrides.setOverride(&proxy, &alternateFake);
TEST_ASSERT_EQUAL_PTR(&alternateFake.get(), subject.getFake<IArduino>(&proxy));
}
namespace OverrideableArduinoFakeTTest
{
void run_tests(void)
{
unity_filename_helper_t _ufname_helper(__FILE__);
RUN_TEST(test_getFake);
}
}