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);
 }
Beispiel #5
0
	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 luaReturnsEnum0_resultIsEqualToEnum0()
	{
		m_lua->register_class<ClassWithEnums>();
		m_lua->run_chunk("return ClassWithEnums.ENUM_0");
		ClassWithEnums::ClassEnum return_value = ClassWithEnums::ENUM_1;
		OOLUA::pull(*m_lua, return_value);
		CPPUNIT_ASSERT_EQUAL(ClassWithEnums::ENUM_0, return_value);
	}
Beispiel #7
0
	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"));
	}
Beispiel #8
0
	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"));
	}
Beispiel #9
0
	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);
		
	}
Beispiel #10
0
	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);
	}
Beispiel #11
0
	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);
	}
Beispiel #12
0
	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);
	}
Beispiel #13
0
	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);
		
	}