Skip to content

Improve test coverage neat_tools/utils.h #20

Description

@Jgocunha

Summary

Add tests for the four utility functions in include/neat_tools/utils.h that currently have zero coverage.

Motivation

tests/test_utils.cpp only tests the three generateRandom*() functions. The normalization and signal-generation helpers below are exercised at runtime but never verified in the test suite, so regressions in their behaviour would go undetected.

Proposed Solution

Extend tests/test_utils.cpp with TEST_CASE blocks for:

  • normalize(value, min, max) — linear normalization to [0, 1]

    • value == min → 0.0
    • value == max → 1.0
    • value at midpoint → 0.5
    • value outside [min, max] (document and assert the boundary behaviour)
  • normalizeWithGaussian(value, target, width) — Gaussian-shaped score

    • value == target → maximum output (1.0)
    • value far from target → output close to 0.0
    • width = 0 edge case
  • normalizeWithFlatheadGaussian(value, min, max, width) — flat-top Gaussian

    • value inside flat region → 1.0
    • value outside flat region → decreases toward 0.0
  • generateRandomSignal() — returns +1 or -1

    • over 1 000 calls, only +1 and -1 are observed

Files to touch: tests/test_utils.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstestsStuff related to testing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions