Comments (5)
Is this an issue of missing documentation, i.e. you have things working but think there should be clearer documentation, or are you unable to get double support working?
The unity.h header does contain a Configuration Options comment block that describes the options and states that "All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above." (That's from v2.5.1 unity.h).
from unity.
@dmorash-BT missing documentation.
I find that simply providing options like UNITY_INCLUDE_DOUBLE
isn't sufficient to bring the double support from working properly. This is because the necessary function definitions for double-related assertions, such as UnityAssertDoublesWithin
which is required for TEST_ASSERT_EQUAL_DOUBLE
, are not included.
This can be confirmed by examining the symbol table of libunity.a
, produced from building the Unity with CMake.
grep 'UnityAssertDoublesWithin' <(nm /path/to/libunity.a)
To wrap up, it's not possible to actually perform assertions on doubles without the required function definitions in the library even if you have configuration options on.
The meson_options.txt
includes support_double
, which is a clear indication for enabling double support when building the Unity. Indeed, the library generated from a meson build with support_double=true
contains all the necessary function definitions for performing assertions on doubles, including the aforementioned UnityAssertDoublesWithin
. Only after obtaining this library and enabling configuration options in the compile flags when building concrete test suites, can assertions on doubles work correctly.
So, the documentation lacks information on how to build Unity, specifically what is needed when double support is required.
Oh, I almost forgot, there is actually a missing equivalent CMake option of support_double
.
from unity.
Well you'll need to supply that define when building Unity as a library to get those functions. That seems clear to me from the unity.h header. I assume CMake supports CFLAGS, either reading the CFLAGS environment variable or setting them directly in the CMake build file.
from unity.
Aye.
I have been away from C for a while, but I recently picked it up again, so the sense of C is not very strong yet. Right now I may not smart enough to figure out from the unity.h header. Based on my past experience, either you specify options during the compilation of the library and then use it without further configurations, or you specify the options when using the library while leaving the building process simple. And my case is the latter one. I built Unity using CMake without double support in CFLAGS, then I used it in my tests with my understanding of double support by either defining above unity.h header or defining in CFLAGS.
from unity.
I'd recommend reading http://www.throwtheswitch.org/build/build-unity and http://www.throwtheswitch.org/build/make. They give a good overview of how unity is meant to be used. If you don't feel like dealing with build configuration, ceedling might be a simpler route. If you're just returning to C, I'd avoid the more complex toolchains like cmake and meson. Both are far more problematic than the other options.
from unity.
Related Issues (20)
- Unit Testing with unity using ceedling on Tarhet Hardware. Programming Target Failed
- mb HOT 2
- cmake and unity_config.h HOT 14
- Issue with Discovery of Included Mocks In Test Runner Generator HOT 4
- TEST_PRINTF() expansion error when no variadic arguments are passed
- TEST_PRINTF(): printing 64-bit hex numbers or pointers HOT 1
- Release for floats and doubles testing HOT 2
- README description of INT assertions is structured oddly
- How do I reset state of static variables inside functions called by multiple tests? HOT 3
- Fails to compile with latest XC8
- static variable inside of target function is reset everytime when it is invoked HOT 3
- Add __FILE__ to failure messages. HOT 1
- Intent of verbosity and command line parsing? HOT 6
- Bug: Boolean is found to be both true and false simultaneously HOT 3
- mistakenly opened issue
- closed HOT 1
- Issue with comparing the streams. HOT 2
- Possibly typo in test_unity_integers_64.c and test_unity_arrays.c HOT 1
- Avoid running the setup for some specific tests HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity.