Skip to content

[Feature] Add unit tests for plot parameter classes #66

Description

@Jgocunha

What would you like?

Unit tests for the plot-parameter classes in src/visualization/plot_parameters.cpp /
include/visualization/plot_parameters.h. These are pure-logic value types with a clean,
GUI-free API and currently have no dedicated test, so they're an easy coverage win.

Cover:

  • PlotDimensions
    • isLegal()true for valid ranges/steps; false when xMin >= xMax, yMin >= yMax,
      or any step is non-positive.
    • toString() — expected formatted text (uses std::format with {:.2f}).
    • operator== — equal vs. each field differing.
  • PlotAnnotationstoString() and operator== (title / x_label / y_label).
  • PlotCommonParameterstoString() and operator== (type + nested dimensions +
    annotations).

Use case / motivation

Overall coverage is ~47%. The visualization/ folder is mostly ImGui rendering (heatmap,
lineplot, plot, visualization) that isn't unit-testable, but plot_parameters is the one
self-contained logic unit in that folder — testing it lifts coverage without needing a render
context.

What's missing today?

There is no tests/visualization/ test file. PlotDimensions::isLegal(), the three
toString() methods, and the three operator== overloads are entirely uncovered.

Possible approach

  • Add tests/visualization/test_plot_parameters.cpp and register it in tests/CMakeLists.txt
    (follow how the existing element tests are registered).
  • One TEST(...) per behaviour. Example:
TEST(PlotDimensionsTest, IsLegal)
{
    EXPECT_TRUE (PlotDimensions(0.0, 100.0, -5.0, 5.0, 1.0, 1.0).isLegal());
    EXPECT_FALSE(PlotDimensions(100.0, 0.0, -5.0, 5.0, 1.0, 1.0).isLegal()); // xMin>=xMax
    EXPECT_FALSE(PlotDimensions(0.0, 100.0, -5.0, 5.0, 0.0, 1.0).isLegal()); // step<=0
}

Verifiable end state: new test_plot_parameters.cpp passes and coverage for
src/visualization/plot_parameters.cpp rises. The ImGui rendering files in src/visualization/
and src/user_interface/ are intentionally out of scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions