Skip to content

Negative-path test coverage: validate(), History throw, all tensor stubs, duplicate-add #11

Description

@petlenz

Summary

Every intentional error path in the codebase can silently regress without any test failing. None of these are exercised today:

Path File:Line
validate() rejects an unregistered symbol include/numsim_codegen/recipe.h:185-204
MooseMaterialTarget throws on InputRole::History include/numsim_codegen/targets/moose_material.h:40-48
tensor_storage_type rejects rank ∉ {2, 4} include/numsim_codegen/targets/moose_material.h:259-263
Every NUMSIM_CODEGEN_TENSOR_STUB throw (tensor_mul, basis_change_imp, outer_product, tensor_inv, …) include/numsim_codegen/code_emit/tensor_code_emit.h:140-150
NUMSIM_CODEGEN_T2S_STUB throw include/numsim_codegen/code_emit/tensor_to_scalar_code_emit.h:163-167
Compile-check driver tests only the happy path tests/generated/compile_check_driver.cpp

If the dim check (#7) and duplicate-add check (#8) land, those need coverage too.

Fix

Add tests/NegativePathTest.cpp with a parameterised gtest per row above:

  • Assert EXPECT_THROW(model.emit_compute_function(), std::runtime_error).
  • Assert the thrown message contains a substring identifying the offending symbol/op.
  • For the compile-check driver, add a sibling generator that produces a recipe with an unsupported op (tensor_inv etc.) and assert non-zero exit.

This is the single PR with the highest defensive value — it locks down every intentional guard in one place.

Refs

  • REVIEW.md → TEST-A6 (High), CORR-5, CORR-6, CORR-7, CORR-9, CORR-10
  • Severity: High

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions