Skip to content

Commit 296391e

Browse files
committed
Contribute yield function
1 parent e5a2f99 commit 296391e

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy