mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-19 17:49:56 +00:00
corrected treat_as merging with standard_treat_as_map
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@212 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
+5
-1
@@ -57,7 +57,11 @@ class CMockConfig
|
||||
options[:plugins].compact!
|
||||
options[:plugins].map! {|p| p.to_sym}
|
||||
@options = options
|
||||
@options[:treat_as].merge!(standard_treat_as_map)
|
||||
|
||||
treat_as_map = standard_treat_as_map().clone
|
||||
treat_as_map.merge!(@options[:treat_as])
|
||||
@options[:treat_as] = treat_as_map
|
||||
|
||||
@options.each_key { |key| eval("def #{key.to_s}() return @options[:#{key.to_s}] end") }
|
||||
end
|
||||
|
||||
|
||||
@@ -179,9 +179,9 @@ class CMockGenerator
|
||||
file << " cmock_line = cmock_call_instance->LineNumber;\n"
|
||||
if (@ordered)
|
||||
file << " if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)\n"
|
||||
file << " UNITY_TEST_FAIL(cmock_line, \"Function '#{function[:name]}' called earlier than expected.\");"
|
||||
file << " UNITY_TEST_FAIL(cmock_line, \"Function '#{function[:name]}' called earlier than expected.\");\n"
|
||||
file << " if (cmock_call_instance->CallOrder < GlobalVerifyOrder)\n"
|
||||
file << " UNITY_TEST_FAIL(cmock_line, \"Function '#{function[:name]}' called later than expected.\");"
|
||||
file << " UNITY_TEST_FAIL(cmock_line, \"Function '#{function[:name]}' called later than expected.\");\n"
|
||||
# file << " UNITY_TEST_ASSERT((cmock_call_instance->CallOrder == ++GlobalVerifyOrder), cmock_line, \"Out of order function calls. Function '#{function[:name]}'\");\n"
|
||||
end
|
||||
file << @plugins.run(:mock_implementation, function)
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
209
|
||||
212
|
||||
|
||||
|
||||
@@ -42,4 +42,39 @@ class CMockConfigTest < Test::Unit::TestCase
|
||||
assert_equal(test_plugins, config.plugins)
|
||||
assert_equal(:include, config.treat_externs)
|
||||
end
|
||||
|
||||
should "populate treat_as map with internal standard_treat_as_map defaults, redefine defaults, and add custom values" do
|
||||
user_treat_as = {
|
||||
'BOOL' => 'UINT8', # redefine standard default
|
||||
'unsigned long' => 'INT', # redefine standard default
|
||||
'U8' => 'UINT8', # custom value
|
||||
'U16' => 'UINT16' # custom value
|
||||
}
|
||||
|
||||
config = CMockConfig.new({:treat_as => user_treat_as})
|
||||
|
||||
# standard defaults
|
||||
assert_equal('INT', config.treat_as['BOOL_T'])
|
||||
assert_equal('HEX32', config.treat_as['unsigned int'])
|
||||
assert_equal('PTR', config.treat_as['void*'])
|
||||
assert_equal('STRING', config.treat_as['CSTRING'])
|
||||
assert_equal('STRING', config.treat_as['char*'])
|
||||
assert_equal('HEX8', config.treat_as['unsigned char'])
|
||||
assert_equal('INT', config.treat_as['long'])
|
||||
assert_equal('INT16', config.treat_as['short'])
|
||||
|
||||
# overrides
|
||||
assert_equal('UINT8', config.treat_as['BOOL'])
|
||||
assert_equal('INT', config.treat_as['unsigned long'])
|
||||
|
||||
# added custom values
|
||||
assert_equal('UINT8', config.treat_as['U8'])
|
||||
assert_equal('UINT16', config.treat_as['U16'])
|
||||
|
||||
# standard_treat_as_map: unchanged
|
||||
assert_equal('INT', config.standard_treat_as_map['BOOL'])
|
||||
assert_equal('HEX32', config.standard_treat_as_map['unsigned long'])
|
||||
assert_equal('STRING', config.standard_treat_as_map['char*'])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user