Recently i’ve tried to compile and run a few tests, using the native environment. Im using the PlatformIO cli.
$ pio test -e native
The tests compile fine, but when ran the following error is displayed:
Processing Pid_Test in native environment
test\Pid_Test\Pid_Test.cpp:26:test_pid_works:FAIL: Unity Double Precision Disabled [FAILED]
When looking up the error i came across the following SO answer. It says that i have to add a unity_config.h file, and then rebuild Unity. How would that work with platform io? Is there a better way to enable double precision?
My target, the Teensy 4.0, supports 64-bit doubles and has an FPU, so its not that the target doesn’t support double precision. And i would much much rather have the
double than simply use
float, if possible.
Thank you in advance for your time!
Could you please try these two solution approaches.
First, go into the
platformio.ini of the project and, in the
[env:native] section, add the line
build_flags = -D UNITY_INCLUDE_DOUBLE -DUNITY_DOUBLE_PRECISION=1e-12
then re-test the project. My hopes are that this defines the macro to enable double support in Unity when Unity is compiled from source in the test and that it then works.
If that fails again you can, as a quick test, go into the folder
C:\Users\<user>\.platformio\packages\tool-unity and open the
unity_config.h to add the line
#define UNITY_DOUBLE_PRECISION 1e-12
#define UNITY_OUTPUT_COMPLETE() output_complete() line, and re-test the project.
Update: Add possibly missing defines regarding precision.
Yes that fixed the error, and double precision is enabled. Thank you very much for the prompt response! Now to fix my code and get tests to pass
EDIT: Specifically the build flags edit fixed the error