Skip to content

[Type] UnitTest: use EXPECT_DOUBLE_EQ as advised for Matrix:trace() test - #6267

Open
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:matrixtest_trace_eq
Open

[Type] UnitTest: use EXPECT_DOUBLE_EQ as advised for Matrix:trace() test#6267
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:matrixtest_trace_eq

Conversation

@fredroy

@fredroy fredroy commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Since always (?), on my mac, when running the Sofa.Type_test unittests, one test was failing:
[ FAILED ] MatSymTest/1.trace, where TypeParam = sofa::MatSymTestParameterPack<3u,double>
due to :

The difference between expectedTrace and sofa::type::trace(m_symmetricMatrix) is 8.8817841970012523e-16, where
expectedTrace evaluates to 7.3017516772499684,
sofa::type::trace(m_symmetricMatrix) evaluates to 7.3017516772499675.
The abs_error parameter testing::NumericTest<Real>::epsilon() evaluates to 2.2204460492503131e-16 which is smaller than the minimum distance between doubles for numbers of this magnitude which is 8.8817841970012523e-16, thus making this EXPECT_NEAR check equivalent to EXPECT_EQUAL. Consider using EXPECT_DOUBLE_EQ instead.

I guess this fail was depending greatly one the platform/compiler/cpu type.

After setting this, no fail anymore.


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: fix Fix a bug pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: status to review To notify reviewers to review this pull-request labels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant