提交 8f6a7ad7 编写于 作者: G greg-williams

- Modified generate_test_runner.rb to generate unit test main() with int...

- Modified generate_test_runner.rb to generate unit test main() with int main(void) instead of void main(void) in order to work with GCC
- Removed unused methods from unity_test_summary.rb

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@6 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 8fb02040
......@@ -142,7 +142,7 @@ class UnityTestRunnerGenerator
def create_main(output, module_name, tests)
output.puts()
output.puts()
output.puts("void main(void)")
output.puts("int main(void)")
output.puts("{")
output.puts("#{@tab}Unity.TestFile = \"#{module_name}\";")
output.puts("#{@tab}UnityBegin();")
......@@ -155,6 +155,7 @@ class UnityTestRunnerGenerator
output.puts()
output.puts("#{@tab}UnityEnd();")
output.puts("#{@tab}return 0;")
output.puts("}")
end
......
......@@ -79,7 +79,6 @@ class UnityTestSummary
def set_root_path(path)
@root = path
puts "root_path = " + @root
end
protected
......@@ -147,49 +146,6 @@ class UnityTestSummary
end
def here; File.expand_path(File.dirname(__FILE__)); end
def valid_file(fname)
raise "Can't find file #{fname}" unless File.exists?(fname)
fname
end
def valid_dir(dirname)
raise "Can't find dir #{dirname}" unless File.exists?(dirname)
dirname
end
def search_file_and_replace(file_name, pattern, replacement)
text = File.read(valid_file(file_name))
text.gsub!(pattern, replacement)
File.open(file_name, "w") do |f| f.write text end
end
def create_file_from_template(dest_file, template_file)
raise "#{dest_file} already exists; remove it first" if File.exists?(dest_file)
template_file = valid_file("#{here}/rscript_template.rb")
template = ERB.new(File.read(template_file))
File.open(dest_file,"w") do |f|
f.write template.result(binding)
end
end
def humanize(lower_case_and_underscored_word)
lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
end
def camelize(lower_case_and_underscored_word)
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
end
def titleize(word)
humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }
end
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册