ut icon indicating copy to clipboard operation
ut copied to clipboard

Test class should own its name if constructed with std::string

Open R2RT opened this issue 2 years ago • 0 comments

Expected Behavior

Test passes

Actual Behavior

Test runner crashes due to accessing deallocated string or reports corrupted names:

""runner returned from test w/o signaling: not popping because 'ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ' differs from '\0ÍÍÍÍÍÍÍÍÍÍÍ'\n"

or

Running test "▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌▌"... FAILED

Steps to Reproduce the Problem

Run parametrized test example from readme.

int main() {
  for (auto i : std::vector{1, 2, 3}) {
    test("parameterized " + std::to_string(i)) = [i] { // 3 tests
      expect(that % i > 0); // 3 asserts
    };
  }
}

Specifications

  • Version: master
  • Platform: MSVC v143
  • Subsystem: runner

Changing

 struct test {
   std::string_view type{};
-  std::string_view name{};
+  std::string name{};
   std::vector<std::string_view> tag{};

Fixes this issue

R2RT avatar Jun 15 '23 09:06 R2RT