GithubHelp home page GithubHelp logo

Comments (5)

dmorash-BT avatar dmorash-BT commented on June 17, 2024

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.

wanghaiqiangk avatar wanghaiqiangk commented on June 17, 2024

@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.

dmorash-BT avatar dmorash-BT commented on June 17, 2024

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.

wanghaiqiangk avatar wanghaiqiangk commented on June 17, 2024

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.

mvandervoord avatar mvandervoord commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.