Giter Club home page Giter Club logo

Comments (4)

bxparks avatar bxparks commented on June 2, 2024

Hi,

Thanks for using AUnit and posting this question. I should have added some notes about this in the README.md.

You are correct that AUnit does not provide the equivalent of ASSERT_FLOAT_EQ and ASSERT_DOUBLE_EQ from Google Test. The reason is that floating point comparison is subtle and complex. The Google Test ASSERT_FLOAT_EQ() interprets equality to mean 4 ULPs (Units in the Last Place) from each other. The definition of Units in the Last Place is incredibly complicated.

For embedded environments like Arduino, floating points are not used often so it didn't seem worth spending a lot of time on this.

The ASSERT_NEAR() macro from Google Test seems much easier to implement and is the same as your workaround. If this functionality is good enough for you, I think I could get that incorporated without too much effort. I would probably name it assertNear(val1, val2, error) in AUnit for consistency. I would implement it for floating types, and extend it to integer types if it's straightforward.

from aunit.

gparmeggiani avatar gparmeggiani commented on June 2, 2024

Yes I think that adding assertNear would be good enough.
I'm now wondering if that could be useful also for integers comparison

from aunit.

bxparks avatar bxparks commented on June 2, 2024

Please take a look at assertNear() and assertNotNear() in v1.1 that I just released. They work for integral types, but I suspect that they will be mostly used for floating point types.

from aunit.

gparmeggiani avatar gparmeggiani commented on June 2, 2024

Thanks

from aunit.

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.