Skip to content

Commit

Permalink
Merge pull request #57 from Spin42/master
Browse files Browse the repository at this point in the history
Add analogReadResolution
  • Loading branch information
FabioBatSilva authored Feb 16, 2024
2 parents cb6d180 + e1ea1ed commit 61a4a2c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/FunctionFake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ void analogReference(uint8_t mode)
ArduinoFakeInstance(Function)->analogReference(mode);
}

void analogReadResolution(uint8_t mode)
{
ArduinoFakeInstance(Function)->analogReadResolution(mode);
}

unsigned long millis(void)
{
return ArduinoFakeInstance(Function)->millis();
Expand Down
1 change: 1 addition & 0 deletions src/FunctionFake.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct FunctionFake

virtual int analogRead(uint8_t) = 0;
virtual void analogReference(uint8_t) = 0;
virtual void analogReadResolution(uint8_t) = 0;
virtual void analogWrite(uint8_t, int) = 0;

virtual unsigned long millis(void) = 0;
Expand Down
1 change: 1 addition & 0 deletions src/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void digitalWrite(uint8_t, uint8_t);
int digitalRead(uint8_t);
int analogRead(uint8_t);
void analogReference(uint8_t mode);
void analogReadResolution(uint8_t mode);
void analogWrite(uint8_t, int);

unsigned long millis(void);
Expand Down
10 changes: 10 additions & 0 deletions test/test_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ namespace FunctionTest
Verify(Method(ArduinoFake(), analogRead).Using(4)).Once();
}

void test_analog_read_resolution(void)
{
When(Method(ArduinoFake(), analogReadResolution)).AlwaysReturn();

analogReadResolution(12);

Verify(Method(ArduinoFake(), analogReadResolution).Using(12)).Once();
}

void test_yield(void)
{
When(Method(ArduinoFake(), yield)).AlwaysReturn();
Expand Down Expand Up @@ -188,6 +197,7 @@ namespace FunctionTest
RUN_TEST(FunctionTest::test_pin_mode);
RUN_TEST(FunctionTest::test_digital_pin);
RUN_TEST(FunctionTest::test_analog_pin);
RUN_TEST(FunctionTest::test_analog_read_resolution);
RUN_TEST(FunctionTest::test_delay);
RUN_TEST(FunctionTest::test_detach);
RUN_TEST(FunctionTest::test_attach);
Expand Down

0 comments on commit 61a4a2c

Please sign in to comment.