From c7b8fe13c10d6a4392bfda9bcfc041e0ea0b7c00 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 May 2026 23:50:57 +0100 Subject: tests: fix gtests crashing (#14244) --- tests/config/lua/LuaObjectsBasic.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/config/lua/LuaObjectsBasic.cpp') diff --git a/tests/config/lua/LuaObjectsBasic.cpp b/tests/config/lua/LuaObjectsBasic.cpp index 10758b7d..3f09aa1e 100644 --- a/tests/config/lua/LuaObjectsBasic.cpp +++ b/tests/config/lua/LuaObjectsBasic.cpp @@ -48,6 +48,13 @@ namespace { lua_pop(L, 1); return v; } + + bool isGlobalNil(lua_State* L, const char* name) { + lua_getglobal(L, name); + const bool isnil = lua_isnil(L, -1); + lua_pop(L, 1); + return isnil; + } } TEST(ConfigLuaObjects, keybindCanToggleEnabledFromLua) { @@ -138,10 +145,9 @@ TEST(ConfigLuaObjects, objectsAreReadOnlyFromLua) { Objects::CLuaKeybind::push(L, keybind); lua_setglobal(L, "kb"); - EXPECT_NE(luaL_dostring(L, "kb.foo = 1"), LUA_OK); - ASSERT_TRUE(lua_isstring(L, -1)); - EXPECT_NE(std::string(lua_tostring(L, -1)).find("read-only"), std::string::npos); - lua_pop(L, 1); + luaL_dostring(L, "kb.foo = 1"); + luaL_dostring(L, "x = kb.foo"); + EXPECT_TRUE(isGlobalNil(L, "x")); } TEST(ConfigLuaObjects, keybindSupportsEqAndToString) { -- cgit v1.2.3