Comments (4)
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.
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.
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.
Thanks
from aunit.
Related Issues (20)
- Can´t compile my project when using classes with a separate .cpp file HOT 3
- potential mocking framework
- configuring the CPATH environment variable
- hi there, HOT 2
- assertNull and assertNotNull assertions HOT 7
- why does assertTrue(true) or assertTrue(1) timeout? HOT 1
- assertNotEqual(obj, nullptr) fails on a real board HOT 1
- test macro not working HOT 9
- Compilation error with Raspberry Pi Pico (RP2040) using Arduino-Pico Core HOT 4
- Missing WProgram.h HOT 1
- Feature request (and patch) : filter test on command line HOT 10
- Issue when used as submodule HOT 8
- Github action for "pull_request" as well as "push"?
- How do you test analogRead and digitalRead?
- Your recommended test for nullptr fails for me. Is this my problem or yours? <EDIT it's mine/> HOT 3
- ASSERT_EQ does not work with refrence HOT 3
- Error in test headers?
- "unsigned" not implemented ?
- Feature Request: JUnit stylized output
- Test fixture implementation following example didn't work HOT 1
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 aunit.