Lutok: anonymous_namespace{test_utils.hpp}::stack_balance_checker Class Reference

Lutok 0.6.1 |

Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
anonymous_namespace{test_utils.hpp}::stack_balance_checker Class Reference

Ensures that the Lua stack maintains its original height upon exit. More...

`#include <test_utils.hpp>`

## Public Member Functions
| stack_balance_checker (lutok::state &state_, const bool with_sentinel_=true)
| Constructs a new stack balance checker.
| ~stack_balance_checker (void)
| Destructor for the object.

## Private Attributes
lutok::state & | _state
| The Lua state.
bool | _with_sentinel
| Whether to install a sentinel on the stack for balance enforcement.
unsigned int | _old_count
| The height of the stack on creation.

## Detailed Description

Ensures that the Lua stack maintains its original height upon exit.

Use an instance of this class to check that a piece of code does not have side-effects on the Lua stack.

To be used within a test case only.

## Constructor & Destructor Documentation

## ◆ stack_balance_checker()

anonymous_namespace{test_utils.hpp}::stack_balance_checker::stack_balance_checker | ( | lutok::state & | state_,
|  | const bool | with_sentinel_ = true )
| inline

Constructs a new stack balance checker.

Parameters

  state_ | The Lua state to validate.
  with_sentinel_ | If true, insert a sentinel item into the stack and validate upon exit that the item is still there. This is an attempt to ensure that already-existing items are not removed from the stack by the code under test.

## ◆ ~stack_balance_checker()

anonymous_namespace{test_utils.hpp}::stack_balance_checker::~stack_balance_checker | ( | void |  | ) |
| inline

Destructor for the object.

If the stack height does not match the height when the instance was created, this fails the test case.

The documentation for this class was generated from the following file:

- test_utils.hpp