diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-05-01 23:50:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-01 23:50:57 +0100 |
| commit | c7b8fe13c10d6a4392bfda9bcfc041e0ea0b7c00 (patch) | |
| tree | b305320b07c3f603ae37b19a64c34066fe848443 /tests | |
| parent | 6e1fcfa81e55a7d78e40fdb5c41700c18b0e1268 (diff) | |
tests: fix gtests crashing (#14244)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/config/lua/LuaObjectsBasic.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
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) { |
