Improve regex for test parameterization to support function pointers

The regex to match function names for the test parameterization used the
wildcard '.*'. This lead to an error when you try to add a function
pointer as arguement.

The regex will now only match the word characters a-z A-Z 0-9 and
underscore (which are all characers that are accepted by the C standard)
This commit is contained in:
Jannis Baudisch
2021-04-01 10:29:22 +02:00
parent 61f4428435
commit b51303a65b

View File

@@ -131,6 +131,7 @@ class UnityTestRunnerGenerator
lines.each_with_index do |line, _index| lines.each_with_index do |line, _index|
# find tests # find tests
next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m
next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]})\w*)\s*\(\s*(.*)\s*\)/m
arguments = Regexp.last_match(1) arguments = Regexp.last_match(1)
name = Regexp.last_match(2) name = Regexp.last_match(2)