mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-13 12:27:26 +00:00
- made index follow alignment rules too
- added support to track line numbers - tweaked color support git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@158 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -4,6 +4,7 @@ class CMockUnityHelperParser
|
||||
|
||||
def initialize(config)
|
||||
@config = config
|
||||
@fallback = @config.plugins.include?(:array) ? 'UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY' : 'UNITY_TEST_ASSERT_EQUAL_MEMORY'
|
||||
@c_types = map_C_types.merge(import_source)
|
||||
end
|
||||
|
||||
@@ -11,11 +12,7 @@ class CMockUnityHelperParser
|
||||
lookup = ctype.gsub(/(?:^|(\S?)(\s*)|(\W))const(?:$|(\s*)(\S)|(\W))/,'\1\3\5\6').strip.gsub(/\s+/,'_')
|
||||
return @c_types[lookup] if (@c_types[lookup])
|
||||
raise("Don't know how to test #{ctype} and memory tests are disabled!") unless @config.memcmp_if_unknown
|
||||
if (ctype =~ /\*/)
|
||||
return 'TEST_ASSERT_EQUAL_MEMORY_MESSAGE_ARRAY'
|
||||
else
|
||||
return 'TEST_ASSERT_EQUAL_MEMORY_MESSAGE'
|
||||
end
|
||||
return @fallback
|
||||
end
|
||||
|
||||
private ###########################
|
||||
@@ -23,7 +20,7 @@ class CMockUnityHelperParser
|
||||
def map_C_types
|
||||
c_types = {}
|
||||
@config.treat_as.each_pair do |ctype, expecttype|
|
||||
c_types[ctype.gsub(/\s+/,'_')] = "TEST_ASSERT_EQUAL_#{expecttype}_MESSAGE"
|
||||
c_types[ctype.gsub(/\s+/,'_')] = "UNITY_TEST_ASSERT_EQUAL_#{expecttype}"
|
||||
end
|
||||
c_types
|
||||
end
|
||||
@@ -36,20 +33,20 @@ class CMockUnityHelperParser
|
||||
source = source.gsub(/\/\*.*?\*\//m, '') #remove block comments
|
||||
|
||||
#scan for comparison helpers
|
||||
m = Regexp.new('^\s*#define\s+(TEST_ASSERT_EQUAL_(\w+)_MESSAGE|TEST_ASSERT_EQUAL_(\w+))\s*\(' + Array.new(2,'\s*\w+\s*').join(',') + '\)')
|
||||
a = source.scan(m).flatten.compact
|
||||
(a.size/2).times do |i|
|
||||
expect = a[i*2]
|
||||
ctype = a[(i*2)+1]
|
||||
match_regex = Regexp.new('^\s*#define\s+(UNITY_TEST_ASSERT_EQUAL_(\w+))\s*\(' + Array.new(4,'\s*\w+\s*').join(',') + '\)')
|
||||
pairs = source.scan(match_regex).flatten.compact
|
||||
(pairs.size/2).times do |i|
|
||||
expect = pairs[i*2]
|
||||
ctype = pairs[(i*2)+1]
|
||||
c_types[ctype] = expect unless expect.include?("_ARRAY")
|
||||
end
|
||||
|
||||
#scan for array variants of those helpers
|
||||
m = Regexp.new('^\s*#define\s+(TEST_ASSERT_EQUAL_(\w+_ARRAY)_MESSAGE|TEST_ASSERT_EQUAL_(\w+_ARRAY))\s*\(' + Array.new(3,'\s*\w+\s*').join(',') + '\)')
|
||||
a = source.scan(m).flatten.compact
|
||||
(a.size/2).times do |i|
|
||||
expect = a[i*2]
|
||||
ctype = a[(i*2)+1]
|
||||
match_regex = Regexp.new('^\s*#define\s+(UNITY_TEST_ASSERT_EQUAL_(\w+_ARRAY))\s*\(' + Array.new(5,'\s*\w+\s*').join(',') + '\)')
|
||||
pairs = source.scan(match_regex).flatten.compact
|
||||
(pairs.size/2).times do |i|
|
||||
expect = pairs[i*2]
|
||||
ctype = pairs[(i*2)+1]
|
||||
c_types[ctype.gsub('_ARRAY','*')] = expect
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user