Skip to content

Commit 5f003df

Browse files
Merge pull request #10 from dolfandringa/feature/add_yield
Contribute yield function
2 parents d45a326 + 296391e commit 5f003df

4 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/FunctionFake.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,8 @@ long map(long value, long fromLow, long fromHigh, long toLow, long toHigh)
115115
{
116116
return ArduinoFakeInstance(Function)->map(value, fromLow, fromHigh, toLow, toHigh);
117117
}
118+
119+
void yield()
120+
{
121+
ArduinoFakeInstance(Function)->yield();
122+
}

src/FunctionFake.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ struct FunctionFake
4141
virtual void randomSeed(unsigned long) = 0;
4242

4343
virtual long map(long, long, long, long, long) = 0;
44+
45+
virtual void yield() = 0;
4446
};

src/arduino/Arduino.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ typedef uint8_t byte;
127127
void init(void);
128128
void initVariant(void);
129129

130+
void yield(void);
131+
130132
int atexit(void (*func)()) __attribute__((weak));
131133

132134
void pinMode(uint8_t, uint8_t);

test/test_function.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ namespace FunctionTest
4949
Verify(Method(ArduinoFake(), analogRead).Using(4)).Once();
5050
}
5151

52+
void test_yield(void)
53+
{
54+
When(Method(ArduinoFake(), yield)).AlwaysReturn();
55+
56+
yield();
57+
58+
Verify(Method(ArduinoFake(), yield)).Once();
59+
}
60+
5261
void test_delay(void)
5362
{
5463
When(Method(ArduinoFake(), delay)).AlwaysReturn();

0 commit comments

Comments
 (0)