Skip to content

Commit 028f2c6

Browse files
author
Marcus Sonestedt
committed
ServoPID: Move globals used only for mocking into namespace
1 parent 3d1a788 commit 028f2c6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

ServoPID/TestServoPID/ArduinoMock.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
// ReSharper disable CppInconsistentNaming
55

6-
unsigned long gMicros = 0;
6+
namespace mock
7+
{
8+
unsigned long gMicros = 0;
79
std::vector<int> gAnalogPins(256, 0);
10+
}
11+
812
MockSerial Serial;
9-
MockWire Wire;
13+
MockWire Wire;

ServoPID/TestServoPID/ArduinoMock.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ constexpr const char* F(const char* x) { return x; }
88

99
// Mock globals
1010

11-
extern unsigned long gMicros;
12-
inline unsigned long micros() { return gMicros; }
13-
inline void setMockMicros(const unsigned long value) { gMicros = value;}
11+
namespace mock {
1412

13+
extern unsigned long gMicros;
1514
extern std::vector<int> gAnalogPins;
16-
inline int analogRead(const int pin) { return gAnalogPins.at(pin);}
15+
16+
}
17+
inline unsigned long micros() { return mock::gMicros; }
18+
inline void setMockMicros(const unsigned long value) { mock::gMicros = value;}
19+
20+
inline int analogRead(const int pin) { return mock::gAnalogPins.at(pin);}
1721
inline void setMockAnalogRead(const int pin, const int value)
1822
{
19-
gAnalogPins.at(pin) = value;
23+
mock::gAnalogPins.at(pin) = value;
2024
}
2125

2226
template<typename T>

0 commit comments

Comments
 (0)