mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-13 20:37:26 +00:00
Merge branch 'feature/less_const'
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
* text=auto
|
||||||
|
|
||||||
|
# These files are text and should be normalized (convert crlf to lf)
|
||||||
|
*.rb text
|
||||||
|
*.test text
|
||||||
|
*.c text
|
||||||
|
*.cpp text
|
||||||
|
*.h text
|
||||||
|
*.txt text
|
||||||
|
*.yml text
|
||||||
|
*.s79 text
|
||||||
|
*.bat text
|
||||||
|
*.xcl text
|
||||||
|
*.inc text
|
||||||
|
*.info text
|
||||||
|
*.md text
|
||||||
|
makefile text
|
||||||
|
rakefile text
|
||||||
|
|
||||||
|
|
||||||
|
#These files are binary and should not be normalized
|
||||||
|
*.doc binary
|
||||||
|
*.odt binary
|
||||||
|
*.pdf binary
|
||||||
|
*.ewd binary
|
||||||
|
*.eww binary
|
||||||
|
*.dni binary
|
||||||
|
*.wsdt binary
|
||||||
|
*.dbgdt binary
|
||||||
|
*.mac binary
|
||||||
@@ -62,7 +62,9 @@ namespace :test do
|
|||||||
|
|
||||||
desc "Run C Unit Tests"
|
desc "Run C Unit Tests"
|
||||||
task :c => [:prep_system_tests] do
|
task :c => [:prep_system_tests] do
|
||||||
build_and_test_c_files
|
unless ($cfg['unsupported'].include? "C")
|
||||||
|
build_and_test_c_files
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run System Tests"
|
desc "Run System Tests"
|
||||||
|
|||||||
+17
-6
@@ -68,7 +68,7 @@ class CMockGenerator
|
|||||||
|
|
||||||
def create_mock_source_file(parsed_stuff)
|
def create_mock_source_file(parsed_stuff)
|
||||||
@file_writer.create_file(@mock_name + ".c", @subdir) do |file, filename|
|
@file_writer.create_file(@mock_name + ".c", @subdir) do |file, filename|
|
||||||
create_source_header_section(file, filename)
|
create_source_header_section(file, filename, parsed_stuff[:functions])
|
||||||
create_instance_structure(file, parsed_stuff[:functions])
|
create_instance_structure(file, parsed_stuff[:functions])
|
||||||
create_extern_declarations(file)
|
create_extern_declarations(file)
|
||||||
create_mock_verify_function(file, parsed_stuff[:functions])
|
create_mock_verify_function(file, parsed_stuff[:functions])
|
||||||
@@ -120,7 +120,7 @@ class CMockGenerator
|
|||||||
header << "\n#endif\n"
|
header << "\n#endif\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_source_header_section(file, filename)
|
def create_source_header_section(file, filename, functions)
|
||||||
header_file = (@subdir ? @subdir + '/' : '') + filename.gsub(".c",".h")
|
header_file = (@subdir ? @subdir + '/' : '') + filename.gsub(".c",".h")
|
||||||
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
|
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
|
||||||
file << "#include <string.h>\n"
|
file << "#include <string.h>\n"
|
||||||
@@ -132,6 +132,15 @@ class CMockGenerator
|
|||||||
file << "#include \"#{header_file}\"\n"
|
file << "#include \"#{header_file}\"\n"
|
||||||
@includes_c_post_header.each {|inc| file << "#include #{inc}\n"}
|
@includes_c_post_header.each {|inc| file << "#include #{inc}\n"}
|
||||||
file << "\n"
|
file << "\n"
|
||||||
|
strs = []
|
||||||
|
functions.each do |func|
|
||||||
|
strs << func[:name]
|
||||||
|
func[:args].each {|arg| strs << arg[:name] }
|
||||||
|
end
|
||||||
|
strs.uniq.sort.each do |str|
|
||||||
|
file << "static const char* CMockString_#{str} = \"#{str}\";\n"
|
||||||
|
end
|
||||||
|
file << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_instance_structure(file, functions)
|
def create_instance_structure(file, functions)
|
||||||
@@ -199,20 +208,22 @@ class CMockGenerator
|
|||||||
file << "#{function_mod_and_rettype} #{function[:name]}(#{args_string})\n"
|
file << "#{function_mod_and_rettype} #{function[:name]}(#{args_string})\n"
|
||||||
file << "{\n"
|
file << "{\n"
|
||||||
file << " UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n"
|
file << " UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n"
|
||||||
|
file << " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n"
|
||||||
file << " CMOCK_#{function[:name]}_CALL_INSTANCE* cmock_call_instance = (CMOCK_#{function[:name]}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.#{function[:name]}_CallInstance);\n"
|
file << " CMOCK_#{function[:name]}_CALL_INSTANCE* cmock_call_instance = (CMOCK_#{function[:name]}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.#{function[:name]}_CallInstance);\n"
|
||||||
file << " Mock.#{function[:name]}_CallInstance = CMock_Guts_MemNext(Mock.#{function[:name]}_CallInstance);\n"
|
file << " Mock.#{function[:name]}_CallInstance = CMock_Guts_MemNext(Mock.#{function[:name]}_CallInstance);\n"
|
||||||
file << @plugins.run(:mock_implementation_precheck, function)
|
file << @plugins.run(:mock_implementation_precheck, function)
|
||||||
file << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"Function '#{function[:name]}' called more times than expected.\");\n"
|
file << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);\n"
|
||||||
file << " cmock_line = cmock_call_instance->LineNumber;\n"
|
file << " cmock_line = cmock_call_instance->LineNumber;\n"
|
||||||
if (@ordered)
|
if (@ordered)
|
||||||
file << " if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)\n"
|
file << " if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)\n"
|
||||||
file << " UNITY_TEST_FAIL(cmock_line, \"Function '#{function[:name]}' called earlier than expected.\");\n"
|
file << " UNITY_TEST_FAIL(cmock_line, CMockStringCalledEarly);\n"
|
||||||
file << " if (cmock_call_instance->CallOrder < GlobalVerifyOrder)\n"
|
file << " if (cmock_call_instance->CallOrder < GlobalVerifyOrder)\n"
|
||||||
file << " UNITY_TEST_FAIL(cmock_line, \"Function '#{function[:name]}' called later than expected.\");\n"
|
file << " UNITY_TEST_FAIL(cmock_line, CMockStringCalledLate);\n"
|
||||||
# file << " UNITY_TEST_ASSERT((cmock_call_instance->CallOrder == ++GlobalVerifyOrder), cmock_line, \"Out of order function calls. Function '#{function[:name]}'\");\n"
|
# file << " UNITY_TEST_ASSERT((cmock_call_instance->CallOrder == ++GlobalVerifyOrder), cmock_line, CMockStringCallOrder);\n"
|
||||||
end
|
end
|
||||||
return_type = function[:return][:const?] ? "(const #{function[:return][:type]})" : ((function[:return][:type] =~ /cmock/) ? "(#{function[:return][:type]})" : '')
|
return_type = function[:return][:const?] ? "(const #{function[:return][:type]})" : ((function[:return][:type] =~ /cmock/) ? "(#{function[:return][:type]})" : '')
|
||||||
file << @plugins.run(:mock_implementation, function)
|
file << @plugins.run(:mock_implementation, function)
|
||||||
|
file << " UNITY_CLR_DETAILS();\n"
|
||||||
file << " return #{return_type}cmock_call_instance->ReturnVal;\n" unless (function[:return][:void?])
|
file << " return #{return_type}cmock_call_instance->ReturnVal;\n" unless (function[:return][:void?])
|
||||||
file << "}\n\n"
|
file << "}\n\n"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class CMockGeneratorPluginCexception
|
|||||||
|
|
||||||
def mock_implementation(function)
|
def mock_implementation(function)
|
||||||
" if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n {\n" +
|
" if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n {\n" +
|
||||||
|
" UNITY_CLR_DETAILS();\n" +
|
||||||
" Throw(cmock_call_instance->ExceptionToThrow);\n }\n"
|
" Throw(cmock_call_instance->ExceptionToThrow);\n }\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -75,12 +75,14 @@ class CMockGeneratorPluginExpect
|
|||||||
lines << @utils.code_add_base_expectation(func_name)
|
lines << @utils.code_add_base_expectation(func_name)
|
||||||
lines << @utils.code_call_argument_loader(function)
|
lines << @utils.code_call_argument_loader(function)
|
||||||
lines << @utils.code_assign_argument_quickly("cmock_call_instance->ReturnVal", function[:return]) unless (function[:return][:void?])
|
lines << @utils.code_assign_argument_quickly("cmock_call_instance->ReturnVal", function[:return]) unless (function[:return][:void?])
|
||||||
|
lines << " UNITY_CLR_DETAILS();\n"
|
||||||
lines << "}\n\n"
|
lines << "}\n\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_verify(function)
|
def mock_verify(function)
|
||||||
func_name = function[:name]
|
func_name = function[:name]
|
||||||
" UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.#{func_name}_CallInstance, cmock_line, \"Function '#{func_name}' called less times than expected.\");\n"
|
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n" +
|
||||||
|
" UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.#{func_name}_CallInstance, cmock_line, CMockStringCalledLess);\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class CMockGeneratorPluginIgnore
|
|||||||
|
|
||||||
def mock_implementation_precheck(function)
|
def mock_implementation_precheck(function)
|
||||||
lines = " if (Mock.#{function[:name]}_IgnoreBool)\n {\n"
|
lines = " if (Mock.#{function[:name]}_IgnoreBool)\n {\n"
|
||||||
|
lines << " UNITY_CLR_DETAILS();\n"
|
||||||
if (function[:return][:void?])
|
if (function[:return][:void?])
|
||||||
lines << " return;\n }\n"
|
lines << " return;\n }\n"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class CMockGeneratorPluginIgnoreArg
|
|||||||
lines << "{\n"
|
lines << "{\n"
|
||||||
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
|
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
|
||||||
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
|
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
|
||||||
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"#{arg_name} IgnoreArg called before Expect on '#{func_name}'.\");\n"
|
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);\n"
|
||||||
lines << " cmock_call_instance->IgnoreArg_#{arg_name} = 1;\n"
|
lines << " cmock_call_instance->IgnoreArg_#{arg_name} = 1;\n"
|
||||||
lines << "}\n\n"
|
lines << "}\n\n"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class CMockGeneratorPluginReturnThruPtr
|
|||||||
|
|
||||||
def initialize(config, utils)
|
def initialize(config, utils)
|
||||||
@utils = utils
|
@utils = utils
|
||||||
@priority = 1
|
@priority = 1 #TODO: it's 1 to come before ignore_arg returns... but should be after expects otherwise (like 9)
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance_typedefs(function)
|
def instance_typedefs(function)
|
||||||
@@ -46,7 +46,7 @@ class CMockGeneratorPluginReturnThruPtr
|
|||||||
lines << "{\n"
|
lines << "{\n"
|
||||||
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
|
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
|
||||||
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
|
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
|
||||||
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"#{arg_name} ReturnThruPtr called before Expect on '#{func_name}'.\");\n"
|
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringPtrPreExp);\n"
|
||||||
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Used = 1;\n"
|
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Used = 1;\n"
|
||||||
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Val = #{arg_name};\n"
|
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Val = #{arg_name};\n"
|
||||||
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Size = cmock_size;\n"
|
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Size = cmock_size;\n"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CMockGeneratorUtils
|
|||||||
def code_add_base_expectation(func_name, global_ordering_supported=true)
|
def code_add_base_expectation(func_name, global_ordering_supported=true)
|
||||||
lines = " CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_#{func_name}_CALL_INSTANCE));\n"
|
lines = " CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_#{func_name}_CALL_INSTANCE));\n"
|
||||||
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = (CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n"
|
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = (CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n"
|
||||||
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n"
|
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n"
|
||||||
lines << " memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n"
|
lines << " memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n"
|
||||||
lines << " Mock.#{func_name}_CallInstance = CMock_Guts_MemChain(Mock.#{func_name}_CallInstance, cmock_guts_index);\n"
|
lines << " Mock.#{func_name}_CallInstance = CMock_Guts_MemChain(Mock.#{func_name}_CallInstance, cmock_guts_index);\n"
|
||||||
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n" if (@ignore)
|
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n" if (@ignore)
|
||||||
@@ -121,30 +121,31 @@ class CMockGeneratorUtils
|
|||||||
lines = ""
|
lines = ""
|
||||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||||
lines << " {\n"
|
lines << " {\n"
|
||||||
|
lines << " UNITY_SET_DETAILS(CMockString_#{function[:name]},CMockString_#{arg_name});\n"
|
||||||
case(unity_func)
|
case(unity_func)
|
||||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY"
|
when "UNITY_TEST_ASSERT_EQUAL_MEMORY"
|
||||||
c_type_local = c_type.gsub(/\*$/,'')
|
c_type_local = c_type.gsub(/\*$/,'')
|
||||||
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type_local}), cmock_line, \"#{unity_msg}\");\n"
|
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type_local}), cmock_line, CMockStringMismatch);\n"
|
||||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
||||||
if (pre == '&')
|
if (pre == '&')
|
||||||
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), cmock_line, \"#{unity_msg}\");\n"
|
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), cmock_line, CMockStringMismatch);\n"
|
||||||
else
|
else
|
||||||
lines << " if (#{pre}#{expected} == NULL)\n"
|
lines << " if (#{pre}#{expected} == NULL)\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
|
||||||
lines << " else\n"
|
lines << " else\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), cmock_line, \"#{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), cmock_line, CMockStringMismatch); }\n"
|
||||||
end
|
end
|
||||||
when /_ARRAY/
|
when /_ARRAY/
|
||||||
if (pre == '&')
|
if (pre == '&')
|
||||||
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, 1, cmock_line, \"#{unity_msg}\");\n"
|
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, 1, cmock_line, CMockStringMismatch);\n"
|
||||||
else
|
else
|
||||||
lines << " if (#{pre}#{expected} == NULL)\n"
|
lines << " if (#{pre}#{expected} == NULL)\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
|
||||||
lines << " else\n"
|
lines << " else\n"
|
||||||
lines << " { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, 1, cmock_line, \"#{unity_msg}\"); }\n"
|
lines << " { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, 1, cmock_line, CMockStringMismatch); }\n"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\");\n"
|
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, CMockStringMismatch);\n"
|
||||||
end
|
end
|
||||||
lines << " }\n"
|
lines << " }\n"
|
||||||
lines
|
lines
|
||||||
@@ -156,30 +157,31 @@ class CMockGeneratorUtils
|
|||||||
lines = ""
|
lines = ""
|
||||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||||
lines << " {\n"
|
lines << " {\n"
|
||||||
|
lines << " UNITY_SET_DETAILS(CMockString_#{function[:name]},CMockString_#{arg_name});\n"
|
||||||
case(unity_func)
|
case(unity_func)
|
||||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY"
|
when "UNITY_TEST_ASSERT_EQUAL_MEMORY"
|
||||||
c_type_local = c_type.gsub(/\*$/,'')
|
c_type_local = c_type.gsub(/\*$/,'')
|
||||||
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type_local}), cmock_line, \"#{unity_msg}\");\n"
|
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type_local}), cmock_line, CMockStringMismatch);\n"
|
||||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
||||||
if (pre == '&')
|
if (pre == '&')
|
||||||
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), cmock_line, \"#{unity_msg}\");\n"
|
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), cmock_line, CMockStringMismatch);\n"
|
||||||
else
|
else
|
||||||
lines << " if (#{pre}#{expected} == NULL)\n"
|
lines << " if (#{pre}#{expected} == NULL)\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
|
||||||
lines << " else\n"
|
lines << " else\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, \"#{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, CMockStringMismatch); }\n"
|
||||||
end
|
end
|
||||||
when /_ARRAY/
|
when /_ARRAY/
|
||||||
if (pre == '&')
|
if (pre == '&')
|
||||||
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, \"#{unity_msg}\");\n"
|
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, CMockStringMismatch);\n"
|
||||||
else
|
else
|
||||||
lines << " if (#{pre}#{expected} == NULL)\n"
|
lines << " if (#{pre}#{expected} == NULL)\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
|
||||||
lines << " else\n"
|
lines << " else\n"
|
||||||
lines << " { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, \"#{unity_msg}\"); }\n"
|
lines << " { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, CMockStringMismatch); }\n"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\");\n"
|
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, CMockStringMismatch);\n"
|
||||||
end
|
end
|
||||||
lines << " }\n"
|
lines << " }\n"
|
||||||
lines
|
lines
|
||||||
@@ -191,32 +193,33 @@ class CMockGeneratorUtils
|
|||||||
lines = ""
|
lines = ""
|
||||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||||
lines << " {\n"
|
lines << " {\n"
|
||||||
|
lines << " UNITY_SET_DETAILS(CMockString_#{function[:name]},CMockString_#{arg_name});\n"
|
||||||
case(unity_func)
|
case(unity_func)
|
||||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY"
|
when "UNITY_TEST_ASSERT_EQUAL_MEMORY"
|
||||||
c_type_local = c_type.gsub(/\*$/,'')
|
c_type_local = c_type.gsub(/\*$/,'')
|
||||||
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type_local}), cmock_line, \"#{unity_msg}\");\n"
|
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type_local}), cmock_line, CMockStringMismatch);\n"
|
||||||
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
when "UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY"
|
||||||
if (pre == '&')
|
if (pre == '&')
|
||||||
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, \"#{unity_msg}\");\n"
|
lines << " UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, CMockStringMismatch);\n"
|
||||||
else
|
else
|
||||||
lines << " if (#{pre}#{expected} == NULL)\n"
|
lines << " if (#{pre}#{expected} == NULL)\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_NULL(#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_NULL(#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
|
||||||
lines << ((depth_name != 1) ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_PTR(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\"); }\n" : "")
|
lines << ((depth_name != 1) ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_PTR(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, CMockStringMismatch); }\n" : "")
|
||||||
lines << " else\n"
|
lines << " else\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, \"#{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(#{pre}#{expected}), (void*)(#{pre}#{arg_name}), sizeof(#{c_type.sub('*','')}), #{depth_name}, cmock_line, CMockStringMismatch); }\n"
|
||||||
end
|
end
|
||||||
when /_ARRAY/
|
when /_ARRAY/
|
||||||
if (pre == '&')
|
if (pre == '&')
|
||||||
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, \"#{unity_msg}\");\n"
|
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, CMockStringMismatch);\n"
|
||||||
else
|
else
|
||||||
lines << " if (#{pre}#{expected} == NULL)\n"
|
lines << " if (#{pre}#{expected} == NULL)\n"
|
||||||
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, \"Expected NULL. #{unity_msg}\"); }\n"
|
lines << " { UNITY_TEST_ASSERT_NULL(#{pre}#{arg_name}, cmock_line, CMockStringExpNULL); }\n"
|
||||||
lines << ((depth_name != 1) ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_PTR(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\"); }\n" : "")
|
lines << ((depth_name != 1) ? " else if (#{depth_name} == 0)\n { UNITY_TEST_ASSERT_EQUAL_PTR(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, CMockStringMismatch); }\n" : "")
|
||||||
lines << " else\n"
|
lines << " else\n"
|
||||||
lines << " { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, \"#{unity_msg}\"); }\n"
|
lines << " { #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, #{depth_name}, cmock_line, CMockStringMismatch); }\n"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, \"#{unity_msg}\");\n"
|
lines << " #{unity_func}(#{pre}#{expected}, #{pre}#{arg_name}, cmock_line, CMockStringMismatch);\n"
|
||||||
end
|
end
|
||||||
lines << " }\n"
|
lines << " }\n"
|
||||||
lines
|
lines
|
||||||
|
|||||||
+1
-1
@@ -264,7 +264,7 @@ module RakefileHelpers
|
|||||||
# some tests have additional requirements to check for (checking the actual output message)
|
# some tests have additional requirements to check for (checking the actual output message)
|
||||||
if (test[:verify_error]) and not (test_results[index] =~ /test#{index+1}:.*#{test[:verify_error]}/)
|
if (test[:verify_error]) and not (test_results[index] =~ /test#{index+1}:.*#{test[:verify_error]}/)
|
||||||
total_failures += 1
|
total_failures += 1
|
||||||
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:should have output matching '#{test[:verify_error]}'"
|
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:should have output matching '#{test[:verify_error]}' but was '#{test_results[index]}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+12
-1
@@ -5,8 +5,19 @@
|
|||||||
========================================== */
|
========================================== */
|
||||||
|
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
|
#include "cmock.h"
|
||||||
|
|
||||||
#include "cmock_internals.h"
|
//public constants to be used by mocks
|
||||||
|
const char* CMockStringOutOfMemory = "CMock has run out of memory. Please allocate more.";
|
||||||
|
const char* CMockStringCalledMore = "Called more times than expected.";
|
||||||
|
const char* CMockStringCalledLess = "Called less times than expected.";
|
||||||
|
const char* CMockStringCalledEarly = "Called earlier than expected.";
|
||||||
|
const char* CMockStringCalledLate = "Called later than expected.";
|
||||||
|
const char* CMockStringCallOrder = "Called out of order.";
|
||||||
|
const char* CMockStringIgnPreExp = "IgnoreArg called before Expect.";
|
||||||
|
const char* CMockStringPtrPreExp = "ReturnThruPtr called before Expect.";
|
||||||
|
const char* CMockStringExpNULL = "Expected NULL.";
|
||||||
|
const char* CMockStringMismatch = "Function called with unexpected argument value.";
|
||||||
|
|
||||||
//private variables
|
//private variables
|
||||||
#ifdef CMOCK_MEM_DYNAMIC
|
#ifdef CMOCK_MEM_DYNAMIC
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#ifndef CMOCK_FRAMEWORK_H
|
#ifndef CMOCK_FRAMEWORK_H
|
||||||
#define CMOCK_FRAMEWORK_H
|
#define CMOCK_FRAMEWORK_H
|
||||||
|
|
||||||
|
#include "cmock_internals.h"
|
||||||
|
|
||||||
//should be big enough to index full range of CMOCK_MEM_MAX
|
//should be big enough to index full range of CMOCK_MEM_MAX
|
||||||
#ifndef CMOCK_MEM_INDEX_TYPE
|
#ifndef CMOCK_MEM_INDEX_TYPE
|
||||||
#define CMOCK_MEM_INDEX_TYPE unsigned int
|
#define CMOCK_MEM_INDEX_TYPE unsigned int
|
||||||
|
|||||||
+11
-1
@@ -7,7 +7,17 @@
|
|||||||
#ifndef CMOCK_FRAMEWORK_INTERNALS_H
|
#ifndef CMOCK_FRAMEWORK_INTERNALS_H
|
||||||
#define CMOCK_FRAMEWORK_INTERNALS_H
|
#define CMOCK_FRAMEWORK_INTERNALS_H
|
||||||
|
|
||||||
#include "cmock.h"
|
//These are constants that the generated mocks have access to
|
||||||
|
extern const char* CMockStringOutOfMemory;
|
||||||
|
extern const char* CMockStringCalledMore;
|
||||||
|
extern const char* CMockStringCalledLess;
|
||||||
|
extern const char* CMockStringCalledEarly;
|
||||||
|
extern const char* CMockStringCalledLate;
|
||||||
|
extern const char* CMockStringCallOrder;
|
||||||
|
extern const char* CMockStringIgnPreExp;
|
||||||
|
extern const char* CMockStringPtrPreExp;
|
||||||
|
extern const char* CMockStringExpNULL;
|
||||||
|
extern const char* CMockStringMismatch;
|
||||||
|
|
||||||
//define CMOCK_MEM_DYNAMIC to grab memory as needed with malloc
|
//define CMOCK_MEM_DYNAMIC to grab memory as needed with malloc
|
||||||
//when you do that, CMOCK_MEM_SIZE is used for incremental size instead of total
|
//when you do that, CMOCK_MEM_SIZE is used for incremental size instead of total
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ compiler:
|
|||||||
defines:
|
defines:
|
||||||
prefix: '-D'
|
prefix: '-D'
|
||||||
items:
|
items:
|
||||||
|
- CMOCK
|
||||||
- 'UNITY_SUPPORT_64'
|
- 'UNITY_SUPPORT_64'
|
||||||
- 'UNITY_POINTER_WIDTH=64'
|
- 'UNITY_POINTER_WIDTH=64'
|
||||||
object_files:
|
object_files:
|
||||||
@@ -83,6 +84,7 @@ linker:
|
|||||||
destination: *systest_build_path
|
destination: *systest_build_path
|
||||||
|
|
||||||
unsupported:
|
unsupported:
|
||||||
|
- out_of_memory
|
||||||
- callingconv
|
- callingconv
|
||||||
|
|
||||||
colour: true
|
colour: true
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ compiler:
|
|||||||
defines:
|
defines:
|
||||||
prefix: '-D'
|
prefix: '-D'
|
||||||
items:
|
items:
|
||||||
|
- CMOCK
|
||||||
- 'UNITY_SUPPORT_64'
|
- 'UNITY_SUPPORT_64'
|
||||||
object_files:
|
object_files:
|
||||||
prefix: '-o'
|
prefix: '-o'
|
||||||
@@ -50,6 +51,7 @@ linker:
|
|||||||
destination: *systest_build_path
|
destination: *systest_build_path
|
||||||
|
|
||||||
unsupported:
|
unsupported:
|
||||||
|
- out_of_memory
|
||||||
- unity_64bit_support
|
- unity_64bit_support
|
||||||
- callingconv
|
- callingconv
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ compiler:
|
|||||||
defines:
|
defines:
|
||||||
prefix: '-D'
|
prefix: '-D'
|
||||||
items:
|
items:
|
||||||
|
- CMOCK
|
||||||
- 'UNITY_SUPPORT_64'
|
- 'UNITY_SUPPORT_64'
|
||||||
- 'UNITY_POINTER_WIDTH=64'
|
- 'UNITY_POINTER_WIDTH=64'
|
||||||
object_files:
|
object_files:
|
||||||
@@ -51,6 +52,7 @@ linker:
|
|||||||
destination: *systest_build_path
|
destination: *systest_build_path
|
||||||
|
|
||||||
unsupported:
|
unsupported:
|
||||||
|
- out_of_memory
|
||||||
- callingconv
|
- callingconv
|
||||||
|
|
||||||
colour: true
|
colour: true
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
---
|
||||||
|
compiler:
|
||||||
|
path: gcc
|
||||||
|
source_path: &systest_generated_path 'test/system/generated/'
|
||||||
|
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||||
|
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||||
|
build_path: &systest_build_path 'test/system/build/'
|
||||||
|
options:
|
||||||
|
- '-c'
|
||||||
|
- '-Wall'
|
||||||
|
- '-Wextra'
|
||||||
|
- '-Wunused-parameter'
|
||||||
|
- '-Wno-address'
|
||||||
|
- '-Wno-invalid-token-paste'
|
||||||
|
- '-std=c99'
|
||||||
|
- '-pedantic'
|
||||||
|
- '-O0'
|
||||||
|
includes:
|
||||||
|
prefix: '-I'
|
||||||
|
items:
|
||||||
|
- *systest_generated_path
|
||||||
|
- *unit_tests_path
|
||||||
|
- *systest_mocks_path
|
||||||
|
- 'src/'
|
||||||
|
- 'vendor/unity/src/'
|
||||||
|
- 'vendor/c_exception/lib/'
|
||||||
|
- 'test/system/test_compilation/'
|
||||||
|
- 'test/'
|
||||||
|
defines:
|
||||||
|
prefix: '-D'
|
||||||
|
items:
|
||||||
|
- CMOCK
|
||||||
|
- 'CMOCK_MEM_STATIC'
|
||||||
|
- 'CMOCK_MEM_SIZE=1024'
|
||||||
|
object_files:
|
||||||
|
prefix: '-o'
|
||||||
|
extension: '.o'
|
||||||
|
destination: *systest_build_path
|
||||||
|
|
||||||
|
linker:
|
||||||
|
path: gcc
|
||||||
|
options:
|
||||||
|
- -lm
|
||||||
|
includes:
|
||||||
|
prefix: '-I'
|
||||||
|
object_files:
|
||||||
|
path: *systest_build_path
|
||||||
|
extension: '.o'
|
||||||
|
bin_files:
|
||||||
|
prefix: '-o'
|
||||||
|
extension: '.exe'
|
||||||
|
destination: *systest_build_path
|
||||||
|
|
||||||
|
unsupported:
|
||||||
|
- all_plugins_but_other_limits
|
||||||
|
- all_plugins_coexist
|
||||||
|
- array_and_pointer_handling
|
||||||
|
- const_primitives_handling
|
||||||
|
- enforce_strict_ordering
|
||||||
|
- expect_and_return_custom_types
|
||||||
|
- expect_and_return_treat_as
|
||||||
|
- expect_and_throw
|
||||||
|
- expect_any_args
|
||||||
|
- fancy_pointer_handling
|
||||||
|
- function_pointer_handling
|
||||||
|
- newer_standards_stuff1
|
||||||
|
- nonstandard_pased_stuff_1
|
||||||
|
- nonstandard_pased_stuff_2
|
||||||
|
- parsing_challenges
|
||||||
|
- return_thru_ptr_and_expect_any_args
|
||||||
|
- return_thru_ptr_ignore_arg
|
||||||
|
- struct_union_enum_expect_and_return
|
||||||
|
- struct_union_enum_expect_and_return_with_plugins
|
||||||
|
- stubs_with_callbacks
|
||||||
|
- unity_64bit_support
|
||||||
|
- unity_ignores
|
||||||
|
- callingconv
|
||||||
|
- C
|
||||||
|
|
||||||
|
colour: true
|
||||||
@@ -46,6 +46,7 @@ compiler:
|
|||||||
defines:
|
defines:
|
||||||
prefix: '-D'
|
prefix: '-D'
|
||||||
items:
|
items:
|
||||||
|
- CMOCK
|
||||||
object_files:
|
object_files:
|
||||||
prefix: '-o'
|
prefix: '-o'
|
||||||
extension: '.r79'
|
extension: '.r79'
|
||||||
@@ -100,6 +101,7 @@ simulator:
|
|||||||
- sim
|
- sim
|
||||||
|
|
||||||
unsupported:
|
unsupported:
|
||||||
|
- out_of_memory
|
||||||
- nonstandard_parsed_stuff_1
|
- nonstandard_parsed_stuff_1
|
||||||
- const
|
- const
|
||||||
- callingconv
|
- callingconv
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ compiler:
|
|||||||
defines:
|
defines:
|
||||||
prefix: '-D'
|
prefix: '-D'
|
||||||
items:
|
items:
|
||||||
|
- CMOCK
|
||||||
object_files:
|
object_files:
|
||||||
prefix: '-o'
|
prefix: '-o'
|
||||||
extension: '.r79'
|
extension: '.r79'
|
||||||
@@ -85,6 +86,7 @@ simulator:
|
|||||||
- sim
|
- sim
|
||||||
|
|
||||||
unsupported:
|
unsupported:
|
||||||
|
- out_of_memory
|
||||||
- nonstandard_parsed_stuff_1
|
- nonstandard_parsed_stuff_1
|
||||||
- const
|
- const
|
||||||
- callingconv
|
- callingconv
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
========================================== */
|
========================================== */
|
||||||
|
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "cmock_internals.h"
|
#include "cmock.h"
|
||||||
|
|
||||||
#define TEST_MEM_INDEX_SIZE (sizeof(CMOCK_MEM_INDEX_TYPE))
|
#define TEST_MEM_INDEX_SIZE (sizeof(CMOCK_MEM_INDEX_TYPE))
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
- 'vendor/unity/src/unity.c'
|
- 'vendor/unity/src/unity.c'
|
||||||
:options:
|
:options:
|
||||||
- 'TEST'
|
- 'TEST'
|
||||||
|
- 'CMOCK_MEM_STATIC'
|
||||||
- 'CMOCK_MEM_SIZE=128'
|
- 'CMOCK_MEM_SIZE=128'
|
||||||
- 'CMOCK_MEM_ALIGN=2'
|
- 'CMOCK_MEM_ALIGN=2'
|
||||||
- 'CMOCK_MEM_INDEX_TYPE=int'
|
- 'CMOCK_MEM_INDEX_TYPE=int'
|
||||||
|
|||||||
@@ -0,0 +1,308 @@
|
|||||||
|
---
|
||||||
|
:cmock:
|
||||||
|
:enforce_strict_ordering: 1
|
||||||
|
:plugins:
|
||||||
|
- :array
|
||||||
|
- :cexception
|
||||||
|
- :ignore
|
||||||
|
- :callback
|
||||||
|
- :return_thru_ptr
|
||||||
|
- :ignore_arg
|
||||||
|
- :expect_any_args
|
||||||
|
:callback_after_arg_check: false
|
||||||
|
:callback_include_count: false
|
||||||
|
:treat_externs: :include
|
||||||
|
|
||||||
|
:systest:
|
||||||
|
:types: |
|
||||||
|
typedef struct _POINT_T {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
} POINT_T;
|
||||||
|
|
||||||
|
:mockable: |
|
||||||
|
#include "CException.h"
|
||||||
|
extern void foo(POINT_T* a);
|
||||||
|
POINT_T* bar(void);
|
||||||
|
void no_args(void);
|
||||||
|
|
||||||
|
:source:
|
||||||
|
:header: |
|
||||||
|
#include "CException.h"
|
||||||
|
void function_a(void);
|
||||||
|
int function_b(void);
|
||||||
|
|
||||||
|
:code: |
|
||||||
|
void function_a(void)
|
||||||
|
{
|
||||||
|
foo(bar());
|
||||||
|
no_args();
|
||||||
|
}
|
||||||
|
|
||||||
|
int function_b(void)
|
||||||
|
{
|
||||||
|
POINT_T pt = { 1, 2 };
|
||||||
|
foo(&pt);
|
||||||
|
return (pt.x + pt.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
:tests:
|
||||||
|
:common: |
|
||||||
|
#include "CException.h"
|
||||||
|
void setUp(void) {}
|
||||||
|
void tearDown(void) {}
|
||||||
|
void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); }
|
||||||
|
|
||||||
|
:units:
|
||||||
|
- :pass: TRUE
|
||||||
|
:should: 'just pass if we do not insert anything ugly into it'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after an expect and return'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after an expect'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after throw expectation'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_ExpectAndThrow(5);
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
|
||||||
|
Try { function_a(); } Catch(e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after a mock call'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after throw'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_ExpectAndThrow(5);
|
||||||
|
|
||||||
|
Try { function_a(); } Catch(e) {}
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after ignore'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_Ignore();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after ignored mock'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
no_args_Ignore();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after callback setup'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_StubWithCallback(my_foo_callback);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock with callback'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_StubWithCallback(my_foo_callback);
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after expect any args'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_ExpectAnyArgs();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock which expected any args'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_ExpectAnyArgs();
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after ignored arg'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
foo_IgnoreArg_a();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock which ignored an arg'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_Expect(NULL);
|
||||||
|
foo_IgnoreArg_a();
|
||||||
|
no_args_Expect();
|
||||||
|
|
||||||
|
function_a();
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock which threw a CException'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
CEXCEPTION_T e;
|
||||||
|
bar_ExpectAndThrow(0x12);
|
||||||
|
|
||||||
|
Try {
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
Catch(e) {}
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock which used a return thru ptr'
|
||||||
|
#:verify_error: 'FAIL: Expected 3 Was 7. CustomFail' #TODO: put back in once ReturnThruPtr fixed
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt1 = { 1, 2 };
|
||||||
|
POINT_T pt2 = { 3, 4 };
|
||||||
|
|
||||||
|
foo_Expect(&pt1);
|
||||||
|
foo_ReturnThruPtr_a(&pt2);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT(3, function_b());
|
||||||
|
}
|
||||||
|
|
||||||
|
...
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
- :pass: FALSE
|
- :pass: FALSE
|
||||||
:should: 'fail because bar() is called but is not expected'
|
:should: 'fail because bar() is called but is not expected'
|
||||||
:verify_error: 'called more times than expected'
|
:verify_error: 'Called more times than expected'
|
||||||
:code: |
|
:code: |
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
- :pass: FALSE
|
- :pass: FALSE
|
||||||
:should: 'fail because bar() is called twice but is expected once'
|
:should: 'fail because bar() is called twice but is expected once'
|
||||||
:verify_error: 'called less times than expected'
|
:verify_error: 'Called less times than expected'
|
||||||
:code: |
|
:code: |
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
|
|
||||||
- :pass: FALSE
|
- :pass: FALSE
|
||||||
:should: 'fail because bar and foo called in reverse order'
|
:should: 'fail because bar and foo called in reverse order'
|
||||||
:verify_error: 'called earlier than expected'
|
:verify_error: 'Called earlier than expected'
|
||||||
:code: |
|
:code: |
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
@@ -228,7 +228,7 @@
|
|||||||
|
|
||||||
- :pass: FALSE
|
- :pass: FALSE
|
||||||
:should: 'successfully catch errors during back to back ExpectAndReturn setup and mock calls'
|
:should: 'successfully catch errors during back to back ExpectAndReturn setup and mock calls'
|
||||||
:verify_error: 'called earlier than expected'
|
:verify_error: 'Called earlier than expected'
|
||||||
:code: |
|
:code: |
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
:cmock:
|
||||||
|
:plugins: []
|
||||||
|
:treat_as:
|
||||||
|
custom_type: INT
|
||||||
|
|
||||||
|
:systest:
|
||||||
|
:types: |
|
||||||
|
typedef struct _BIG_FAT_STRUCT_T
|
||||||
|
{
|
||||||
|
char bytes[512];
|
||||||
|
} BIG_FAT_STRUCT_T;
|
||||||
|
|
||||||
|
:mockable: |
|
||||||
|
void foo(BIG_FAT_STRUCT_T a);
|
||||||
|
|
||||||
|
:source:
|
||||||
|
:header: |
|
||||||
|
void function_a(void);
|
||||||
|
void function_b(void);
|
||||||
|
|
||||||
|
:code: |
|
||||||
|
void function_a(void)
|
||||||
|
{
|
||||||
|
BIG_FAT_STRUCT_T stuff = { { 8, 0 } };
|
||||||
|
foo(stuff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void function_b(void)
|
||||||
|
{
|
||||||
|
BIG_FAT_STRUCT_T stuff1 = { { 9, 1, 0 } };
|
||||||
|
BIG_FAT_STRUCT_T stuff2 = { { 9, 2, 0 } };
|
||||||
|
foo(stuff1);
|
||||||
|
foo(stuff2);
|
||||||
|
}
|
||||||
|
|
||||||
|
:tests:
|
||||||
|
:common: |
|
||||||
|
void setUp(void) {}
|
||||||
|
void tearDown(void) {}
|
||||||
|
|
||||||
|
:units:
|
||||||
|
- :pass: TRUE
|
||||||
|
:should: 'successfully should be able to run function a because it only takes half the memory'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
BIG_FAT_STRUCT_T expected = { { 8, 0 } };
|
||||||
|
foo_Expect(expected);
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'should error out because we do not have eough memory to handle two of these structures'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
BIG_FAT_STRUCT_T expected1 = { { 9, 1, 0 } };
|
||||||
|
BIG_FAT_STRUCT_T expected2 = { { 9, 2, 0 } };
|
||||||
|
foo_Expect(expected1);
|
||||||
|
foo_Expect(expected2);
|
||||||
|
function_b();
|
||||||
|
}
|
||||||
|
|
||||||
|
...
|
||||||
@@ -267,6 +267,10 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|||||||
|
|
||||||
it "create a proper heading for a source file" do
|
it "create a proper heading for a source file" do
|
||||||
output = []
|
output = []
|
||||||
|
functions = [ { :name => "uno", :args => [ { :name => "arg1" }, { :name => "arg2" } ] },
|
||||||
|
{ :name => "dos", :args => [ { :name => "arg3" }, { :name => "arg2" } ] },
|
||||||
|
{ :name => "tres", :args => [] }
|
||||||
|
]
|
||||||
expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
expected = [ "/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
|
||||||
"#include <string.h>\n",
|
"#include <string.h>\n",
|
||||||
"#include <stdlib.h>\n",
|
"#include <stdlib.h>\n",
|
||||||
@@ -274,10 +278,17 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|||||||
"#include \"unity.h\"\n",
|
"#include \"unity.h\"\n",
|
||||||
"#include \"cmock.h\"\n",
|
"#include \"cmock.h\"\n",
|
||||||
"#include \"MockPoutPoutFish.h\"\n",
|
"#include \"MockPoutPoutFish.h\"\n",
|
||||||
|
"\n",
|
||||||
|
"static const char* CMockString_arg1 = \"arg1\";\n",
|
||||||
|
"static const char* CMockString_arg2 = \"arg2\";\n",
|
||||||
|
"static const char* CMockString_arg3 = \"arg3\";\n",
|
||||||
|
"static const char* CMockString_dos = \"dos\";\n",
|
||||||
|
"static const char* CMockString_tres = \"tres\";\n",
|
||||||
|
"static const char* CMockString_uno = \"uno\";\n",
|
||||||
"\n"
|
"\n"
|
||||||
]
|
]
|
||||||
|
|
||||||
@cmock_generator.create_source_header_section(output, "MockPoutPoutFish.c")
|
@cmock_generator.create_source_header_section(output, "MockPoutPoutFish.c", functions)
|
||||||
|
|
||||||
assert_equal(expected, output)
|
assert_equal(expected, output)
|
||||||
end
|
end
|
||||||
@@ -440,13 +451,15 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|||||||
expected = [ "static int SupaFunction(uint32 sandwiches, const char* named)\n",
|
expected = [ "static int SupaFunction(uint32 sandwiches, const char* named)\n",
|
||||||
"{\n",
|
"{\n",
|
||||||
" UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n",
|
" UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n",
|
||||||
|
" UNITY_SET_DETAIL(CMockString_SupaFunction);\n",
|
||||||
" CMOCK_SupaFunction_CALL_INSTANCE* cmock_call_instance = (CMOCK_SupaFunction_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.SupaFunction_CallInstance);\n",
|
" CMOCK_SupaFunction_CALL_INSTANCE* cmock_call_instance = (CMOCK_SupaFunction_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.SupaFunction_CallInstance);\n",
|
||||||
" Mock.SupaFunction_CallInstance = CMock_Guts_MemNext(Mock.SupaFunction_CallInstance);\n",
|
" Mock.SupaFunction_CallInstance = CMock_Guts_MemNext(Mock.SupaFunction_CallInstance);\n",
|
||||||
" uno",
|
" uno",
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"Function 'SupaFunction' called more times than expected.\");\n",
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);\n",
|
||||||
" cmock_line = cmock_call_instance->LineNumber;\n",
|
" cmock_line = cmock_call_instance->LineNumber;\n",
|
||||||
" dos",
|
" dos",
|
||||||
" tres",
|
" tres",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
" return cmock_call_instance->ReturnVal;\n",
|
" return cmock_call_instance->ReturnVal;\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
]
|
]
|
||||||
@@ -472,13 +485,15 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|||||||
expected = [ "int __stdcall SupaFunction(uint32 sandwiches, corn ...)\n",
|
expected = [ "int __stdcall SupaFunction(uint32 sandwiches, corn ...)\n",
|
||||||
"{\n",
|
"{\n",
|
||||||
" UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n",
|
" UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n",
|
||||||
|
" UNITY_SET_DETAIL(CMockString_SupaFunction);\n",
|
||||||
" CMOCK_SupaFunction_CALL_INSTANCE* cmock_call_instance = (CMOCK_SupaFunction_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.SupaFunction_CallInstance);\n",
|
" CMOCK_SupaFunction_CALL_INSTANCE* cmock_call_instance = (CMOCK_SupaFunction_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.SupaFunction_CallInstance);\n",
|
||||||
" Mock.SupaFunction_CallInstance = CMock_Guts_MemNext(Mock.SupaFunction_CallInstance);\n",
|
" Mock.SupaFunction_CallInstance = CMock_Guts_MemNext(Mock.SupaFunction_CallInstance);\n",
|
||||||
" uno",
|
" uno",
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"Function 'SupaFunction' called more times than expected.\");\n",
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);\n",
|
||||||
" cmock_line = cmock_call_instance->LineNumber;\n",
|
" cmock_line = cmock_call_instance->LineNumber;\n",
|
||||||
" dos",
|
" dos",
|
||||||
" tres",
|
" tres",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
" return cmock_call_instance->ReturnVal;\n",
|
" return cmock_call_instance->ReturnVal;\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -52,8 +52,11 @@ describe CMockGeneratorPluginCexception, "Verify CMockGeneratorPluginCexception
|
|||||||
|
|
||||||
it "add a mock implementation" do
|
it "add a mock implementation" do
|
||||||
function = {:name => "Cherry", :args => [], :return => test_return[:void]}
|
function = {:name => "Cherry", :args => [], :return => test_return[:void]}
|
||||||
expected = " if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n {\n" +
|
expected = " if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n" +
|
||||||
" Throw(cmock_call_instance->ExceptionToThrow);\n }\n"
|
" {\n" +
|
||||||
|
" UNITY_CLR_DETAILS();\n" +
|
||||||
|
" Throw(cmock_call_instance->ExceptionToThrow);\n" +
|
||||||
|
" }\n"
|
||||||
returned = @cmock_generator_plugin_cexception.mock_implementation(function)
|
returned = @cmock_generator_plugin_cexception.mock_implementation(function)
|
||||||
assert_equal(expected, returned)
|
assert_equal(expected, returned)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module"
|
|||||||
"{\n",
|
"{\n",
|
||||||
"mock_retval_0 ",
|
"mock_retval_0 ",
|
||||||
"mock_retval_1 ",
|
"mock_retval_1 ",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
].join
|
].join
|
||||||
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
||||||
@@ -158,6 +159,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module"
|
|||||||
"mock_retval_0 ",
|
"mock_retval_0 ",
|
||||||
"mock_retval_1 ",
|
"mock_retval_1 ",
|
||||||
"mock_retval_2",
|
"mock_retval_2",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
].join
|
].join
|
||||||
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
||||||
@@ -174,6 +176,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module"
|
|||||||
"mock_retval_0 ",
|
"mock_retval_0 ",
|
||||||
"mock_retval_1 ",
|
"mock_retval_1 ",
|
||||||
"mock_retval_2",
|
"mock_retval_2",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
].join
|
].join
|
||||||
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
returned = @cmock_generator_plugin_expect.mock_interfaces(function)
|
||||||
@@ -188,6 +191,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module"
|
|||||||
"{\n",
|
"{\n",
|
||||||
"mock_retval_0 ",
|
"mock_retval_0 ",
|
||||||
"mock_retval_1 ",
|
"mock_retval_1 ",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
].join
|
].join
|
||||||
@cmock_generator_plugin_expect.ordered = true
|
@cmock_generator_plugin_expect.ordered = true
|
||||||
@@ -197,7 +201,8 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module"
|
|||||||
|
|
||||||
it "add mock verify lines" do
|
it "add mock verify lines" do
|
||||||
function = {:name => "Banana" }
|
function = {:name => "Banana" }
|
||||||
expected = " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.Banana_CallInstance, cmock_line, \"Function 'Banana' called less times than expected.\");\n"
|
expected = " UNITY_SET_DETAIL(CMockString_Banana);\n" +
|
||||||
|
" UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.Banana_CallInstance, cmock_line, CMockStringCalledLess);\n"
|
||||||
returned = @cmock_generator_plugin_expect.mock_verify(function)
|
returned = @cmock_generator_plugin_expect.mock_verify(function)
|
||||||
assert_equal(expected, returned)
|
assert_equal(expected, returned)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ describe CMockGeneratorPluginIgnoreArg, "Verify CMockGeneratorPluginIgnoreArg Mo
|
|||||||
"{\n" +
|
"{\n" +
|
||||||
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
||||||
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"chicken IgnoreArg called before Expect on 'Pine'.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);\n" +
|
||||||
" cmock_call_instance->IgnoreArg_chicken = 1;\n" +
|
" cmock_call_instance->IgnoreArg_chicken = 1;\n" +
|
||||||
"}\n\n" +
|
"}\n\n" +
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ describe CMockGeneratorPluginIgnoreArg, "Verify CMockGeneratorPluginIgnoreArg Mo
|
|||||||
"{\n" +
|
"{\n" +
|
||||||
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
||||||
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"beef IgnoreArg called before Expect on 'Pine'.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);\n" +
|
||||||
" cmock_call_instance->IgnoreArg_beef = 1;\n" +
|
" cmock_call_instance->IgnoreArg_beef = 1;\n" +
|
||||||
"}\n\n" +
|
"}\n\n" +
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ describe CMockGeneratorPluginIgnoreArg, "Verify CMockGeneratorPluginIgnoreArg Mo
|
|||||||
"{\n" +
|
"{\n" +
|
||||||
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
||||||
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"tofu IgnoreArg called before Expect on 'Pine'.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);\n" +
|
||||||
" cmock_call_instance->IgnoreArg_tofu = 1;\n" +
|
" cmock_call_instance->IgnoreArg_tofu = 1;\n" +
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ describe CMockGeneratorPluginIgnore, "Verify CMockGeneratorPluginIgnore Module"
|
|||||||
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
function = {:name => "Mold", :args_string => "void", :return => test_return[:void]}
|
||||||
expected = [" if (Mock.Mold_IgnoreBool)\n",
|
expected = [" if (Mock.Mold_IgnoreBool)\n",
|
||||||
" {\n",
|
" {\n",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
" return;\n",
|
" return;\n",
|
||||||
" }\n"
|
" }\n"
|
||||||
].join
|
].join
|
||||||
@@ -65,6 +66,7 @@ describe CMockGeneratorPluginIgnore, "Verify CMockGeneratorPluginIgnore Module"
|
|||||||
@utils.expect :code_assign_argument_quickly, ' mock_retval_0', ["Mock.Fungus_FinalReturn", retval]
|
@utils.expect :code_assign_argument_quickly, ' mock_retval_0', ["Mock.Fungus_FinalReturn", retval]
|
||||||
expected = [" if (Mock.Fungus_IgnoreBool)\n",
|
expected = [" if (Mock.Fungus_IgnoreBool)\n",
|
||||||
" {\n",
|
" {\n",
|
||||||
|
" UNITY_CLR_DETAILS();\n",
|
||||||
" if (cmock_call_instance == NULL)\n",
|
" if (cmock_call_instance == NULL)\n",
|
||||||
" return Mock.Fungus_FinalReturn;\n",
|
" return Mock.Fungus_FinalReturn;\n",
|
||||||
" mock_retval_0",
|
" mock_retval_0",
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ describe CMockGeneratorPluginReturnThruPtr, "Verify CMockGeneratorPluginReturnTh
|
|||||||
"{\n" +
|
"{\n" +
|
||||||
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
" CMOCK_Pine_CALL_INSTANCE* cmock_call_instance = " +
|
||||||
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
"(CMOCK_Pine_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.Pine_CallInstance));\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"tofu ReturnThruPtr called before Expect on 'Pine'.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringPtrPreExp);\n" +
|
||||||
" cmock_call_instance->ReturnThruPtr_tofu_Used = 1;\n" +
|
" cmock_call_instance->ReturnThruPtr_tofu_Used = 1;\n" +
|
||||||
" cmock_call_instance->ReturnThruPtr_tofu_Val = tofu;\n" +
|
" cmock_call_instance->ReturnThruPtr_tofu_Val = tofu;\n" +
|
||||||
" cmock_call_instance->ReturnThruPtr_tofu_Size = cmock_size;\n" +
|
" cmock_call_instance->ReturnThruPtr_tofu_Size = cmock_size;\n" +
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
expected =
|
expected =
|
||||||
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
||||||
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n" +
|
||||||
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
||||||
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
||||||
" cmock_call_instance->LineNumber = cmock_line;\n"
|
" cmock_call_instance->LineNumber = cmock_line;\n"
|
||||||
@@ -70,7 +70,7 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
expected =
|
expected =
|
||||||
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
||||||
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n" +
|
||||||
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
||||||
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
||||||
" Mock.Apple_IgnoreBool = (int)0;\n" +
|
" Mock.Apple_IgnoreBool = (int)0;\n" +
|
||||||
@@ -85,7 +85,7 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
expected =
|
expected =
|
||||||
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
||||||
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
||||||
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n" +
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n" +
|
||||||
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
||||||
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
||||||
" Mock.Apple_IgnoreBool = (int)0;\n" +
|
" Mock.Apple_IgnoreBool = (int)0;\n" +
|
||||||
@@ -204,7 +204,10 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle a simple assert when requested' do
|
it 'handle a simple assert when requested' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:int]
|
arg = test_arg[:int]
|
||||||
expected = " {\n UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_MyInt, MyInt, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyInt'.\");\n }\n"
|
expected = " {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyInt);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_MyInt, MyInt, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT', ''], ['int']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT', ''], ['int']
|
||||||
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -213,14 +216,20 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle a pointer comparison when configured to do so' do
|
it 'handle a pointer comparison when configured to do so' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:int_ptr]
|
arg = test_arg[:int_ptr]
|
||||||
expected = " {\n UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyIntPtr'.\");\n }\n"
|
expected = " {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyIntPtr);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'handle const char as string compares ' do
|
it 'handle const char as string compares ' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:string]
|
arg = test_arg[:string]
|
||||||
expected = " {\n UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_MyStr, MyStr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyStr'.\");\n }\n"
|
expected = " {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyStr);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_MyStr, MyStr, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_STRING',''], ['char*']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_STRING',''], ['char*']
|
||||||
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -229,7 +238,10 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle custom types as memory compares when we have no better way to do it' do
|
it 'handle custom types as memory compares when we have no better way to do it' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:mytype]
|
arg = test_arg[:mytype]
|
||||||
expected = " {\n UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_MyMyType), (void*)(&MyMyType), sizeof(MY_TYPE), cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
expected = " {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyType);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_MyMyType), (void*)(&MyMyType), sizeof(MY_TYPE), cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MEMORY','&'], ['MY_TYPE']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MEMORY','&'], ['MY_TYPE']
|
||||||
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -238,7 +250,10 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle custom types with custom handlers when available, even if they do not support the extra message' do
|
it 'handle custom types with custom handlers when available, even if they do not support the extra message' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:mytype]
|
arg = test_arg[:mytype]
|
||||||
expected = " {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE(cmock_call_instance->Expected_MyMyType, MyMyType, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
expected = " {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyType);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_MY_TYPE(cmock_call_instance->Expected_MyMyType, MyMyType, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE',''], ['MY_TYPE']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE',''], ['MY_TYPE']
|
||||||
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -247,7 +262,10 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle pointers to custom types with array handlers, even if the array extension is turned off' do
|
it 'handle pointers to custom types with array handlers, even if the array extension is turned off' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:mytype]
|
arg = test_arg[:mytype]
|
||||||
expected = " {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(&cmock_call_instance->Expected_MyMyType, &MyMyType, 1, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
expected = " {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyType);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(&cmock_call_instance->Expected_MyMyType, &MyMyType, 1, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY','&'], ['MY_TYPE']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY','&'], ['MY_TYPE']
|
||||||
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_simple.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -256,7 +274,11 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle a simple assert when requested with array plugin enabled' do
|
it 'handle a simple assert when requested with array plugin enabled' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:int]
|
arg = test_arg[:int]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyInt)\n {\n UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_MyInt, MyInt, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyInt'.\");\n }\n"
|
expected = " if (!cmock_call_instance->IgnoreArg_MyInt)\n" +
|
||||||
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyInt);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_MyInt, MyInt, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT',''], ['int']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT',''], ['int']
|
||||||
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -267,12 +289,13 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
arg = test_arg[:int_ptr]
|
arg = test_arg[:int_ptr]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyIntPtr)\n" +
|
expected = " if (!cmock_call_instance->IgnoreArg_MyIntPtr)\n" +
|
||||||
" {\n" +
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyIntPtr);\n" +
|
||||||
" if (cmock_call_instance->Expected_MyIntPtr == NULL)\n" +
|
" if (cmock_call_instance->Expected_MyIntPtr == NULL)\n" +
|
||||||
" { UNITY_TEST_ASSERT_NULL(MyIntPtr, cmock_line, \"Expected NULL. Function 'Pear' called with unexpected value for argument 'MyIntPtr'.\"); }\n" +
|
" { UNITY_TEST_ASSERT_NULL(MyIntPtr, cmock_line, CMockStringExpNULL); }\n" +
|
||||||
" else if (cmock_call_instance->Expected_MyIntPtr_Depth == 0)\n" +
|
" else if (cmock_call_instance->Expected_MyIntPtr_Depth == 0)\n" +
|
||||||
" { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyIntPtr'.\"); }\n" +
|
" { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_line, CMockStringMismatch); }\n" +
|
||||||
" else\n" +
|
" else\n" +
|
||||||
" { UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_call_instance->Expected_MyIntPtr_Depth, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyIntPtr'.\"); }\n" +
|
" { UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(cmock_call_instance->Expected_MyIntPtr, MyIntPtr, cmock_call_instance->Expected_MyIntPtr_Depth, cmock_line, CMockStringMismatch); }\n" +
|
||||||
" }\n"
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT_ARRAY',''], ['int*']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_INT_ARRAY',''], ['int*']
|
||||||
@@ -282,7 +305,11 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle const char as string compares with array plugin enabled' do
|
it 'handle const char as string compares with array plugin enabled' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:string]
|
arg = test_arg[:string]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyStr)\n {\n UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_MyStr, MyStr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyStr'.\");\n }\n"
|
expected = " if (!cmock_call_instance->IgnoreArg_MyStr)\n" +
|
||||||
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyStr);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_MyStr, MyStr, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_STRING',''], ['char*']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_STRING',''], ['char*']
|
||||||
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -291,7 +318,14 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle custom types as memory compares when we have no better way to do it with array plugin enabled' do
|
it 'handle custom types as memory compares when we have no better way to do it with array plugin enabled' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:mytype]
|
arg = test_arg[:mytype]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n {\n if (cmock_call_instance->Expected_MyMyType == NULL)\n { UNITY_TEST_ASSERT_NULL(MyMyType, cmock_line, \"Expected NULL. Function 'Pear' called with unexpected value for argument 'MyMyType'.\"); }\n else\n { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_MyMyType), (void*)(MyMyType), sizeof(MY_TYPE), 1, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\"); }\n }\n"
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n" +
|
||||||
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyType);\n" +
|
||||||
|
" if (cmock_call_instance->Expected_MyMyType == NULL)\n" +
|
||||||
|
" { UNITY_TEST_ASSERT_NULL(MyMyType, cmock_line, CMockStringExpNULL); }\n" +
|
||||||
|
" else\n" +
|
||||||
|
" { UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_MyMyType), (void*)(MyMyType), sizeof(MY_TYPE), 1, cmock_line, CMockStringMismatch); }\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY', ''], ['MY_TYPE']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY', ''], ['MY_TYPE']
|
||||||
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -300,7 +334,11 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle custom types with custom handlers when available, even if they do not support the extra message with array plugin enabled' do
|
it 'handle custom types with custom handlers when available, even if they do not support the extra message with array plugin enabled' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:mytype]
|
arg = test_arg[:mytype]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE(cmock_call_instance->Expected_MyMyType, MyMyType, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n" +
|
||||||
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyType);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_MY_TYPE(cmock_call_instance->Expected_MyMyType, MyMyType, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE', ''], ['MY_TYPE']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE', ''], ['MY_TYPE']
|
||||||
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
||||||
@@ -311,12 +349,13 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
arg = test_arg[:mytype_ptr]
|
arg = test_arg[:mytype_ptr]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyMyTypePtr)\n" +
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyTypePtr)\n" +
|
||||||
" {\n" +
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyTypePtr);\n" +
|
||||||
" if (cmock_call_instance->Expected_MyMyTypePtr == NULL)\n" +
|
" if (cmock_call_instance->Expected_MyMyTypePtr == NULL)\n" +
|
||||||
" { UNITY_TEST_ASSERT_NULL(MyMyTypePtr, cmock_line, \"Expected NULL. Function 'Pear' called with unexpected value for argument 'MyMyTypePtr'.\"); }\n" +
|
" { UNITY_TEST_ASSERT_NULL(MyMyTypePtr, cmock_line, CMockStringExpNULL); }\n" +
|
||||||
" else if (cmock_call_instance->Expected_MyMyTypePtr_Depth == 0)\n" +
|
" else if (cmock_call_instance->Expected_MyMyTypePtr_Depth == 0)\n" +
|
||||||
" { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyMyTypePtr, MyMyTypePtr, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyTypePtr'.\"); }\n" +
|
" { UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_MyMyTypePtr, MyMyTypePtr, cmock_line, CMockStringMismatch); }\n" +
|
||||||
" else\n" +
|
" else\n" +
|
||||||
" { UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(cmock_call_instance->Expected_MyMyTypePtr, MyMyTypePtr, cmock_call_instance->Expected_MyMyTypePtr_Depth, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyTypePtr'.\"); }\n" +
|
" { UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(cmock_call_instance->Expected_MyMyTypePtr, MyMyTypePtr, cmock_call_instance->Expected_MyMyTypePtr_Depth, cmock_line, CMockStringMismatch); }\n" +
|
||||||
" }\n"
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY', ''], ['MY_TYPE*']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY', ''], ['MY_TYPE*']
|
||||||
@@ -326,7 +365,11 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do
|
|||||||
it 'handle custom types with array handlers when array plugin is enabled for non-array types' do
|
it 'handle custom types with array handlers when array plugin is enabled for non-array types' do
|
||||||
function = { :name => 'Pear' }
|
function = { :name => 'Pear' }
|
||||||
arg = test_arg[:mytype]
|
arg = test_arg[:mytype]
|
||||||
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n {\n UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(&cmock_call_instance->Expected_MyMyType, &MyMyType, 1, cmock_line, \"Function 'Pear' called with unexpected value for argument 'MyMyType'.\");\n }\n"
|
expected = " if (!cmock_call_instance->IgnoreArg_MyMyType)\n" +
|
||||||
|
" {\n" +
|
||||||
|
" UNITY_SET_DETAILS(CMockString_Pear,CMockString_MyMyType);\n" +
|
||||||
|
" UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY(&cmock_call_instance->Expected_MyMyType, &MyMyType, 1, cmock_line, CMockStringMismatch);\n" +
|
||||||
|
" }\n"
|
||||||
@unity_helper.expect :nil?, false
|
@unity_helper.expect :nil?, false
|
||||||
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY', '&'], ['MY_TYPE']
|
@unity_helper.expect :get_helper, ['UNITY_TEST_ASSERT_EQUAL_MY_TYPE_ARRAY', '&'], ['MY_TYPE']
|
||||||
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
assert_equal(expected, @cmock_generator_utils_complex.code_verify_an_arg_expectation(function, arg))
|
||||||
|
|||||||
Vendored
+1
-1
Submodule vendor/unity updated: b922d622a6...e8662ae1cc
Reference in New Issue
Block a user