(Issue written by Claude on behalf of @IvanaGyro.)
Summary
GoogleTest's own FAQ says test suite names and test names must not contain underscores (googletest FAQ — "Why should test suite names and test names not contain underscore?"). Our test suite violates this very widely, and a subset of the violations produce reserved C++ identifiers (undefined behavior), not just style problems.
Why it matters (from the FAQ)
TEST(SuiteName, TestName) expands to a class named SuiteName_TestName_Test (the macro joins the parts with _ and appends _Test). Two failure modes follow:
- Reserved identifiers (UB). The C++ standard reserves "any identifier that starts with
_ followed by an upper-case letter, and any identifier that contains two consecutive underscores (__) anywhere." So a TestName that ends in _ (→ ..._ + _Test = ..__Test), or that already contains __, makes the generated class name a reserved identifier — undefined behavior.
- Name collisions. Even when not reserved, different underscore placements collapse to the same class name. The FAQ's example:
TEST(Time, Flies_Like_An_Arrow) { ... }
TEST(Time_Flies, Like_An_Arrow) { ... }
both generate Time_Flies_Like_An_Arrow_Test → conflict.
Scope in this repo (master @ 24e8cc6)
Counting TEST / TEST_F / TEST_P / TYPED_TEST macros under tests/:
- 877 of 1020 test names contain an underscore.
- 123 suite/fixture names contain an underscore (e.g.
linalg_Test).
- Of the test names, the reserved-identifier (UB) subset:
- ~39 test names end with
_ → generated class has __. Examples: Trace_, Trace__str, Transpose_, Pow_, Tensor_Gemm_, Tensor_Inv_, DenseUt_InvM_, contiguous_, get_block_, get_blocks_, gpu_Tensor_Gemm_, gpu_DenseUt_Pow_, Conj__.
- ~68 test names contain
__ directly.
(Combined with underscore-containing suite names, many more class names embed __ even when the individual name doesn't end in one — e.g. suite linalg_Test + name Tensor_InvM_ → linalg_Test_Tensor_InvM__Test.)
Suggested action
- Longer term, migrate test/suite names to underscore-free CamelCase to comply with the FAQ and avoid the collision class entirely.
- This is mechanical but large (877 names); it can be done incrementally per test file. A CI lint (grep for
TEST*\(.*_.*, / names with _) could prevent regressions once cleaned.
(Issue written by Claude on behalf of @IvanaGyro.)
Summary
GoogleTest's own FAQ says test suite names and test names must not contain underscores (googletest FAQ — "Why should test suite names and test names not contain underscore?"). Our test suite violates this very widely, and a subset of the violations produce reserved C++ identifiers (undefined behavior), not just style problems.
Why it matters (from the FAQ)
TEST(SuiteName, TestName)expands to a class namedSuiteName_TestName_Test(the macro joins the parts with_and appends_Test). Two failure modes follow:_followed by an upper-case letter, and any identifier that contains two consecutive underscores (__) anywhere." So aTestNamethat ends in_(→..._+_Test=..__Test), or that already contains__, makes the generated class name a reserved identifier — undefined behavior.Time_Flies_Like_An_Arrow_Test→ conflict.Scope in this repo (master @ 24e8cc6)
Counting
TEST/TEST_F/TEST_P/TYPED_TESTmacros undertests/:linalg_Test)._→ generated class has__. Examples:Trace_,Trace__str,Transpose_,Pow_,Tensor_Gemm_,Tensor_Inv_,DenseUt_InvM_,contiguous_,get_block_,get_blocks_,gpu_Tensor_Gemm_,gpu_DenseUt_Pow_,Conj__.__directly.(Combined with underscore-containing suite names, many more class names embed
__even when the individual name doesn't end in one — e.g. suitelinalg_Test+ nameTensor_InvM_→linalg_Test_Tensor_InvM__Test.)Suggested action
TEST*\(.*_.*,/ names with_) could prevent regressions once cleaned.