TEST_F(LuaFunctionTest, Call) { { ScopedLuaStackTest stackTest(L); // Test execution with failure LuaFunction function = LuaFunction::createFromCode(L, "invalid()"); ASSERT_THROW(function.call(), luacpp::LuaException); ASSERT_THROW(function(), luacpp::LuaException); } { ScopedLuaStackTest stackTest(L); // Test execution without failure LuaFunction function = LuaFunction::createFromCode(L, "local a = 1"); ASSERT_NO_THROW(function.call()); ASSERT_NO_THROW(function()); } { ScopedLuaStackTest stackTest(L); // Test execution without failure LuaFunction function = LuaFunction::createFromCode(L, "return 'abc', 5"); LuaValueList returnValues = function(); ASSERT_EQ(luacpp::ValueType::STRING, returnValues[0].getValueType()); ASSERT_EQ(luacpp::ValueType::NUMBER, returnValues[1].getValueType()); ASSERT_STREQ("abc", returnValues[0].getValue<std::string>().c_str()); ASSERT_EQ(5, returnValues[1].getValue<int>()); } { ScopedLuaStackTest stackTest(L); lua_getglobal(L, "type"); LuaFunction func; ASSERT_TRUE(convert::popValue(L, func)); LuaValue arg = LuaValue::createValue(L, "testString"); LuaValueList returnVals = func({ arg }); ASSERT_EQ(1, (int)returnVals.size()); ASSERT_EQ(ValueType::STRING, returnVals[0].getValueType()); ASSERT_STREQ("string", returnVals[0].getValue<std::string>().c_str()); } }