Class SetPointerPlugin

Inheritance Relationships

Base Type

Class Documentation

class SetPointerPlugin : public mu::tiny::test::Plugin
[source]

Plugin that restores pointer variables to their original values.

Up to max_set pointers may be registered per test. The plugin records the address of each pointer variable before it is overwritten; on post_test_action() it writes the saved address back.

Public Functions

SetPointerPlugin()
[source]

Construct the plugin and prepare the storage array.

virtual void post_test_action(Shell &test, Result &result) override

Restore all registered pointer variables to their original values.

Called automatically by the test runner after each test.

Parameters:
  • test – The test shell that just ran.

  • result – The active test result accumulator.

Public Static Functions

template<typename T>
static inline void set_pointer(T *&a, T *b)

Save the original value of a, then set a = b.

The original value is restored automatically at end-of-test via post_test_action(). Prefer the MUTINY_PTR_SET macro.

Template Parameters:

T – Pointee type; deduced from a.

Parameters:
  • a – Reference to the pointer variable to overwrite.

  • b – New value to assign to a.

Public Static Attributes

static size_t max_set = 32

Maximum number of pointers that can be registered per test.