MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / TestCppFunction

Function TestCppFunction

Source/TestBase/TestLua.cpp:46–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46static void TestCppFunction(LuaCpp::State &lua) {
47 // Register function pointer to Lua
48 lua["sum"].SetFunc(::sum);
49 lua("ret = sum(1, 2)");
50 assert(lua["ret"] == 3);
51
52 // Register lambda to Lua
53 lua["sub"].SetFunc([](int a, int b) {
54 return a - b;
55 });
56 lua("ret = sub(1, 2)");
57 assert(lua["ret"] == -1);
58}
59
60class Base {
61public:

Callers 1

TestLuaFunction · 0.85

Calls 2

SetFuncMethod · 0.80
luaClass · 0.50

Tested by

no test coverage detected