mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-10-17 12:23:13 +08:00
- 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
This commit is contained in:
@ -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
|
||||
@ -148,49 +147,6 @@ class UnityTestSummary
|
||||
|
||||
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
|
||||
|
||||
if $0 == __FILE__
|
||||
|
Reference in New Issue
Block a user