googletest icon indicating copy to clipboard operation
googletest copied to clipboard

Add mock_type to MockObjectState for dynamic type registration

Open kairosci opened this issue 2 months ago • 2 comments
trafficstars

This pull request adds support for tracking and displaying the dynamic type information of mock objects in Google Mock. The changes improve diagnostics by showing the type of the mock object when reporting errors, and provide a mechanism to register the type information for each mock object.

Enhancements to mock object diagnostics:

  • Added a new member mock_type of type const std::type_info* to the MockObjectState struct to store the dynamic type of the mock object.
  • Updated error reporting in MockObjectRegistry to display the type name of the mock object if type information is available.

API extension for type registration:

  • Introduced a new template method RegisterMockType in MockObjectRegistry to register the dynamic type information for a given mock object.

I would specify it implements FIXME in relating file.

// FIXME: Print the type of the leaked object.
// This can help the user identify the leaked object.

kairosci avatar Aug 23 '25 19:08 kairosci

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 23 '25 19:08 google-cla[bot]

I signed CLA

kairosci avatar Aug 23 '25 20:08 kairosci

@derekmauro could you take a look?

kairosci avatar Nov 11 '25 10:11 kairosci