llnl / llnl/smith

Create helper macro for test name string

Open Beginner friendly
#1,640 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
245
Forks
36
Avg merge
8d 23h
Merged PRs (30d)
4

Description

There are cases where you need a unique string in test cases, for example creating the Sidre datastore. We should create a macro that returns a string of the test name. This will help with people accidentally using the same string to output files in different tests.

Something like:

```
#define GTEST_FULL_NAME() \
([]() -> std::string { \
const auto* info = \
::testing::UnitTest::GetInstance()->current_test_info(); \
return info \
? std::string(info->test_suite_name()) + "_" + info->name() \
: std::string{}; \
}())
```

It would return `SolidMechanics_AxisymmetricPressureInnerResultant` in this case.

_Originally posted by @white238 in https://github.com/llnl/smith/pull/1638#discussion_r3723021586_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the test utilities and Sidre datastore tests for existing helpers and cases that create output strings, then review the proposed GTEST_FULL_NAME() use of current_test_info(). Done means a reusable helper returns the test suite and test name joined as shown, avoids collisions across tests, and is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.