void globalData_addFuncToGlobalThenCall_callReturnsTrue() { OOLUA::set_global(*m_lua, "global_func", dummy_c_function_returns_stack_count); bool result = m_lua->call("global_func"); CPPUNIT_ASSERT_EQUAL(true,result); }
void inOutTraitRef_luaPassesInt_functionReceivesInputedValue() { InOutParamHelper helper(m_lua); EXPECT_CALL(helper.mock, ref(::testing::Eq(helper.input))).Times(1); m_lua->run_chunk("return function(object, input) return object:ref(input) end"); m_lua->call(1, helper.object, helper.input); }
/**[IntegerInOutParamUsage]*/ void inOutTraitRef_luaPassesIntCppAssignsNewValue_returnIsNewlyAssignedValue() { InOutParamHelper helper(m_lua); EXPECT_CALL(helper.mock, ref(::testing::_)).Times(1).WillOnce(::testing::SetArgReferee<0>(helper.expected)); m_lua->run_chunk("return function(object) return object:ref(1) end"); m_lua->call(1, helper.object); assert_top_of_stack_is_expected_value(helper.expected); }
void inOutTraitRef_luaPassesInt_functionPushesBackNumber() { m_lua->register_class<IntegerFunctionInOutTraits>(); ::testing::NiceMock<IntegerFunctionInOutTraitsMock> fake; m_lua->run_chunk("return function(object) return object:ref(1) end"); m_lua->call(1, static_cast<IntegerFunctionInOutTraits*>(&fake)); CPPUNIT_ASSERT_EQUAL(LUA_TNUMBER, lua_type(*m_lua, -1)); }
void outTraitPtr_luaDoesNotPassIntCppAssignsNewValue_returnIsNewlyAssignedValue() { OutParamHelper helper(m_lua); EXPECT_CALL(helper.mock, ptr(::testing::_)).Times(1).WillOnce(::testing::SetArgumentPointee<0>(helper.expected)); m_lua->run_chunk("return function(object) return object:ptr() end"); m_lua->call(1, helper.object); assert_top_of_stack_is_expected_value(helper.expected); }
void constructWithEnum_passedString_throwsOoluaRuntimeError() { m_lua->register_class<Enums>(); m_lua->run_chunk("foo = function() " "local obj = Enums:new('foo') " "end"); CPPUNIT_ASSERT_THROW(m_lua->call("foo"),OOLUA::Runtime_error); }
void constructWithEnum_passedCoroutine_callReturnsFalse() { m_lua->register_class<Enums>(); m_lua->run_chunk("foo = function() " "local obj = Enums:new( coroutine.create (foo)) " "end"); CPPUNIT_ASSERT_EQUAL(false,m_lua->call("foo")); }
void constructWithEnum_passedString_callReturnsFalse() { m_lua->register_class<Enums>(); m_lua->run_chunk("foo = function() " "local obj = Enums:new('foo') " "end"); CPPUNIT_ASSERT_EQUAL(false,m_lua->call("foo")); }
void globalData_addIntGlobalThenReturnItFromFunction_callReturnsTrue() { int input(1); OOLUA::set_global(*m_lua, "i", input); m_lua->run_chunk("foo = function() return i end"); bool result = m_lua->call("foo"); CPPUNIT_ASSERT_EQUAL(true,result); }
void globalData_addIntGlobalThenReturnItFromFunction_resultEqualsInput() { int input(1); OOLUA::set_global(*m_lua, "i", input); m_lua->run_chunk("foo = function() return i end"); m_lua->call("foo"); int result; OOLUA::pull2cpp(*m_lua,result); CPPUNIT_ASSERT_EQUAL(input,result); }
void constructWithEnum_passedValueGreen_functionReturnsGreen() { m_lua->register_class<Enums>(); m_lua->run_chunk("foo = function() " "local obj = Enums:new(Enums.GREEN) " "return obj:get_enum() " "end"); Enums::COLOUR result(Enums::INVALID); m_lua->call("foo"); OOLUA::pull2cpp(*m_lua,result); CPPUNIT_ASSERT_EQUAL(Enums::GREEN,result); }
void memberFunctionSetsEnum_passedGreen_resultIsGreen() { m_lua->register_class<Enums>(); m_lua->run_chunk("foo = function() " "local obj = Enums:new() " "obj:set_enum(obj.GREEN) " "return obj:get_enum() " "end"); Enums::COLOUR result(Enums::INVALID); m_lua->call("foo"); OOLUA::pull2cpp(*m_lua,result); CPPUNIT_ASSERT_EQUAL(Enums::GREEN,result); }
void memberFunction_returnsEnum_defaultValueIsInvalid() { m_lua->register_class<Enums>(); m_lua->run_chunk("foo = function() " "local obj = Enums:new() " "return obj:get_enum() " "end"); Enums::COLOUR result(Enums::GREEN); m_lua->call("foo"); OOLUA::pull2cpp(*m_lua,result); CPPUNIT_ASSERT_EQUAL(Enums::INVALID,result); }