Skip to content

Introduce unit testing for Column class - #426

Open
svalat wants to merge 8 commits into
idefix-code:developfrom
svalat:feature/test-column
Open

svalat wants to merge 8 commits into
idefix-code:developfrom
svalat:feature/test-column

Conversation

@svalat

@svalat svalat commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Goal

Be able to unit test more classes in Idefix, starting with the Column class, currently considering only the single rank implementation when being in MPI.

Tests depending on DataBlock

The Column class depends on the DataBlock class which connect to too many objects. To reduce those dependencies, the DataBlock class has been patched to optionally initialise the physics so we can have only the grid in place.

UnitTestApp

In order to ease the creation of the idefix objects required to make minimum tests I added the UnitTestApp object to setup Idefix basement in one line in unit tests.

This classe does :

  1. Create a dummy minimal config file with the given mesh size
  2. init the objects requires to use the DataBlock object.
  3. destroy and cleanup everything when being deleted (when one test exit).

Tests for Column

The unit test for column consider only the 3D and Spherical case by filling an array with a constant value.

The test mainly consider that the column return value should be constant increase along $\phi$ and $\theta$ and being constant over $\theta$ and $\phi$ when applying column along r.

The expected value is estimating roughly with some rounding before checking the constant property for the other cells.

Array compare macros

I added some checks so that the arrays have the same size when using ASSERT_THAT_XD_ARRAYS* macros so we also ensure thay have same size before comparing the content.

About safeExit() in unit tests

I also made safeExit() a weak symbol, so the unit test can override it to make it throwing an exception instead of aborting the whole test suite if it is triggered. To be check if it is OK for you ?

TODO

  • Maybe add one test with second argument being -1 instead of 1.
  • See what is the best for boundary in the generated config.

@svalat
svalat force-pushed the feature/test-column branch from 25a168e to a402091 Compare November 27, 2026 09:20
@svalat
svalat marked this pull request as ready for review November 27, 2026 19:41
@glesur
glesur self-requested a review November 29, 2026 20:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant