mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-16 08:07:51 +00:00
tested ignores
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@25 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -18,7 +18,7 @@ class CMockGeneratorPluginIgnore
|
||||
end
|
||||
|
||||
def mock_function_declarations(function_name, function_args, function_return_type)
|
||||
if (function_args == "void")
|
||||
if (function_return_type == "void")
|
||||
return "void #{function_name}_Ignore(void);\n"
|
||||
else
|
||||
return "void #{function_name}_IgnoreAndReturn(#{function_return_type} toReturn);\n"
|
||||
|
||||
@@ -16,4 +16,104 @@ class CMockGeneratorPluginIgnoreTest < Test::Unit::TestCase
|
||||
assert_equal(@utils, @cmock_generator_plugin_ignore.utils)
|
||||
assert_equal(" ", @cmock_generator_plugin_ignore.tab)
|
||||
end
|
||||
|
||||
should "not have no additional include file requirements" do
|
||||
assert_equal([], @cmock_generator_plugin_ignore.include_files)
|
||||
end
|
||||
|
||||
should "add a required variable to the instance structure" do
|
||||
function_name = "Grass"
|
||||
function_args_as_array = []
|
||||
function_return_type = "void"
|
||||
|
||||
@config.expect.ignore_bool_type.returns("BOOL")
|
||||
|
||||
expected = " BOOL Grass_IgnoreBool;\n"
|
||||
returned = @cmock_generator_plugin_ignore.instance_structure(function_name, function_args_as_array, function_return_type)
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "handle function declarations for functions without return values" do
|
||||
function_name = "Mold"
|
||||
function_args = "void"
|
||||
function_return_type = "void"
|
||||
|
||||
expected = "void Mold_Ignore(void);\n"
|
||||
returned = @cmock_generator_plugin_ignore.mock_function_declarations(function_name, function_args, function_return_type)
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "handle function declarations for functions that returns something" do
|
||||
function_name = "Fungus"
|
||||
function_args = "void"
|
||||
function_return_type = "const char*"
|
||||
|
||||
expected = "void Fungus_IgnoreAndReturn(const char* toReturn);\n"
|
||||
returned = @cmock_generator_plugin_ignore.mock_function_declarations(function_name, function_args, function_return_type)
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "add required code to implementation prefix" do
|
||||
function_name = "Mold"
|
||||
function_args = "void"
|
||||
function_return_type = "void"
|
||||
|
||||
@utils.expect.make_handle_return(function_name, function_return_type, " ").returns(" mock_return_1")
|
||||
|
||||
expected = [" if (!Mock.Mold_IgnoreBool)\n",
|
||||
" {\n",
|
||||
" mock_return_1",
|
||||
" }\n"
|
||||
]
|
||||
returned = @cmock_generator_plugin_ignore.mock_implementation_prefix(function_name, function_return_type)
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "have nothing new for mock implementation" do
|
||||
assert_equal([], @cmock_generator_plugin_ignore.mock_implementation("Ooze", []))
|
||||
end
|
||||
|
||||
should "add a new mock interface for ignoring when function had no return value" do
|
||||
function_name = "Slime"
|
||||
function_args = "void"
|
||||
function_args_as_array = []
|
||||
function_return_type = "void"
|
||||
|
||||
expected = ["void Slime_Ignore(void)\n",
|
||||
"{\n",
|
||||
" Mock.Slime_IgnoreBool = (unsigned char)1;\n",
|
||||
"}\n\n"
|
||||
]
|
||||
returned = @cmock_generator_plugin_ignore.mock_interfaces(function_name, function_args, function_args_as_array, function_return_type)
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "add a new mock interface for ignoring when function has return value" do
|
||||
function_name = "Slime"
|
||||
function_args = "void"
|
||||
function_args_as_array = []
|
||||
function_return_type = "uint32"
|
||||
|
||||
@utils.expect.make_expand_array("uint32", "Mock.Slime_Return_Head", "toReturn").returns("mock_return_1")
|
||||
|
||||
expected = ["void Slime_IgnoreAndReturn(uint32 toReturn)\n",
|
||||
"{\n",
|
||||
" Mock.Slime_IgnoreBool = (unsigned char)1;\n",
|
||||
"mock_return_1",
|
||||
" Mock.Slime_Return = Mock.Slime_Return_Head;\n",
|
||||
" Mock.Slime_Return += Mock.Slime_CallCount;\n",
|
||||
"}\n\n"
|
||||
]
|
||||
returned = @cmock_generator_plugin_ignore.mock_interfaces(function_name, function_args, function_args_as_array, function_return_type)
|
||||
assert_equal(expected, returned)
|
||||
end
|
||||
|
||||
should "have nothing new for mock verify" do
|
||||
assert_equal([], @cmock_generator_plugin_ignore.mock_verify("Ooze"))
|
||||
end
|
||||
|
||||
|
||||
should "have nothing new for mock destroy" do
|
||||
assert_equal([], @cmock_generator_plugin_ignore.mock_destroy("Ooze", [], "void"))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user