Skip to content

adding Serial.prinf(const char* format, ...)#84

Open
arek-jamanskiy wants to merge 1 commit intoFabioBatSilva:masterfrom
arek-jamanskiy:master
Open

adding Serial.prinf(const char* format, ...)#84
arek-jamanskiy wants to merge 1 commit intoFabioBatSilva:masterfrom
arek-jamanskiy:master

Conversation

@arek-jamanskiy
Copy link

adding Serial.printf(const char* format, ...)



size_t Print::printf(const char *format, ...) {
va_list arg;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a call to the fake instance not a concrete implementation.

This might help : https://github.com/FabioBatSilva/ArduinoFake/blob/master/CONTRIBUTING.md

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried - maybe not very hard - but mocking method with ... did not work for me at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I will try one more time. thanks for fast feedback!

if (this->Instances) {
delete this->Instances;
}
this->Instances = new ArduinoFakeInstances();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary ?

Copy link
Author

@arek-jamanskiy arek-jamanskiy Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is necessary to fix unit test ArduinoContextTest::test_reset. It failed on my pc all the time no matter what.
It failed because CRT, used in g++ compiler shipped with msys64 installed on Windows, reuses very same memory address (value of this->Instances) when re-creating object just after deleting it. So I created new object first and then deleted the old one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants