blob: cd80bb35427c58ff23aece4f77ee00f1fdfdb021 (
plain)
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
50
|
extern "C"
{
#include "driver.h"
#include "registers.h"
}
#include "../../../fff.h"
#include <gtest/gtest.h>
extern "C"
{
static uint8_t readVal;
static int readCalled;
static uint32_t readRegister;
uint8_t IO_MEM_RD8(uint32_t reg)
{
readRegister = reg;
readCalled++;
return readVal;
}
static uint32_t writeRegister;
static uint8_t writeVal;
static int writeCalled;
void IO_MEM_WR8(uint32_t reg, uint8_t val)
{
writeRegister = reg;
writeVal = val;
writeCalled++;
}
}
TEST(Driver, When_writing_Then_writes_data_to_DRIVER_OUTPUT_REGISTER)
{
driver_write(0x34);
ASSERT_EQ(1u, writeCalled);
ASSERT_EQ(0x34u, writeVal);
ASSERT_EQ(DRIVER_OUTPUT_REGISTER, writeRegister);
}
TEST(Driver, When_reading_data_Then_reads_from_DRIVER_INPUT_REGISTER)
{
readVal = 0x55;
uint8_t returnedValue = driver_read();
ASSERT_EQ(1u, readCalled);
ASSERT_EQ(0x55u, returnedValue);
ASSERT_EQ(readRegister, DRIVER_INPUT_REGISTER);
}
|