Lutok  0.4
 All Classes Namespaces Files Functions Variables Macros
Public Member Functions | Private Attributes
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>

List of all members.

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

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.
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: