-
Notifications
You must be signed in to change notification settings - Fork 0
Draft for unit-tests #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hi @cmaglie that's a super useful feature!
I tried to modify the tests a little and:
It looks like a sign conversion problem maybe related to the typecast the StreamMock class is doing (?) The library has no issues regarding error codes or float sign |
This is actually the correct outcome since you changed 2.0 to -2.0 the response obtained is different from the
since line 63 is: COMPARE_ARRAYS(expected, got); The error indicates that the byte at index 10 is 64 instead of 192.
This is an artifact due to the implementation of the COMPARE_ARRAY part. I admit I sketched this part quickly, but it can be improved, for example changing line 27 from:
to
improves the message:
Here you are comparing The correct comparison should be: REQUIRE(rpc.lastError.code == -3) That is exactly what you will write client-side. |
I've rebased this branch on top of the latest |
This PR aims to provide unit tests that can be run locally on a PC.
This patch is inspired by Aentiger's (😢) work on unit tests for the ArduinoCore-API.
The Serial connection is mocked with a bidirectional Stream.
Currently, only a single call test is implemented, which is very rough and can be optimized. However, my goal is to create a pilot implementation that works.
It uses CMake for building, and the
catch.hpp
library to run assertions on tests. It should also produce coverage, but I haven't investigated yet how to extract the data and upload it to codecov.Further instructions can be found in the README in the PR.