36#if !defined(LUTOK_TEST_UTILS_HPP)
37# define LUTOK_TEST_UTILS_HPP
39# error "test_utils.hpp can only be included once"
61#define REQUIRE_API_ERROR(exp_api_function, statement) \
65 ATF_FAIL("api_error not raised by " #statement); \
66 } catch (const lutok::api_error& api_error) { \
67 ATF_REQUIRE_EQ(exp_api_function, api_error.api_function()); \
79static inline lua_State*
111 const bool with_sentinel_ =
true) :
117 _state.push_integer(987654321);
127 if (!
_state.is_number(-1) ||
_state.to_integer(-1) != 987654321)
128 ATF_FAIL(
"Stack corrupted: sentinel not found");
132 unsigned int new_count =
_state.get_top();
136 ATF_FAIL(
"Stack not balanced");
Provides direct access to the C state of the Lua wrappers.
Provides the state wrapper class for the Lua C state.
Exception types raised by lutok.
static lua_State * raw(lutok::state &state)
Gets the pointer to the internal lua_State of a state object.
Definition test_utils.hpp:80
Gateway to the raw C state of Lua.
Definition c_gate.hpp:55
lua_State * c_state(void)
Returns the C native Lua state.
Definition c_gate.cpp:73
A RAII model for the Lua state.
Definition state.hpp:71
stack_balance_checker(lutok::state &state_, const bool with_sentinel_=true)
Constructs a new stack balance checker.
Definition test_utils.hpp:110
~stack_balance_checker(void)
Destructor for the object.
Definition test_utils.hpp:124
lutok::state & _state
The Lua state.
Definition test_utils.hpp:94
unsigned int _old_count
The height of the stack on creation.
Definition test_utils.hpp:100
bool _with_sentinel
Whether to install a sentinel on the stack for balance enforcement.
Definition test_utils.hpp:97