diff options
| author | Fuwn <[email protected]> | 2026-02-26 10:24:00 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-26 10:31:15 -0800 |
| commit | a14f361a60f55299e0057c419cc59e5194a77854 (patch) | |
| tree | edf54089f5849ee4dfdac48bd04bd8c271cfb62a | |
| parent | feat(homework_2): Add implementation (diff) | |
| download | cst456-a14f361a60f55299e0057c419cc59e5194a77854.tar.xz cst456-a14f361a60f55299e0057c419cc59e5194a77854.zip | |
feat(lab_6): Add initial files
111 files changed, 9126 insertions, 0 deletions
diff --git a/lab_6/CST456 Lab6.pdf b/lab_6/CST456 Lab6.pdf Binary files differnew file mode 100644 index 0000000..4ae4220 --- /dev/null +++ b/lab_6/CST456 Lab6.pdf diff --git a/lab_6/unity/.gitignore b/lab_6/unity/.gitignore new file mode 100644 index 0000000..fbdf49e --- /dev/null +++ b/lab_6/unity/.gitignore @@ -0,0 +1,7 @@ +build/ +.DS_Store +examples/example_1/test1.out
+examples/example_1/test2.out
+examples/example_2/all_tests.out
+examples/example_3/test1.out
+examples/example_3/test2.out
diff --git a/lab_6/unity/.travis.yml b/lab_6/unity/.travis.yml new file mode 100644 index 0000000..74dc382 --- /dev/null +++ b/lab_6/unity/.travis.yml @@ -0,0 +1,6 @@ +language: ruby +rvm: + - "1.9.3" + - "2.0.0" +script: + - cd test && rake ci diff --git a/lab_6/unity/README.md b/lab_6/unity/README.md new file mode 100644 index 0000000..61d0a62 --- /dev/null +++ b/lab_6/unity/README.md @@ -0,0 +1,203 @@ +Unity Test API
+==============
+
+[](https://travis-ci.org/ThrowTheSwitch/Unity)
+__Copyright (c) 2007 - 2014 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
+
+Running Tests
+-------------
+
+ RUN_TEST(func, linenum)
+
+Each Test is run within the macro `RUN_TEST`. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards.
+
+Ignoring Tests
+--------------
+
+There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned.
+
+ TEST_IGNORE()
+
+Ignore this test and return immediately
+
+ TEST_IGNORE_MESSAGE (message)
+
+Ignore this test and return immediately. Output a message stating why the test was ignored.
+
+Aborting Tests
+--------------
+
+There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call.
+
+ TEST_PROTECT()
+
+Setup and Catch macro
+
+ TEST_ABORT()
+
+Abort Test macro
+
+Example:
+
+ main()
+ {
+ if (TEST_PROTECT() == 0)
+ {
+ MyTest();
+ }
+ }
+
+If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a non-zero return value.
+
+
+Unity Assertion Summary
+=======================
+
+Basic Validity Tests
+--------------------
+
+ TEST_ASSERT_TRUE(condition)
+
+Evaluates whatever code is in condition and fails if it evaluates to false
+
+ TEST_ASSERT_FALSE(condition)
+
+Evaluates whatever code is in condition and fails if it evaluates to true
+
+ TEST_ASSERT(condition)
+
+Another way of calling `TEST_ASSERT_TRUE`
+
+ TEST_ASSERT_UNLESS(condition)
+
+Another way of calling `TEST_ASSERT_FALSE`
+
+ TEST_FAIL()
+ TEST_FAIL_MESSAGE(message)
+
+This test is automatically marked as a failure. The message is output stating why.
+
+Numerical Assertions: Integers
+------------------------------
+
+ TEST_ASSERT_EQUAL_INT(expected, actual)
+ TEST_ASSERT_EQUAL_INT8(expected, actual)
+ TEST_ASSERT_EQUAL_INT16(expected, actual)
+ TEST_ASSERT_EQUAL_INT32(expected, actual)
+ TEST_ASSERT_EQUAL_INT64(expected, actual)
+
+Compare two integers for equality and display errors as signed integers. A cast will be performed
+to your natural integer size so often this can just be used. When you need to specify the exact size,
+like when comparing arrays, you can use a specific version:
+
+ TEST_ASSERT_EQUAL_UINT(expected, actual)
+ TEST_ASSERT_EQUAL_UINT8(expected, actual)
+ TEST_ASSERT_EQUAL_UINT16(expected, actual)
+ TEST_ASSERT_EQUAL_UINT32(expected, actual)
+ TEST_ASSERT_EQUAL_UINT64(expected, actual)
+
+Compare two integers for equality and display errors as unsigned integers. Like INT, there are
+variants for different sizes also.
+
+ TEST_ASSERT_EQUAL_HEX(expected, actual)
+ TEST_ASSERT_EQUAL_HEX8(expected, actual)
+ TEST_ASSERT_EQUAL_HEX16(expected, actual)
+ TEST_ASSERT_EQUAL_HEX32(expected, actual)
+ TEST_ASSERT_EQUAL_HEX64(expected, actual)
+
+Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
+you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16`
+will show 4 nibbles).
+
+ _ARRAY
+
+You can append `_ARRAY` to any of these macros to make an array comparison of that type. Here you will
+need to care a bit more about the actual size of the value being checked. You will also specify an
+additional argument which is the number of elements to compare. For example:
+
+ TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)
+
+ TEST_ASSERT_EQUAL(expected, actual)
+
+Another way of calling TEST_ASSERT_EQUAL_INT
+
+ TEST_ASSERT_INT_WITHIN(delta, expected, actual)
+
+Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
+size specific variants.
+
+
+Numerical Assertions: Bitwise
+-----------------------------
+
+ TEST_ASSERT_BITS(mask, expected, actual)
+
+Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored.
+
+ TEST_ASSERT_BITS_HIGH(mask, actual)
+
+Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored.
+
+ TEST_ASSERT_BITS_LOW(mask, actual)
+
+Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored.
+
+ TEST_ASSERT_BIT_HIGH(bit, actual)
+
+Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer.
+
+ TEST_ASSERT_BIT_LOW(bit, actual)
+
+Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer.
+
+Numerical Assertions: Floats
+----------------------------
+
+ TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)
+
+Asserts that the actual value is within plus or minus delta of the expected value.
+
+ TEST_ASSERT_EQUAL_FLOAT(expected, actual)
+ TEST_ASSERT_EQUAL_DOUBLE(expected, actual)
+
+Asserts that two floating point values are "equal" within a small % delta of the expected value.
+
+String Assertions
+-----------------
+
+ TEST_ASSERT_EQUAL_STRING(expected, actual)
+
+Compare two null-terminate strings. Fail if any character is different or if the lengths are different.
+
+ TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)
+
+Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure.
+
+Pointer Assertions
+------------------
+
+Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity.
+
+ TEST_ASSERT_NULL(pointer)
+
+Fails if the pointer is not equal to NULL
+
+ TEST_ASSERT_NOT_NULL(pointer)
+
+Fails if the pointer is equal to NULL
+
+Memory Assertions
+-----------------
+
+ TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
+
+Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
+standard types... but since it's a memory compare, you have to be careful that your data types are packed.
+
+_MESSAGE
+--------
+
+you can append _MESSAGE to any of the macros to make them take an additional argument. This argument
+is a string that will be printed at the end of the failure strings. This is useful for specifying more
+information about the problem.
+
diff --git a/lab_6/unity/auto/colour_prompt.rb b/lab_6/unity/auto/colour_prompt.rb new file mode 100644 index 0000000..8adab6e --- /dev/null +++ b/lab_6/unity/auto/colour_prompt.rb @@ -0,0 +1,115 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +if RUBY_PLATFORM =~/(win|w)32$/ + begin + require 'Win32API' + rescue LoadError + puts "ERROR! \"Win32API\" library not found" + puts "\"Win32API\" is required for colour on a windows machine" + puts " try => \"gem install Win32API\" on the command line" + puts + end + # puts + # puts 'Windows Environment Detected...' + # puts 'Win32API Library Found.' + # puts +end + +class ColourCommandLine + def initialize + if RUBY_PLATFORM =~/(win|w)32$/ + get_std_handle = Win32API.new("kernel32", "GetStdHandle", ['L'], 'L') + @set_console_txt_attrb = + Win32API.new("kernel32","SetConsoleTextAttribute",['L','N'], 'I') + @hout = get_std_handle.call(-11) + end + end + + def change_to(new_colour) + if RUBY_PLATFORM =~/(win|w)32$/ + @set_console_txt_attrb.call(@hout,self.win32_colour(new_colour)) + else + "\033[30;#{posix_colour(new_colour)};22m" + end + end + + def win32_colour(colour) + case colour + when :black then 0 + when :dark_blue then 1 + when :dark_green then 2 + when :dark_cyan then 3 + when :dark_red then 4 + when :dark_purple then 5 + when :dark_yellow, :narrative then 6 + when :default_white, :default, :dark_white then 7 + when :silver then 8 + when :blue then 9 + when :green, :success then 10 + when :cyan, :output then 11 + when :red, :failure then 12 + when :purple then 13 + when :yellow then 14 + when :white then 15 + else + 0 + end + end + + def posix_colour(colour) + # ANSI Escape Codes - Foreground colors + # | Code | Color | + # | 39 | Default foreground color | + # | 30 | Black | + # | 31 | Red | + # | 32 | Green | + # | 33 | Yellow | + # | 34 | Blue | + # | 35 | Magenta | + # | 36 | Cyan | + # | 37 | Light gray | + # | 90 | Dark gray | + # | 91 | Light red | + # | 92 | Light green | + # | 93 | Light yellow | + # | 94 | Light blue | + # | 95 | Light magenta | + # | 96 | Light cyan | + # | 97 | White | + + case colour + when :black then 30 + when :red, :failure then 31 + when :green, :success then 32 + when :yellow then 33 + when :blue, :narrative then 34 + when :purple, :magenta then 35 + when :cyan, :output then 36 + when :white, :default_white then 37 + when :default then 39 + else + 39 + end + end + + def out_c(mode, colour, str) + case RUBY_PLATFORM + when /(win|w)32$/ + change_to(colour) + $stdout.puts str if mode == :puts + $stdout.print str if mode == :print + change_to(:default_white) + else + $stdout.puts("#{change_to(colour)}#{str}\033[0m") if mode == :puts + $stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print + end + end +end # ColourCommandLine + +def colour_puts(role,str) ColourCommandLine.new.out_c(:puts, role, str) end +def colour_print(role,str) ColourCommandLine.new.out_c(:print, role, str) end + diff --git a/lab_6/unity/auto/colour_reporter.rb b/lab_6/unity/auto/colour_reporter.rb new file mode 100644 index 0000000..89e7951 --- /dev/null +++ b/lab_6/unity/auto/colour_reporter.rb @@ -0,0 +1,39 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+require "#{File.expand_path(File.dirname(__FILE__))}/colour_prompt"
+
+$colour_output = true
+
+def report(message)
+ if not $colour_output
+ $stdout.puts(message)
+ else
+ message = message.join('\n') if (message.class == Array)
+ message.each_line do |line|
+ line.chomp!
+ colour = case(line)
+ when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i
+ ($1.to_i == 0) ? :green : :red
+ when /PASS/
+ :green
+ when /^OK$/
+ :green
+ when /(?:FAIL|ERROR)/
+ :red
+ when /IGNORE/
+ :yellow
+ when /^(?:Creating|Compiling|Linking)/
+ :white
+ else
+ :silver
+ end
+ colour_puts(colour, line)
+ end
+ end
+ $stdout.flush
+ $stderr.flush
+end
\ No newline at end of file diff --git a/lab_6/unity/auto/generate_config.yml b/lab_6/unity/auto/generate_config.yml new file mode 100644 index 0000000..ce66cea --- /dev/null +++ b/lab_6/unity/auto/generate_config.yml @@ -0,0 +1,36 @@ +#this is a sample configuration file for generate_module
+#you would use it by calling generate_module with the -ygenerate_config.yml option
+#files like this are useful for customizing generate_module to your environment
+:generate_module:
+ :defaults:
+ #these defaults are used in place of any missing options at the command line
+ :path_src: ../src/
+ :path_inc: ../src/
+ :path_tst: ../test/
+ :update_svn: true
+ :includes:
+ #use [] for no additional includes, otherwise list the includes on separate lines
+ :src:
+ - Defs.h
+ - Board.h
+ :inc: []
+ :tst:
+ - Defs.h
+ - Board.h
+ - Exception.h
+ :boilerplates:
+ #these are inserted at the top of generated files.
+ #just comment out or remove if not desired.
+ #use %1$s where you would like the file name to appear (path/extension not included)
+ :src: |
+ //-------------------------------------------
+ // %1$s.c
+ //-------------------------------------------
+ :inc: |
+ //-------------------------------------------
+ // %1$s.h
+ //-------------------------------------------
+ :tst: |
+ //-------------------------------------------
+ // Test%1$s.c : Units tests for %1$s.c
+ //-------------------------------------------
diff --git a/lab_6/unity/auto/generate_module.rb b/lab_6/unity/auto/generate_module.rb new file mode 100644 index 0000000..4a020eb --- /dev/null +++ b/lab_6/unity/auto/generate_module.rb @@ -0,0 +1,202 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+# This script creates all the files with start code necessary for a new module.
+# A simple module only requires a source file, header file, and test file.
+# Triad modules require a source, header, and test file for each triad type (like model, conductor, and hardware).
+
+require 'rubygems'
+require 'fileutils'
+
+HERE = File.expand_path(File.dirname(__FILE__)) + '/'
+
+#help text when requested
+HELP_TEXT = [ "\nGENERATE MODULE\n-------- ------",
+ "\nUsage: ruby generate_module [options] module_name",
+ " -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
+ " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
+ " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
+ " -p\"MCH\" sets the output pattern to MCH.",
+ " dh - driver hardware.",
+ " dih - driver interrupt hardware.",
+ " mch - model conductor hardware.",
+ " mvp - model view presenter.",
+ " src - just a single source module. (DEFAULT)",
+ " -d destroy module instead of creating it.",
+ " -u update subversion too (requires subversion command line)",
+ " -y\"my.yml\" selects a different yaml config file for module generation",
+ "" ].join("\n")
+
+#Built in patterns
+PATTERNS = { 'src' => {'' => { :inc => [] } },
+ 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
+ 'Hardware' => { :inc => [] }
+ },
+ 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
+ 'Interrupt'=> { :inc => ['%1$sHardware.h'] },
+ 'Hardware' => { :inc => [] }
+ },
+ 'mch' => {'Model' => { :inc => [] },
+ 'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
+ 'Hardware' => { :inc => [] }
+ },
+ 'mvp' => {'Model' => { :inc => [] },
+ 'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
+ 'View' => { :inc => [] }
+ }
+ }
+
+#TEMPLATE_TST
+TEMPLATE_TST = %q[#include "unity.h"
+%2$s#include "%1$s.h"
+
+void setUp(void)
+{
+}
+
+void tearDown(void)
+{
+}
+
+void test_%1$s_NeedToImplement(void)
+{
+ TEST_IGNORE();
+}
+]
+
+#TEMPLATE_SRC
+TEMPLATE_SRC = %q[%2$s#include "%1$s.h"
+]
+
+#TEMPLATE_INC
+TEMPLATE_INC = %q[#ifndef _%3$s_H
+#define _%3$s_H%2$s
+
+#endif // _%3$s_H
+]
+
+# Parse the command line parameters.
+ARGV.each do |arg|
+ case(arg)
+ when /^-d/ then @destroy = true
+ when /^-u/ then @update_svn = true
+ when /^-p(\w+)/ then @pattern = $1
+ when /^-s(.+)/ then @path_src = $1
+ when /^-i(.+)/ then @path_inc = $1
+ when /^-t(.+)/ then @path_tst = $1
+ when /^-y(.+)/ then @yaml_config = $1
+ when /^(\w+)/
+ raise "ERROR: You can't have more than one Module name specified!" unless @module_name.nil?
+ @module_name = arg
+ when /^-(h|-help)/
+ puts HELP_TEXT
+ exit
+ else
+ raise "ERROR: Unknown option specified '#{arg}'"
+ end
+end
+raise "ERROR: You must have a Module name specified! (use option -h for help)" if @module_name.nil?
+
+#load yaml file if one was requested
+if @yaml_config
+ require 'yaml'
+ cfg = YAML.load_file(HERE + @yaml_config)[:generate_module]
+ @path_src = cfg[:defaults][:path_src] if @path_src.nil?
+ @path_inc = cfg[:defaults][:path_inc] if @path_inc.nil?
+ @path_tst = cfg[:defaults][:path_tst] if @path_tst.nil?
+ @update_svn = cfg[:defaults][:update_svn] if @update_svn.nil?
+ @extra_inc = cfg[:includes]
+ @boilerplates = cfg[:boilerplates]
+else
+ @boilerplates = {}
+end
+
+# Create default file paths if none were provided
+@path_src = HERE + "../src/" if @path_src.nil?
+@path_inc = @path_src if @path_inc.nil?
+@path_tst = HERE + "../test/" if @path_tst.nil?
+@path_src += '/' unless (@path_src[-1] == 47)
+@path_inc += '/' unless (@path_inc[-1] == 47)
+@path_tst += '/' unless (@path_tst[-1] == 47)
+@pattern = 'src' if @pattern.nil?
+@includes = { :src => [], :inc => [], :tst => [] }
[email protected]!(@extra_inc) unless @extra_inc.nil?
+
+#create triad definition
+TRIAD = [ { :ext => '.c', :path => @path_src, :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @boilerplates[:src] },
+ { :ext => '.h', :path => @path_inc, :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @boilerplates[:inc] },
+ { :ext => '.c', :path => @path_tst+'Test', :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @boilerplates[:tst] },
+ ]
+
+#prepare the pattern for use
+@patterns = PATTERNS[@pattern.downcase]
+raise "ERROR: The design pattern specified isn't one that I recognize!" if @patterns.nil?
+
+# Assemble the path/names of the files we need to work with.
+files = []
+TRIAD.each do |triad|
+ @patterns.each_pair do |pattern_file, pattern_traits|
+ files << {
+ :path => "#{triad[:path]}#{@module_name}#{pattern_file}#{triad[:ext]}",
+ :name => "#{@module_name}#{pattern_file}",
+ :template => triad[:template],
+ :boilerplate => triad[:boilerplate],
+ :includes => case(triad[:inc])
+ when :src then @includes[:src] | pattern_traits[:inc].map{|f| f % [@module_name]}
+ when :inc then @includes[:inc]
+ when :tst then @includes[:tst] | pattern_traits[:inc].map{|f| "Mock#{f}"% [@module_name]}
+ end
+ }
+ end
+end
+
+# destroy files if that was what was requested
+if @destroy
+ files.each do |filespec|
+ file = filespec[:path]
+ if File.exist?(file)
+ if @update_svn
+ `svn delete \"#{file}\" --force`
+ puts "File #{file} deleted and removed from source control"
+ else
+ FileUtils.remove(file)
+ puts "File #{file} deleted"
+ end
+ else
+ puts "File #{file} does not exist so cannot be removed."
+ end
+ end
+ puts "Destroy Complete"
+ exit
+end
+
+#Abort if any module already exists
+files.each do |file|
+ raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
+end
+
+# Create Source Modules
+files.each_with_index do |file, i|
+ File.open(file[:path], 'w') do |f|
+ f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
+ f.write(file[:template] % [ file[:name],
+ file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
+ file[:name].upcase ]
+ )
+ end
+ if (@update_svn)
+ `svn add \"#{file[:path]}\"`
+ if $?.exitstatus == 0
+ puts "File #{file[:path]} created and added to source control"
+ else
+ puts "File #{file[:path]} created but FAILED adding to source control!"
+ end
+ else
+ puts "File #{file[:path]} created"
+ end
+end
+
+puts 'Generate Complete'
diff --git a/lab_6/unity/auto/generate_test_runner.rb b/lab_6/unity/auto/generate_test_runner.rb new file mode 100644 index 0000000..63aa462 --- /dev/null +++ b/lab_6/unity/auto/generate_test_runner.rb @@ -0,0 +1,346 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+$QUICK_RUBY_VERSION = RUBY_VERSION.split('.').inject(0){|vv,v| vv * 100 + v.to_i }
+File.expand_path(File.join(File.dirname(__FILE__),'colour_prompt'))
+
+class UnityTestRunnerGenerator
+
+ def initialize(options = nil)
+ @options = UnityTestRunnerGenerator.default_options
+ case(options)
+ when NilClass then @options
+ when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
+ when Hash then @options.merge!(options)
+ else raise "If you specify arguments, it should be a filename or a hash of options"
+ end
+ end
+
+ def self.default_options
+ {
+ :includes => [],
+ :plugins => [],
+ :framework => :unity,
+ :test_prefix => "test|spec|should",
+ :setup_name => "setUp",
+ :teardown_name => "tearDown",
+ }
+ end
+
+ def self.grab_config(config_file)
+ options = self.default_options
+ unless (config_file.nil? or config_file.empty?)
+ require 'yaml'
+ yaml_guts = YAML.load_file(config_file)
+ options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
+ raise "No :unity or :cmock section found in #{config_file}" unless options
+ end
+ return(options)
+ end
+
+ def run(input_file, output_file, options=nil)
+ tests = []
+ testfile_includes = []
+ used_mocks = []
+
+ @options.merge!(options) unless options.nil?
+ module_name = File.basename(input_file)
+
+ #pull required data from source file
+ source = File.read(input_file)
+ source = source.force_encoding("ISO-8859-1").encode("utf-8", :replace => nil) if ($QUICK_RUBY_VERSION > 10900)
+ tests = find_tests(source)
+ testfile_includes = find_includes(source)
+ used_mocks = find_mocks(testfile_includes)
+
+ #build runner file
+ generate(input_file, output_file, tests, used_mocks, testfile_includes)
+
+ #determine which files were used to return them
+ all_files_used = [input_file, output_file]
+ all_files_used += testfile_includes.map {|filename| filename + '.c'} unless testfile_includes.empty?
+ all_files_used += @options[:includes] unless @options[:includes].empty?
+ return all_files_used.uniq
+ end
+
+ def generate(input_file, output_file, tests, used_mocks, testfile_includes)
+ File.open(output_file, 'w') do |output|
+ create_header(output, used_mocks, testfile_includes)
+ create_externs(output, tests, used_mocks)
+ create_mock_management(output, used_mocks)
+ create_suite_setup_and_teardown(output)
+ create_reset(output, used_mocks)
+ create_main(output, input_file, tests, used_mocks)
+ end
+ end
+
+ def find_tests(source)
+ tests_raw = []
+ tests_args = []
+ tests_and_line_numbers = []
+
+ source_scrubbed = source.gsub(/\/\/.*$/, '') # remove line comments
+ source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
+ lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
+ | (;|\{|\}) /x) # Match ;, {, and } as end of lines
+
+ lines.each_with_index do |line, index|
+ #find tests
+ if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/
+ arguments = $1
+ name = $2
+ call = $3
+ args = nil
+ if (@options[:use_param_tests] and !arguments.empty?)
+ args = []
+ arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) {|a| args << a[0]}
+ end
+ tests_and_line_numbers << { :test => name, :args => args, :call => call, :line_number => 0 }
+ tests_args = []
+ end
+ end
+
+ #determine line numbers and create tests to run
+ source_lines = source.split("\n")
+ source_index = 0;
+ tests_and_line_numbers.size.times do |i|
+ source_lines[source_index..-1].each_with_index do |line, index|
+ if (line =~ /#{tests_and_line_numbers[i][:test]}/)
+ source_index += index
+ tests_and_line_numbers[i][:line_number] = source_index + 1
+ break
+ end
+ end
+ end
+
+ return tests_and_line_numbers
+ end
+
+ def find_includes(source)
+
+ #remove comments (block and line, in three steps to ensure correct precedence)
+ source.gsub!(/\/\/(?:.+\/\*|\*(?:$|[^\/])).*$/, '') # remove line comments that comment out the start of blocks
+ source.gsub!(/\/\*.*?\*\//m, '') # remove block comments
+ source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain)
+
+ #parse out includes
+ includes = source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten
+ brackets_includes = source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten
+ brackets_includes.each { |inc| includes << '<' + inc +'>' }
+ return includes
+ end
+
+ def find_mocks(includes)
+ mock_headers = []
+ includes.each do |include_file|
+ mock_headers << File.basename(include_file) if (include_file =~ /^mock/i)
+ end
+ return mock_headers
+ end
+
+ def create_header(output, mocks, testfile_includes=[])
+ output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
+ create_runtest(output, mocks)
+ output.puts("\n//=======Automagically Detected Files To Include=====")
+ output.puts("#include \"#{@options[:framework].to_s}.h\"")
+ output.puts('#include "cmock.h"') unless (mocks.empty?)
+ @options[:includes].flatten.uniq.compact.each do |inc|
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
+ end
+ output.puts('#include <setjmp.h>')
+ output.puts('#include <stdio.h>')
+ output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
+ testfile_includes.delete_if{|inc| inc =~ /(unity|cmock)/}
+ testrunner_includes = testfile_includes - mocks
+ testrunner_includes.each do |inc|
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
+ end
+ mocks.each do |mock|
+ output.puts("#include \"#{mock.gsub('.h','')}.h\"")
+ end
+ if @options[:enforce_strict_ordering]
+ output.puts('')
+ output.puts('int GlobalExpectCount;')
+ output.puts('int GlobalVerifyOrder;')
+ output.puts('char* GlobalOrderError;')
+ end
+ end
+
+ def create_externs(output, tests, mocks)
+ output.puts("\n//=======External Functions This Runner Calls=====")
+ output.puts("extern void #{@options[:setup_name]}(void);")
+ output.puts("extern void #{@options[:teardown_name]}(void);")
+ tests.each do |test|
+ output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});")
+ end
+ output.puts('')
+ end
+
+ def create_mock_management(output, mocks)
+ unless (mocks.empty?)
+ output.puts("\n//=======Mock Management=====")
+ output.puts("static void CMock_Init(void)")
+ output.puts("{")
+ if @options[:enforce_strict_ordering]
+ output.puts(" GlobalExpectCount = 0;")
+ output.puts(" GlobalVerifyOrder = 0;")
+ output.puts(" GlobalOrderError = NULL;")
+ end
+ mocks.each do |mock|
+ mock_clean = mock.gsub(/(?:-|\s+)/, "_")
+ output.puts(" #{mock_clean}_Init();")
+ end
+ output.puts("}\n")
+
+ output.puts("static void CMock_Verify(void)")
+ output.puts("{")
+ mocks.each do |mock|
+ mock_clean = mock.gsub(/(?:-|\s+)/, "_")
+ output.puts(" #{mock_clean}_Verify();")
+ end
+ output.puts("}\n")
+
+ output.puts("static void CMock_Destroy(void)")
+ output.puts("{")
+ mocks.each do |mock|
+ mock_clean = mock.gsub(/(?:-|\s+)/, "_")
+ output.puts(" #{mock_clean}_Destroy();")
+ end
+ output.puts("}\n")
+ end
+ end
+
+ def create_suite_setup_and_teardown(output)
+ unless (@options[:suite_setup].nil?)
+ output.puts("\n//=======Suite Setup=====")
+ output.puts("static int suite_setup(void)")
+ output.puts("{")
+ output.puts(@options[:suite_setup])
+ output.puts("}")
+ end
+ unless (@options[:suite_teardown].nil?)
+ output.puts("\n//=======Suite Teardown=====")
+ output.puts("static int suite_teardown(int num_failures)")
+ output.puts("{")
+ output.puts(@options[:suite_teardown])
+ output.puts("}")
+ end
+ end
+
+ def create_runtest(output, used_mocks)
+ cexception = @options[:plugins].include? :cexception
+ va_args1 = @options[:use_param_tests] ? ', ...' : ''
+ va_args2 = @options[:use_param_tests] ? '__VA_ARGS__' : ''
+ output.puts("\n//=======Test Runner Used To Run Each Test Below=====")
+ output.puts("#define RUN_TEST_NO_ARGS") if @options[:use_param_tests]
+ output.puts("#define RUN_TEST(TestFunc, TestLineNum#{va_args1}) \\")
+ output.puts("{ \\")
+ output.puts(" Unity.CurrentTestName = #TestFunc#{va_args2.empty? ? '' : " \"(\" ##{va_args2} \")\""}; \\")
+ output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
+ output.puts(" Unity.NumberOfTests++; \\")
+ output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
+ output.puts(" if (TEST_PROTECT()) \\")
+ output.puts(" { \\")
+ output.puts(" CEXCEPTION_T e; \\") if cexception
+ output.puts(" Try { \\") if cexception
+ output.puts(" #{@options[:setup_name]}(); \\")
+ output.puts(" TestFunc(#{va_args2}); \\")
+ output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
+ output.puts(" } \\")
+ output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
+ output.puts(" { \\")
+ output.puts(" #{@options[:teardown_name]}(); \\")
+ output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
+ output.puts(" } \\")
+ output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
+ output.puts(" UnityConcludeTest(); \\")
+ output.puts("}\n")
+ end
+
+ def create_reset(output, used_mocks)
+ output.puts("\n//=======Test Reset Option=====")
+ output.puts("void resetTest(void);")
+ output.puts("void resetTest(void)")
+ output.puts("{")
+ output.puts(" CMock_Verify();") unless (used_mocks.empty?)
+ output.puts(" CMock_Destroy();") unless (used_mocks.empty?)
+ output.puts(" #{@options[:teardown_name]}();")
+ output.puts(" CMock_Init();") unless (used_mocks.empty?)
+ output.puts(" #{@options[:setup_name]}();")
+ output.puts("}")
+ end
+
+ def create_main(output, filename, tests, used_mocks)
+ output.puts("\n\n//=======MAIN=====")
+ output.puts("int main(void)")
+ output.puts("{")
+ output.puts(" suite_setup();") unless @options[:suite_setup].nil?
+ output.puts(" UnityBegin(\"#{filename}\");")
+ if (@options[:use_param_tests])
+ tests.each do |test|
+ if ((test[:args].nil?) or (test[:args].empty?))
+ output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, RUN_TEST_NO_ARGS);")
+ else
+ test[:args].each {|args| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, #{args});")}
+ end
+ end
+ else
+ tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") }
+ end
+ output.puts()
+ output.puts(" CMock_Guts_MemFreeFinal();") unless used_mocks.empty?
+ output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());")
+ output.puts("}")
+ end
+end
+
+
+if ($0 == __FILE__)
+ options = { :includes => [] }
+ yaml_file = nil
+
+ #parse out all the options first (these will all be removed as we go)
+ ARGV.reject! do |arg|
+ case(arg)
+ when '-cexception'
+ options[:plugins] = [:cexception]; true
+ when /\.*\.ya?ml/
+ options = UnityTestRunnerGenerator.grab_config(arg); true
+ when /\.*\.h/
+ options[:includes] << arg; true
+ when /--(\w+)=\"?(.*)\"?/
+ options[$1.to_sym] = $2; true
+ else false
+ end
+ end
+
+ #make sure there is at least one parameter left (the input file)
+ if !ARGV[0]
+ puts ["\nusage: ruby #{__FILE__} (files) (options) input_test_file (output)",
+ "\n input_test_file - this is the C file you want to create a runner for",
+ " output - this is the name of the runner file to generate",
+ " defaults to (input_test_file)_Runner",
+ " files:",
+ " *.yml / *.yaml - loads configuration from here in :unity or :cmock",
+ " *.h - header files are added as #includes in runner",
+ " options:",
+ " -cexception - include cexception support",
+ " --setup_name=\"\" - redefine setUp func name to something else",
+ " --teardown_name=\"\" - redefine tearDown func name to something else",
+ " --test_prefix=\"\" - redefine test prefix from default test|spec|should",
+ " --suite_setup=\"\" - code to execute for setup of entire suite",
+ " --suite_teardown=\"\" - code to execute for teardown of entire suite",
+ " --use_param_tests=1 - enable parameterized tests (disabled by default)",
+ ].join("\n")
+ exit 1
+ end
+
+ #create the default test runner name if not specified
+ ARGV[1] = ARGV[0].gsub(".c","_Runner.c") if (!ARGV[1])
+
+
+ UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1])
+end
diff --git a/lab_6/unity/auto/parseOutput.rb b/lab_6/unity/auto/parseOutput.rb new file mode 100644 index 0000000..5165c7f --- /dev/null +++ b/lab_6/unity/auto/parseOutput.rb @@ -0,0 +1,189 @@ +#============================================================ +# Author: John Theofanopoulos +# A simple parser. Takes the output files generated during the build process and +# extracts information relating to the tests. +# +# Notes: +# To capture an output file under VS builds use the following: +# devenv [build instructions] > Output.txt & type Output.txt +# +# To capture an output file under GCC/Linux builds use the following: +# make | tee Output.txt +# +# To use this parser use the following command +# ruby parseOutput.rb [options] [file] +# options: -xml : produce a JUnit compatible XML file +# file : file to scan for results +#============================================================ + + +class ParseOutput +# The following flag is set to true when a test is found or false otherwise. + @testFlag + @xmlOut + @arrayList + @totalTests + @classIndex + +# Set the flag to indicate if there will be an XML output file or not + def setXmlOutput() + @xmlOut = true + end + +# if write our output to XML + def writeXmlOuput() + output = File.open("report.xml", "w") + output << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + @arrayList.each do |item| + output << item << "\n" + end + output << "</testsuite>\n" + end + +# This function will try and determine when the suite is changed. This is +# is the name that gets added to the classname parameter. + def testSuiteVerify(testSuiteName) + if @testFlag == false + @testFlag = true; + # Split the path name + testName = testSuiteName.split("/") + # Remove the extension + baseName = testName[testName.size - 1].split(".") + @testSuite = "test." + baseName[0] + printf "New Test: %s\n", @testSuite + end + end + + +# Test was flagged as having passed so format the output + def testPassed(array) + lastItem = array.length - 1 + testName = array[lastItem - 1] + testSuiteVerify(array[@className]) + printf "%-40s PASS\n", testName + if @xmlOut == true + @arrayList.push " <testcase classname=\"" + @testSuite + "\" name=\"" + testName + "\"/>" + end + end + +# Test was flagged as being ingored so format the output + def testIgnored(array) + lastItem = array.length - 1 + testName = array[lastItem - 2] + reason = array[lastItem].chomp + testSuiteVerify(array[@className]) + printf "%-40s IGNORED\n", testName + if @xmlOut == true + @arrayList.push " <testcase classname=\"" + @testSuite + "\" name=\"" + testName + "\">" + @arrayList.push " <skipped type=\"TEST IGNORED\"> " + reason + " </skipped>" + @arrayList.push " </testcase>" + end + end + +# Test was flagged as having failed so format the line + def testFailed(array) + lastItem = array.length - 1 + testName = array[lastItem - 2] + reason = array[lastItem].chomp + " at line: " + array[lastItem - 3] + testSuiteVerify(array[@className]) + printf "%-40s FAILED\n", testName + if @xmlOut == true + @arrayList.push " <testcase classname=\"" + @testSuite + "\" name=\"" + testName + "\">" + @arrayList.push " <failure type=\"ASSERT FAILED\"> " + reason + " </failure>" + @arrayList.push " </testcase>" + end + end + + +# Figure out what OS we are running on. For now we are assuming if it's not Windows it must +# be Unix based. + def detectOS() + myOS = RUBY_PLATFORM.split("-") + if myOS.size == 2 + if myOS[1] == "mingw32" + @className = 1 + else + @className = 0 + end + end + + end + +# Main function used to parse the file that was captured. + def process(name) + @testFlag = false + @arrayList = Array.new + + detectOS() + + puts "Parsing file: " + name + + + testPass = 0 + testFail = 0 + testIgnore = 0 + puts "" + puts "=================== RESULTS =====================" + puts "" + File.open(name).each do |line| + # Typical test lines look like this: + # <path>/<test_file>.c:36:test_tc1000_opsys:FAIL: Expected 1 Was 0 + # <path>/<test_file>.c:112:test_tc5004_initCanChannel:IGNORE: Not Yet Implemented + # <path>/<test_file>.c:115:test_tc5100_initCanVoidPtrs:PASS + # + # where path is different on Unix vs Windows devices (Windows leads with a drive letter) + lineArray = line.split(":") + lineSize = lineArray.size + # If we were able to split the line then we can look to see if any of our target words + # were found. Case is important. + if lineSize >= 4 + # Determine if this test passed + if line.include? ":PASS" + testPassed(lineArray) + testPass += 1 + elsif line.include? ":FAIL:" + testFailed(lineArray) + testFail += 1 + elsif line.include? ":IGNORE:" + testIgnored(lineArray) + testIgnore += 1 + # If none of the keywords are found there are no more tests for this suite so clear + # the test flag + else + @testFlag = false + end + else + @testFlag = false + end + end + puts "" + puts "=================== SUMMARY =====================" + puts "" + puts "Tests Passed : " + testPass.to_s + puts "Tests Failed : " + testFail.to_s + puts "Tests Ignored : " + testIgnore.to_s + @totalTests = testPass + testFail + testIgnore + if @xmlOut == true + heading = "<testsuite tests=\"" + @totalTests.to_s + "\" failures=\"" + testFail.to_s + "\"" + " skips=\"" + testIgnore.to_s + "\">" + @arrayList.insert(0, heading) + writeXmlOuput() + end + + # return result + end + + end + +# If the command line has no values in, used a default value of Output.txt +parseMyFile = ParseOutput.new + +if ARGV.size >= 1 + ARGV.each do |a| + if a == "-xml" + parseMyFile.setXmlOutput(); + else + parseMyFile.process(a) + break + end + end +end diff --git a/lab_6/unity/auto/test_file_filter.rb b/lab_6/unity/auto/test_file_filter.rb new file mode 100644 index 0000000..3dbc26a --- /dev/null +++ b/lab_6/unity/auto/test_file_filter.rb @@ -0,0 +1,23 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +require'yaml' + +module RakefileHelpers + class TestFileFilter + def initialize(all_files = false) + @all_files = all_files + if not @all_files == true + if File.exist?('test_file_filter.yml') + filters = YAML.load_file( 'test_file_filter.yml' ) + @all_files, @only_files, @exclude_files = + filters[:all_files], filters[:only_files], filters[:exclude_files] + end + end + end + attr_accessor :all_files, :only_files, :exclude_files + end +end diff --git a/lab_6/unity/auto/unity_test_summary.py b/lab_6/unity/auto/unity_test_summary.py new file mode 100644 index 0000000..7426ec8 --- /dev/null +++ b/lab_6/unity/auto/unity_test_summary.py @@ -0,0 +1,135 @@ +#! python3
+# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2015 Alexander Mueller / [email protected]
+# [Released under MIT License. Please refer to license.txt for details]
+# Based on the ruby script by Mike Karlesky, Mark VanderVoord, Greg Williams
+# ==========================================
+import sys
+import os
+import re
+from glob import glob
+
+class UnityTestSummary:
+ def __init__(self):
+ self.report = ''
+ self.total_tests = 0
+ self.failures = 0
+ self.ignored = 0
+
+ def run(self):
+ # Clean up result file names
+ results = []
+ for target in self.targets:
+ results.append(target.replace('\\', '/'))
+
+ # Dig through each result file, looking for details on pass/fail:
+ failure_output = []
+ ignore_output = []
+
+ for result_file in results:
+ lines = list(map(lambda line: line.rstrip(), open(result_file, "r").read().split('\n')))
+ if len(lines) == 0:
+ raise Exception("Empty test result file: %s" % result_file)
+
+ details = self.get_details(result_file, lines)
+ failures = details['failures']
+ ignores = details['ignores']
+ if len(failures) > 0: failure_output.append('\n'.join(failures))
+ if len(ignores) > 0: ignore_output.append('n'.join(ignores))
+ tests,failures,ignored = self.parse_test_summary('\n'.join(lines))
+ self.total_tests += tests
+ self.failures += failures
+ self.ignored += ignored
+
+ if self.ignored > 0:
+ self.report += "\n"
+ self.report += "--------------------------\n"
+ self.report += "UNITY IGNORED TEST SUMMARY\n"
+ self.report += "--------------------------\n"
+ self.report += "\n".join(ignore_output)
+
+ if self.failures > 0:
+ self.report += "\n"
+ self.report += "--------------------------\n"
+ self.report += "UNITY FAILED TEST SUMMARY\n"
+ self.report += "--------------------------\n"
+ self.report += '\n'.join(failure_output)
+
+ self.report += "\n"
+ self.report += "--------------------------\n"
+ self.report += "OVERALL UNITY TEST SUMMARY\n"
+ self.report += "--------------------------\n"
+ self.report += "{total_tests} TOTAL TESTS {failures} TOTAL FAILURES {ignored} IGNORED\n".format(total_tests = self.total_tests, failures=self.failures, ignored=self.ignored)
+ self.report += "\n"
+
+ return self.report
+
+ def set_targets(self, target_array):
+ self.targets = target_array
+
+ def set_root_path(self, path):
+ self.root = path
+
+ def usage(self, err_msg=None):
+ print("\nERROR: ")
+ if err_msg:
+ print(err_msg)
+ print("\nUsage: unity_test_summary.rb result_file_directory/ root_path/")
+ print(" result_file_directory - The location of your results files.")
+ print(" Defaults to current directory if not specified.")
+ print(" Should end in / if specified.")
+ print(" root_path - Helpful for producing more verbose output if using relative paths.")
+ sys.exit(1)
+
+ def get_details(self, result_file, lines):
+ results = { 'failures': [], 'ignores': [], 'successes': [] }
+ for line in lines:
+ parts = line.split(':')
+ if len(parts) != 5:
+ continue
+ src_file,src_line,test_name,status,msg = parts
+ if len(self.root) > 0:
+ line_out = "%s%s" % (self.root, line)
+ else:
+ line_out = line
+ if status == 'IGNORE':
+ results['ignores'].append(line_out)
+ elif status == 'FAIL':
+ results['failures'].append(line_out)
+ elif status == 'PASS':
+ results['successes'].append(line_out)
+ return results
+
+ def parse_test_summary(self, summary):
+ m = re.search(r"([0-9]+) Tests ([0-9]+) Failures ([0-9]+) Ignored", summary)
+ if not m:
+ raise Exception("Couldn't parse test results: %s" % summary)
+
+ return int(m.group(1)), int(m.group(2)), int(m.group(3))
+
+
+if __name__ == '__main__':
+ uts = UnityTestSummary()
+ try:
+ #look in the specified or current directory for result files
+ if len(sys.argv) > 1:
+ targets_dir = sys.argv[1]
+ else:
+ targets_dir = './'
+ targets = list(map(lambda x: x.replace('\\', '/'), glob(targets_dir + '*.test*')))
+ if len(targets) == 0:
+ raise Exception("No *.testpass or *.testfail files found in '%s'" % targets_dir)
+ uts.set_targets(targets)
+
+ #set the root path
+ if len(sys.argv) > 2:
+ root_path = sys.argv[2]
+ else:
+ root_path = os.path.split(__file__)[0]
+ uts.set_root_path(root_path)
+
+ #run the summarizer
+ print(uts.run())
+ except Exception as e:
+ uts.usage(e)
diff --git a/lab_6/unity/auto/unity_test_summary.rb b/lab_6/unity/auto/unity_test_summary.rb new file mode 100644 index 0000000..8cf360f --- /dev/null +++ b/lab_6/unity/auto/unity_test_summary.rb @@ -0,0 +1,139 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+#!/usr/bin/ruby
+#
+# unity_test_summary.rb
+#
+require 'fileutils'
+require 'set'
+
+class UnityTestSummary
+ include FileUtils::Verbose
+
+ attr_reader :report, :total_tests, :failures, :ignored
+
+ def initialize
+ @report = ''
+ @total_tests = 0
+ @failures = 0
+ @ignored = 0
+ end
+
+ def run
+ # Clean up result file names
+ results = @targets.map {|target| target.gsub(/\\/,'/')}
+
+ # Dig through each result file, looking for details on pass/fail:
+ failure_output = []
+ ignore_output = []
+
+ results.each do |result_file|
+ lines = File.readlines(result_file).map { |line| line.chomp }
+ if lines.length == 0
+ raise "Empty test result file: #{result_file}"
+ else
+ output = get_details(result_file, lines)
+ failure_output << output[:failures] unless output[:failures].empty?
+ ignore_output << output[:ignores] unless output[:ignores].empty?
+ tests,failures,ignored = parse_test_summary(lines)
+ @total_tests += tests
+ @failures += failures
+ @ignored += ignored
+ end
+ end
+
+ if @ignored > 0
+ @report += "\n"
+ @report += "--------------------------\n"
+ @report += "UNITY IGNORED TEST SUMMARY\n"
+ @report += "--------------------------\n"
+ @report += ignore_output.flatten.join("\n")
+ end
+
+ if @failures > 0
+ @report += "\n"
+ @report += "--------------------------\n"
+ @report += "UNITY FAILED TEST SUMMARY\n"
+ @report += "--------------------------\n"
+ @report += failure_output.flatten.join("\n")
+ end
+
+ @report += "\n"
+ @report += "--------------------------\n"
+ @report += "OVERALL UNITY TEST SUMMARY\n"
+ @report += "--------------------------\n"
+ @report += "#{@total_tests} TOTAL TESTS #{@failures} TOTAL FAILURES #{@ignored} IGNORED\n"
+ @report += "\n"
+ end
+
+ def set_targets(target_array)
+ @targets = target_array
+ end
+
+ def set_root_path(path)
+ @root = path
+ end
+
+ def usage(err_msg=nil)
+ puts "\nERROR: "
+ puts err_msg if err_msg
+ puts "\nUsage: unity_test_summary.rb result_file_directory/ root_path/"
+ puts " result_file_directory - The location of your results files."
+ puts " Defaults to current directory if not specified."
+ puts " Should end in / if specified."
+ puts " root_path - Helpful for producing more verbose output if using relative paths."
+ exit 1
+ end
+
+ protected
+
+ def get_details(result_file, lines)
+ results = { :failures => [], :ignores => [], :successes => [] }
+ lines.each do |line|
+ src_file,src_line,test_name,status,msg = line.split(/:/)
+ line_out = ((@root and (@root != 0)) ? "#{@root}#{line}" : line ).gsub(/\//, "\\")
+ case(status)
+ when 'IGNORE' then results[:ignores] << line_out
+ when 'FAIL' then results[:failures] << line_out
+ when 'PASS' then results[:successes] << line_out
+ end
+ end
+ return results
+ end
+
+ def parse_test_summary(summary)
+ if summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
+ [$1.to_i,$2.to_i,$3.to_i]
+ else
+ raise "Couldn't parse test results: #{summary}"
+ end
+ end
+
+ def here; File.expand_path(File.dirname(__FILE__)); end
+
+end
+
+if $0 == __FILE__
+ uts = UnityTestSummary.new
+ begin
+ #look in the specified or current directory for result files
+ ARGV[0] ||= './'
+ targets = "#{ARGV[0].gsub(/\\/, '/')}*.test*"
+ results = Dir[targets]
+ raise "No *.testpass or *.testfail files found in '#{targets}'" if results.empty?
+ uts.set_targets(results)
+
+ #set the root path
+ ARGV[1] ||= File.expand_path(File.dirname(__FILE__)) + '/'
+ uts.set_root_path(ARGV[1])
+
+ #run the summarizer
+ puts uts.run
+ rescue Exception => e
+ uts.usage e.message
+ end
+end
diff --git a/lab_6/unity/docs/Unity Summary.odt b/lab_6/unity/docs/Unity Summary.odt Binary files differnew file mode 100644 index 0000000..6530864 --- /dev/null +++ b/lab_6/unity/docs/Unity Summary.odt diff --git a/lab_6/unity/docs/Unity Summary.pdf b/lab_6/unity/docs/Unity Summary.pdf Binary files differnew file mode 100644 index 0000000..b1e6419 --- /dev/null +++ b/lab_6/unity/docs/Unity Summary.pdf diff --git a/lab_6/unity/docs/Unity Summary.txt b/lab_6/unity/docs/Unity Summary.txt new file mode 100644 index 0000000..a157aac --- /dev/null +++ b/lab_6/unity/docs/Unity Summary.txt @@ -0,0 +1,216 @@ +==============
+Unity Test API
+==============
+
+[Copyright (c) 2007 - 2012 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams]
+
+-------------
+Running Tests
+-------------
+
+RUN_TEST(func, linenum)
+
+Each Test is run within the macro RUN_TEST. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards.
+
+--------------
+Ignoring Tests
+--------------
+
+There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned.
+
+TEST_IGNORE()
+
+Ignore this test and return immediately
+
+TEST_IGNORE_MESSAGE (message)
+
+Ignore this test and return immediately. Output a message stating why the test was ignored.
+
+--------------
+Aborting Tests
+--------------
+
+There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first (TEST_PROTECT) sets up the feature, and handles emergency abort cases. TEST_ABORT can then be used at any time within the tests to return to the last TEST_PROTECT call.
+
+TEST_PROTECT()
+
+Setup and Catch macro
+
+TEST_ABORT()
+
+Abort Test macro
+
+Example:
+
+main()
+{
+ if (TEST_PROTECT() == 0)
+ {
+ MyTest();
+ }
+}
+
+If MyTest calls TEST_ABORT, program control will immediately return to TEST_PROTECT with a non-zero return value.
+
+
+=======================
+Unity Assertion Summary
+=======================
+
+--------------------
+Basic Validity Tests
+--------------------
+
+TEST_ASSERT_TRUE(condition)
+
+Evaluates whatever code is in condition and fails if it evaluates to false
+
+TEST_ASSERT_FALSE(condition)
+
+Evaluates whatever code is in condition and fails if it evaluates to true
+
+TEST_ASSERT(condition)
+
+Another way of calling TEST_ASSERT_TRUE
+
+TEST_ASSERT_UNLESS(condition)
+
+Another way of calling TEST_ASSERT_FALSE
+
+TEST_FAIL()
+TEST_FAIL_MESSAGE(message)
+
+This test is automatically marked as a failure. The message is output stating why.
+
+------------------------------
+Numerical Assertions: Integers
+------------------------------
+
+TEST_ASSERT_EQUAL_INT(expected, actual)
+TEST_ASSERT_EQUAL_INT8(expected, actual)
+TEST_ASSERT_EQUAL_INT16(expected, actual)
+TEST_ASSERT_EQUAL_INT32(expected, actual)
+TEST_ASSERT_EQUAL_INT64(expected, actual)
+
+Compare two integers for equality and display errors as signed integers. A cast will be performed
+to your natural integer size so often this can just be used. When you need to specify the exact size,
+like when comparing arrays, you can use a specific version:
+
+TEST_ASSERT_EQUAL_UINT(expected, actual)
+TEST_ASSERT_EQUAL_UINT8(expected, actual)
+TEST_ASSERT_EQUAL_UINT16(expected, actual)
+TEST_ASSERT_EQUAL_UINT32(expected, actual)
+TEST_ASSERT_EQUAL_UINT64(expected, actual)
+
+Compare two integers for equality and display errors as unsigned integers. Like INT, there are
+variants for different sizes also.
+
+TEST_ASSERT_EQUAL_HEX(expected, actual)
+TEST_ASSERT_EQUAL_HEX8(expected, actual)
+TEST_ASSERT_EQUAL_HEX16(expected, actual)
+TEST_ASSERT_EQUAL_HEX32(expected, actual)
+TEST_ASSERT_EQUAL_HEX64(expected, actual)
+
+Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
+you can specify the size... here the size will also effect how many nibbles are shown (for example, HEX16
+will show 4 nibbles).
+
+_ARRAY
+
+You can append _ARRAY to any of these macros to make an array comparison of that type. Here you will
+need to care a bit more about the actual size of the value being checked. You will also specify an
+additional argument which is the number of elements to compare. For example:
+
+TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)
+
+TEST_ASSERT_EQUAL(expected, actual)
+
+Another way of calling TEST_ASSERT_EQUAL_INT
+
+TEST_ASSERT_INT_WITHIN(delta, expected, actual)
+
+Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
+size specific variants.
+
+
+-----------------------------
+Numerical Assertions: Bitwise
+-----------------------------
+
+TEST_ASSERT_BITS(mask, expected, actual)
+
+Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored.
+
+TEST_ASSERT_BITS_HIGH(mask, actual)
+
+Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored.
+
+TEST_ASSERT_BITS_LOW(mask, actual)
+
+Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored.
+
+TEST_ASSERT_BIT_HIGH(bit, actual)
+
+Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer.
+
+TEST_ASSERT_BIT_LOW(bit, actual)
+
+Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer.
+
+----------------------------
+Numerical Assertions: Floats
+----------------------------
+
+TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)
+
+Asserts that the actual value is within plus or minus delta of the expected value.
+
+TEST_ASSERT_EQUAL_FLOAT(expected, actual)
+TEST_ASSERT_EQUAL_DOUBLE(expected, actual)
+
+Asserts that two floating point values are "equal" within a small % delta of the expected value.
+
+-----------------
+String Assertions
+-----------------
+
+TEST_ASSERT_EQUAL_STRING(expected, actual)
+
+Compare two null-terminate strings. Fail if any character is different or if the lengths are different.
+
+TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)
+
+Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure.
+
+------------------
+Pointer Assertions
+------------------
+
+Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity.
+
+TEST_ASSERT_NULL(pointer)
+
+Fails if the pointer is not equal to NULL
+
+TEST_ASSERT_NOT_NULL(pointer)
+
+Fails if the pointer is equal to NULL
+
+
+-----------------
+Memory Assertions
+-----------------
+
+TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
+
+Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
+standard types... but since it's a memory compare, you have to be careful that your data types are packed.
+
+--------
+_MESSAGE
+--------
+
+you can append _MESSAGE to any of the macros to make them take an additional argument. This argument
+is a string that will be printed at the end of the failure strings. This is useful for specifying more
+information about the problem.
+
diff --git a/lab_6/unity/docs/license.txt b/lab_6/unity/docs/license.txt new file mode 100644 index 0000000..d0f635f --- /dev/null +++ b/lab_6/unity/docs/license.txt @@ -0,0 +1,21 @@ +The MIT License (MIT)
+
+Copyright (c) <year> 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/lab_6/unity/examples/example_1/makefile b/lab_6/unity/examples/example_1/makefile new file mode 100644 index 0000000..3d8d763 --- /dev/null +++ b/lab_6/unity/examples/example_1/makefile @@ -0,0 +1,65 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +#We try to detect the OS we are running on, and adjust commands as needed +ifeq ($(OSTYPE),cygwin) + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +else ifeq ($(OS),Windows_NT) + CLEANUP = del /F /Q + MKDIR = mkdir + TARGET_EXTENSION=.exe +else + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +endif + +UNITY_ROOT=../.. +C_COMPILER=gcc + +CFLAGS=-std=c99 +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -Werror +CFLAGS += -Wpointer-arith +CFLAGS += -Wcast-align +CFLAGS += -Wwrite-strings +CFLAGS += -Wswitch-default +CFLAGS += -Wunreachable-code +CFLAGS += -Winit-self +CFLAGS += -Wlogical-op +CFLAGS += -Wmissing-field-initializers +CFLAGS += -Wno-unknown-pragmas +CFLAGS += -Wjump-misses-init +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wundef +CFLAGS += -Wunsafe-loop-optimizations +CFLAGS += -Wold-style-definition + +TARGET_BASE1=test1 +TARGET_BASE2=test2 +TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) +TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION) +SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c +SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c +INC_DIRS=-Isrc -I$(UNITY_ROOT)/src +SYMBOLS=-DTEST + +all: clean default + +default: +# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c +# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2) + ./$(TARGET1) + ./$(TARGET2) + +clean: + $(CLEANUP) + diff --git a/lab_6/unity/examples/example_1/readme.txt b/lab_6/unity/examples/example_1/readme.txt new file mode 100644 index 0000000..dfed815 --- /dev/null +++ b/lab_6/unity/examples/example_1/readme.txt @@ -0,0 +1,5 @@ +Example 1 +========= + +Close to the simplest possible example of Unity, using only basic features. +Run make to build & run the example tests.
\ No newline at end of file diff --git a/lab_6/unity/examples/example_1/src/ProductionCode.c b/lab_6/unity/examples/example_1/src/ProductionCode.c new file mode 100644 index 0000000..500b44b --- /dev/null +++ b/lab_6/unity/examples/example_1/src/ProductionCode.c @@ -0,0 +1,24 @@ + +#include "ProductionCode.h" + +int Counter = 0; +int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious array to search that is 1-based indexing instead of 0. + +// This function is supposed to search through NumbersToFind and find a particular number. +// If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since +// NumbersToFind is indexed from 1. Unfortunately it's broken +// (and should therefore be caught by our tests) +int FindFunction_WhichIsBroken(int NumberToFind) +{ + int i = 0; + while (i <= 8) //Notice I should have been in braces + i++; + if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it! + return i; + return 0; +} + +int FunctionWhichReturnsLocalVariable(void) +{ + return Counter; +} diff --git a/lab_6/unity/examples/example_1/src/ProductionCode.h b/lab_6/unity/examples/example_1/src/ProductionCode.h new file mode 100644 index 0000000..250ca0d --- /dev/null +++ b/lab_6/unity/examples/example_1/src/ProductionCode.h @@ -0,0 +1,3 @@ + +int FindFunction_WhichIsBroken(int NumberToFind); +int FunctionWhichReturnsLocalVariable(void); diff --git a/lab_6/unity/examples/example_1/src/ProductionCode2.c b/lab_6/unity/examples/example_1/src/ProductionCode2.c new file mode 100644 index 0000000..77c969f --- /dev/null +++ b/lab_6/unity/examples/example_1/src/ProductionCode2.c @@ -0,0 +1,11 @@ + +#include "ProductionCode2.h" + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) +{ + (void)Poor; + (void)LittleFunction; + //Since There Are No Tests Yet, This Function Could Be Empty For All We Know. + // Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget + return (char*)0; +} diff --git a/lab_6/unity/examples/example_1/src/ProductionCode2.h b/lab_6/unity/examples/example_1/src/ProductionCode2.h new file mode 100644 index 0000000..34ae980 --- /dev/null +++ b/lab_6/unity/examples/example_1/src/ProductionCode2.h @@ -0,0 +1,2 @@ + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/lab_6/unity/examples/example_1/test/TestProductionCode.c b/lab_6/unity/examples/example_1/test/TestProductionCode.c new file mode 100644 index 0000000..28a5581 --- /dev/null +++ b/lab_6/unity/examples/example_1/test/TestProductionCode.c @@ -0,0 +1,62 @@ + +#include "ProductionCode.h" +#include "unity.h" + +//sometimes you may want to get at local data in a module. +//for example: If you plan to pass by reference, this could be useful +//however, it should often be avoided +extern int Counter; + +void setUp(void) +{ + //This is run before EACH TEST + Counter = 0x5a5a; +} + +void tearDown(void) +{ +} + +void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) +{ + //All of these should pass + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); +} + +void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void) +{ + // You should see this line fail in your test summary + TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34)); + + // Notice the rest of these didn't get a chance to run because the line above failed. + // Unit tests abort each test function on the first sign of trouble. + // Then NEXT test function runs as normal. + TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888)); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void) +{ + //This should be true because setUp set this up for us before this test + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); + + //This should be true because we can still change our answer + Counter = 0x1234; + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void) +{ + //This should be true again because setup was rerun before this test (and after we changed it to 0x1234) + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void) +{ + //Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell + // you what actually happened...which in this case was a failure to setup the initial condition. + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} diff --git a/lab_6/unity/examples/example_1/test/TestProductionCode2.c b/lab_6/unity/examples/example_1/test/TestProductionCode2.c new file mode 100644 index 0000000..e2119cc --- /dev/null +++ b/lab_6/unity/examples/example_1/test/TestProductionCode2.c @@ -0,0 +1,31 @@ + +#include "ProductionCode2.h" +#include "unity.h" + +/* These should be ignored because they are commented out in various ways: +#include "whatever.h" +*/ +//#include "somethingelse.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_IgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); +} + +void test_AnotherIgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("These Can Be Useful For Leaving Yourself Notes On What You Need To Do Yet"); +} + +void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void) +{ + TEST_IGNORE(); //Like This +} diff --git a/lab_6/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c b/lab_6/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c new file mode 100644 index 0000000..4d67701 --- /dev/null +++ b/lab_6/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c @@ -0,0 +1,33 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> + +char MessageBuffer[50]; + +extern void setUp(void); +extern void tearDown(void); + +extern void test_IgnoredTest(void); +extern void test_AnotherIgnoredTest(void); +extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); + +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +int main(void) +{ + UnityBegin("test/TestProductionCode2.c"); + + RUN_TEST(test_IgnoredTest, 13); + RUN_TEST(test_AnotherIgnoredTest, 18); + RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23); + + UnityEnd(); + return 0; +} diff --git a/lab_6/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c b/lab_6/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c new file mode 100644 index 0000000..0a795ec --- /dev/null +++ b/lab_6/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c @@ -0,0 +1,37 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> + +char MessageBuffer[50]; + +extern void setUp(void); +extern void tearDown(void); + +extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); +extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); + +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +int main(void) +{ + UnityBegin("test/TestProductionCode.c"); + + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20); + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57); + + UnityEnd(); + return 0; +} diff --git a/lab_6/unity/examples/example_2/makefile b/lab_6/unity/examples/example_2/makefile new file mode 100644 index 0000000..311e8ce --- /dev/null +++ b/lab_6/unity/examples/example_2/makefile @@ -0,0 +1,71 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +#We try to detect the OS we are running on, and adjust commands as needed +ifeq ($(OSTYPE),cygwin) + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +else ifeq ($(OS),Windows_NT) + CLEANUP = del /F /Q + MKDIR = mkdir + TARGET_EXTENSION=.exe +else + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +endif + +UNITY_ROOT=../.. +C_COMPILER=gcc + +CFLAGS = -std=c99 +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -Werror +CFLAGS += -Wpointer-arith +CFLAGS += -Wcast-align +CFLAGS += -Wwrite-strings +CFLAGS += -Wswitch-default +CFLAGS += -Wunreachable-code +CFLAGS += -Winit-self +CFLAGS += -Wlogical-op +CFLAGS += -Wmissing-field-initializers +CFLAGS += -Wno-unknown-pragmas +CFLAGS += -Wjump-misses-init +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wundef +CFLAGS += -Wunsafe-loop-optimizations +CFLAGS += -Wold-style-definition +CFLAGS += -Wmissing-prototypes +CFLAGS += -Wmissing-declarations + +TARGET_BASE1=all_tests +TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) +SRC_FILES1=\ + $(UNITY_ROOT)/src/unity.c \ + $(UNITY_ROOT)/extras/fixture/src/unity_fixture.c \ + src/ProductionCode.c \ + src/ProductionCode2.c \ + test/TestProductionCode.c \ + test/TestProductionCode2.c \ + test/test_runners/TestProductionCode_Runner.c \ + test/test_runners/TestProductionCode2_Runner.c \ + test/test_runners/all_tests.c +INC_DIRS=-Isrc -I$(UNITY_ROOT)/src -I$(UNITY_ROOT)/extras/fixture/src +SYMBOLS= + +all: clean default + +default: +# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c +# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) + ./$(TARGET1) + +clean: + $(CLEANUP) + diff --git a/lab_6/unity/examples/example_2/readme.txt b/lab_6/unity/examples/example_2/readme.txt new file mode 100644 index 0000000..f0fce65 --- /dev/null +++ b/lab_6/unity/examples/example_2/readme.txt @@ -0,0 +1,5 @@ +Example 2 +========= + +Same as the first example, but now using Unity's test fixture to group tests +together. Using the test fixture also makes writing test runners much easier.
\ No newline at end of file diff --git a/lab_6/unity/examples/example_2/src/ProductionCode.c b/lab_6/unity/examples/example_2/src/ProductionCode.c new file mode 100644 index 0000000..500b44b --- /dev/null +++ b/lab_6/unity/examples/example_2/src/ProductionCode.c @@ -0,0 +1,24 @@ + +#include "ProductionCode.h" + +int Counter = 0; +int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious array to search that is 1-based indexing instead of 0. + +// This function is supposed to search through NumbersToFind and find a particular number. +// If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since +// NumbersToFind is indexed from 1. Unfortunately it's broken +// (and should therefore be caught by our tests) +int FindFunction_WhichIsBroken(int NumberToFind) +{ + int i = 0; + while (i <= 8) //Notice I should have been in braces + i++; + if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it! + return i; + return 0; +} + +int FunctionWhichReturnsLocalVariable(void) +{ + return Counter; +} diff --git a/lab_6/unity/examples/example_2/src/ProductionCode.h b/lab_6/unity/examples/example_2/src/ProductionCode.h new file mode 100644 index 0000000..250ca0d --- /dev/null +++ b/lab_6/unity/examples/example_2/src/ProductionCode.h @@ -0,0 +1,3 @@ + +int FindFunction_WhichIsBroken(int NumberToFind); +int FunctionWhichReturnsLocalVariable(void); diff --git a/lab_6/unity/examples/example_2/src/ProductionCode2.c b/lab_6/unity/examples/example_2/src/ProductionCode2.c new file mode 100644 index 0000000..77c969f --- /dev/null +++ b/lab_6/unity/examples/example_2/src/ProductionCode2.c @@ -0,0 +1,11 @@ + +#include "ProductionCode2.h" + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) +{ + (void)Poor; + (void)LittleFunction; + //Since There Are No Tests Yet, This Function Could Be Empty For All We Know. + // Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget + return (char*)0; +} diff --git a/lab_6/unity/examples/example_2/src/ProductionCode2.h b/lab_6/unity/examples/example_2/src/ProductionCode2.h new file mode 100644 index 0000000..34ae980 --- /dev/null +++ b/lab_6/unity/examples/example_2/src/ProductionCode2.h @@ -0,0 +1,2 @@ + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/lab_6/unity/examples/example_2/test/TestProductionCode.c b/lab_6/unity/examples/example_2/test/TestProductionCode.c new file mode 100644 index 0000000..ff318ab --- /dev/null +++ b/lab_6/unity/examples/example_2/test/TestProductionCode.c @@ -0,0 +1,64 @@ +#include "ProductionCode.h" +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP(ProductionCode); + +//sometimes you may want to get at local data in a module. +//for example: If you plan to pass by reference, this could be useful +//however, it should often be avoided +extern int Counter; + +TEST_SETUP(ProductionCode) +{ + //This is run before EACH TEST + Counter = 0x5a5a; +} + +TEST_TEAR_DOWN(ProductionCode) +{ +} + +TEST(ProductionCode, FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode) +{ + //All of these should pass + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); +} + +TEST(ProductionCode, FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken) +{ + // You should see this line fail in your test summary + TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34)); + + // Notice the rest of these didn't get a chance to run because the line above failed. + // Unit tests abort each test function on the first sign of trouble. + // Then NEXT test function runs as normal. + TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888)); +} + +TEST(ProductionCode, FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue) +{ + //This should be true because setUp set this up for us before this test + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); + + //This should be true because we can still change our answer + Counter = 0x1234; + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} + +TEST(ProductionCode, FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain) +{ + //This should be true again because setup was rerun before this test (and after we changed it to 0x1234) + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); +} + +TEST(ProductionCode, FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed) +{ + //Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell + // you what actually happened...which in this case was a failure to setup the initial condition. + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} diff --git a/lab_6/unity/examples/example_2/test/TestProductionCode2.c b/lab_6/unity/examples/example_2/test/TestProductionCode2.c new file mode 100644 index 0000000..d9f4efe --- /dev/null +++ b/lab_6/unity/examples/example_2/test/TestProductionCode2.c @@ -0,0 +1,33 @@ +#include "ProductionCode2.h" +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP(ProductionCode2); + +/* These should be ignored because they are commented out in various ways: +#include "whatever.h" +*/ +//#include "somethingelse.h" + +TEST_SETUP(ProductionCode2) +{ +} + +TEST_TEAR_DOWN(ProductionCode2) +{ +} + +TEST(ProductionCode2, IgnoredTest) +{ + TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); +} + +TEST(ProductionCode2, AnotherIgnoredTest) +{ + TEST_IGNORE_MESSAGE("These Can Be Useful For Leaving Yourself Notes On What You Need To Do Yet"); +} + +TEST(ProductionCode2, ThisFunctionHasNotBeenTested_NeedsToBeImplemented) +{ + TEST_IGNORE(); //Like This +} diff --git a/lab_6/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c b/lab_6/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c new file mode 100644 index 0000000..6fcc3b1 --- /dev/null +++ b/lab_6/unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c @@ -0,0 +1,9 @@ +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(ProductionCode2) +{ + RUN_TEST_CASE(ProductionCode2, IgnoredTest); + RUN_TEST_CASE(ProductionCode2, AnotherIgnoredTest); + RUN_TEST_CASE(ProductionCode2, ThisFunctionHasNotBeenTested_NeedsToBeImplemented); +}
\ No newline at end of file diff --git a/lab_6/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c b/lab_6/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c new file mode 100644 index 0000000..41a416a --- /dev/null +++ b/lab_6/unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c @@ -0,0 +1,11 @@ +#include "unity.h" +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(ProductionCode) +{ + RUN_TEST_CASE(ProductionCode, FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode); + RUN_TEST_CASE(ProductionCode, FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken); + RUN_TEST_CASE(ProductionCode, FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue); + RUN_TEST_CASE(ProductionCode, FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain); + RUN_TEST_CASE(ProductionCode, FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed); +}
\ No newline at end of file diff --git a/lab_6/unity/examples/example_2/test/test_runners/all_tests.c b/lab_6/unity/examples/example_2/test/test_runners/all_tests.c new file mode 100644 index 0000000..e706ece --- /dev/null +++ b/lab_6/unity/examples/example_2/test/test_runners/all_tests.c @@ -0,0 +1,12 @@ +#include "unity_fixture.h" + +static void RunAllTests(void) +{ + RUN_TEST_GROUP(ProductionCode); + RUN_TEST_GROUP(ProductionCode2); +} + +int main(int argc, const char * argv[]) +{ + return UnityMain(argc, argv, RunAllTests); +} diff --git a/lab_6/unity/examples/example_3/helper/UnityHelper.c b/lab_6/unity/examples/example_3/helper/UnityHelper.c new file mode 100644 index 0000000..9cf42c6 --- /dev/null +++ b/lab_6/unity/examples/example_3/helper/UnityHelper.c @@ -0,0 +1,10 @@ +#include "unity.h" +#include "UnityHelper.h" +#include <stdio.h> +#include <string.h> + +void AssertEqualExampleStruct(const EXAMPLE_STRUCT_T expected, const EXAMPLE_STRUCT_T actual, const unsigned short line) +{ + UNITY_TEST_ASSERT_EQUAL_INT(expected.x, actual.x, line, "Example Struct Failed For Field x"); + UNITY_TEST_ASSERT_EQUAL_INT(expected.y, actual.y, line, "Example Struct Failed For Field y"); +} diff --git a/lab_6/unity/examples/example_3/helper/UnityHelper.h b/lab_6/unity/examples/example_3/helper/UnityHelper.h new file mode 100644 index 0000000..1516111 --- /dev/null +++ b/lab_6/unity/examples/example_3/helper/UnityHelper.h @@ -0,0 +1,12 @@ +#ifndef _TESTHELPER_H +#define _TESTHELPER_H + +#include "Types.h" + +void AssertEqualExampleStruct(const EXAMPLE_STRUCT_T expected, const EXAMPLE_STRUCT_T actual, const unsigned short line); + +#define UNITY_TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual, line, message) AssertEqualExampleStruct(expected, actual, line); + +#define TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual) UNITY_TEST_ASSERT_EQUAL_EXAMPLE_STRUCT_T(expected, actual, __LINE__, NULL); + +#endif // _TESTHELPER_H diff --git a/lab_6/unity/examples/example_3/makefile b/lab_6/unity/examples/example_3/makefile new file mode 100644 index 0000000..aa485f3 --- /dev/null +++ b/lab_6/unity/examples/example_3/makefile @@ -0,0 +1,65 @@ +# ========================================== +# Unity Project - A Test Framework for C +# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +# [Released under MIT License. Please refer to license.txt for details] +# ========================================== + +#We try to detect the OS we are running on, and adjust commands as needed +ifeq ($(OSTYPE),cygwin) + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +else ifeq ($(OS),Windows_NT) + CLEANUP = del /F /Q + MKDIR = mkdir + TARGET_EXTENSION=.exe +else + CLEANUP = rm -f + MKDIR = mkdir -p + TARGET_EXTENSION=.out +endif + +UNITY_ROOT=../.. +C_COMPILER=gcc + +CFLAGS=-std=c99 +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -Werror +CFLAGS += -Wpointer-arith +CFLAGS += -Wcast-align +CFLAGS += -Wwrite-strings +CFLAGS += -Wswitch-default +CFLAGS += -Wunreachable-code +CFLAGS += -Winit-self +CFLAGS += -Wlogical-op +CFLAGS += -Wmissing-field-initializers +CFLAGS += -Wno-unknown-pragmas +CFLAGS += -Wjump-misses-init +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wundef +CFLAGS += -Wunsafe-loop-optimizations +CFLAGS += -Wold-style-definition + +TARGET_BASE1=test1 +TARGET_BASE2=test2 +TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION) +TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION) +SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c +SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c +INC_DIRS=-Isrc -I$(UNITY_ROOT)/src +SYMBOLS=-DTEST + +all: clean default + +default: +# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/no_ruby/TestProductionCode_Runner.c +# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/no_ruby/TestProductionCode2_Runner.c + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1) + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2) + ./$(TARGET1) + ./$(TARGET2) + +clean: + $(CLEANUP) + diff --git a/lab_6/unity/examples/example_3/rakefile.rb b/lab_6/unity/examples/example_3/rakefile.rb new file mode 100644 index 0000000..9f1dbeb --- /dev/null +++ b/lab_6/unity/examples/example_3/rakefile.rb @@ -0,0 +1,43 @@ +HERE = File.expand_path(File.dirname(__FILE__)) + '/' +UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/../..' + +require 'rake' +require 'rake/clean' +require HERE+'rakefile_helper' + +TEMP_DIRS = [ + File.join(HERE, 'build') +] + +TEMP_DIRS.each do |dir| + directory(dir) + CLOBBER.include(dir) +end + +task :prepare_for_tests => TEMP_DIRS + +include RakefileHelpers + +# Load default configuration, for now +DEFAULT_CONFIG_FILE = 'target_gcc_32.yml' +configure_toolchain(DEFAULT_CONFIG_FILE) + +task :unit => [:prepare_for_tests] do + run_tests get_unit_test_files +end + +desc "Generate test summary" +task :summary do + report_summary +end + +desc "Build and test Unity" +task :all => [:clean, :unit, :summary] +task :default => [:clobber, :all] +task :ci => [:default] +task :cruise => [:default] + +desc "Load configuration" +task :config, :config_file do |t, args| + configure_toolchain(args[:config_file]) +end diff --git a/lab_6/unity/examples/example_3/rakefile_helper.rb b/lab_6/unity/examples/example_3/rakefile_helper.rb new file mode 100644 index 0000000..6702145 --- /dev/null +++ b/lab_6/unity/examples/example_3/rakefile_helper.rb @@ -0,0 +1,256 @@ +require 'yaml' +require 'fileutils' +require UNITY_ROOT+'/auto/unity_test_summary' +require UNITY_ROOT+'/auto/generate_test_runner' +require UNITY_ROOT+'/auto/colour_reporter' + +module RakefileHelpers + + C_EXTENSION = '.c' + + def load_configuration(config_file) + $cfg_file = config_file + $cfg = YAML.load(File.read($cfg_file)) + end + + def configure_clean + CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil? + end + + def configure_toolchain(config_file=DEFAULT_CONFIG_FILE) + config_file += '.yml' unless config_file =~ /\.yml$/ + load_configuration(config_file) + configure_clean + end + + def get_unit_test_files + path = $cfg['compiler']['unit_tests_path'] + 'Test*' + C_EXTENSION + path.gsub!(/\\/, '/') + FileList.new(path) + end + + def get_local_include_dirs + include_dirs = $cfg['compiler']['includes']['items'].dup + include_dirs.delete_if {|dir| dir.is_a?(Array)} + return include_dirs + end + + def extract_headers(filename) + includes = [] + lines = File.readlines(filename) + lines.each do |line| + m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/) + if not m.nil? + includes << m[1] + end + end + return includes + end + + def find_source_file(header, paths) + paths.each do |dir| + src_file = dir + header.ext(C_EXTENSION) + if (File.exists?(src_file)) + return src_file + end + end + return nil + end + + def tackit(strings) + if strings.is_a?(Array) + result = "\"#{strings.join}\"" + else + result = strings + end + return result + end + + def squash(prefix, items) + result = '' + items.each { |item| result += " #{prefix}#{tackit(item)}" } + return result + end + + def build_compiler_fields + command = tackit($cfg['compiler']['path']) + if $cfg['compiler']['defines']['items'].nil? + defines = '' + else + defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items']) + end + options = squash('', $cfg['compiler']['options']) + includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items']) + includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + return {:command => command, :defines => defines, :options => options, :includes => includes} + end + + def compile(file, defines=[]) + compiler = build_compiler_fields + cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " + + "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" + obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}" + execute(cmd_str + obj_file) + return obj_file + end + + def build_linker_fields + command = tackit($cfg['linker']['path']) + if $cfg['linker']['options'].nil? + options = '' + else + options = squash('', $cfg['linker']['options']) + end + if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?) + includes = '' + else + includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items']) + end + includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR) + return {:command => command, :options => options, :includes => includes} + end + + def link_it(exe_name, obj_list) + linker = build_linker_fields + cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " + + (obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).join + + $cfg['linker']['bin_files']['prefix'] + ' ' + + $cfg['linker']['bin_files']['destination'] + + exe_name + $cfg['linker']['bin_files']['extension'] + execute(cmd_str) + end + + def build_simulator_fields + return nil if $cfg['simulator'].nil? + if $cfg['simulator']['path'].nil? + command = '' + else + command = (tackit($cfg['simulator']['path']) + ' ') + end + if $cfg['simulator']['pre_support'].nil? + pre_support = '' + else + pre_support = squash('', $cfg['simulator']['pre_support']) + end + if $cfg['simulator']['post_support'].nil? + post_support = '' + else + post_support = squash('', $cfg['simulator']['post_support']) + end + return {:command => command, :pre_support => pre_support, :post_support => post_support} + end + + def execute(command_string, verbose=true, raise_on_fail=true) + report command_string + output = `#{command_string}`.chomp + report(output) if (verbose && !output.nil? && (output.length > 0)) + if (($?.exitstatus != 0) and (raise_on_fail)) + raise "Command failed. (Returned #{$?.exitstatus})" + end + return output + end + + def report_summary + summary = UnityTestSummary.new + summary.set_root_path(HERE) + results_glob = "#{$cfg['compiler']['build_path']}*.test*" + results_glob.gsub!(/\\/, '/') + results = Dir[results_glob] + summary.set_targets(results) + summary.run + fail_out "FAIL: There were failures" if (summary.failures > 0) + end + + def run_tests(test_files) + + report 'Running system tests...' + + # Tack on TEST define for compiling unit tests + load_configuration($cfg_file) + test_defines = ['TEST'] + $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil? + $cfg['compiler']['defines']['items'] << 'TEST' + + include_dirs = get_local_include_dirs + + # Build and execute each unit test + test_files.each do |test| + obj_list = [] + + # Detect dependencies and build required required modules + extract_headers(test).each do |header| + # Compile corresponding source file if it exists + src_file = find_source_file(header, include_dirs) + if !src_file.nil? + obj_list << compile(src_file, test_defines) + end + end + + # Build the test runner (generate if configured to do so) + test_base = File.basename(test, C_EXTENSION) + runner_name = test_base + '_Runner.c' + if $cfg['compiler']['runner_path'].nil? + runner_path = $cfg['compiler']['build_path'] + runner_name + test_gen = UnityTestRunnerGenerator.new($cfg_file) + test_gen.run(test, runner_path) + else + runner_path = $cfg['compiler']['runner_path'] + runner_name + end + + obj_list << compile(runner_path, test_defines) + + # Build the test module + obj_list << compile(test, test_defines) + + # Link the test executable + link_it(test_base, obj_list) + + # Execute unit test and generate results file + simulator = build_simulator_fields + executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + if simulator.nil? + cmd_str = executable + else + cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}" + end + output = execute(cmd_str, true, false) + test_results = $cfg['compiler']['build_path'] + test_base + if output.match(/OK$/m).nil? + test_results += '.testfail' + else + test_results += '.testpass' + end + File.open(test_results, 'w') { |f| f.print output } + end + end + + def build_application(main) + + report "Building application..." + + obj_list = [] + load_configuration($cfg_file) + main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION + + # Detect dependencies and build required required modules + include_dirs = get_local_include_dirs + extract_headers(main_path).each do |header| + src_file = find_source_file(header, include_dirs) + if !src_file.nil? + obj_list << compile(src_file) + end + end + + # Build the main source file + main_base = File.basename(main_path, C_EXTENSION) + obj_list << compile(main_path) + + # Create the executable + link_it(main_base, obj_list) + end + + def fail_out(msg) + puts msg + exit(-1) + end +end diff --git a/lab_6/unity/examples/example_3/readme.txt b/lab_6/unity/examples/example_3/readme.txt new file mode 100644 index 0000000..df6fb18 --- /dev/null +++ b/lab_6/unity/examples/example_3/readme.txt @@ -0,0 +1,19 @@ +Example 3 +========= + +This example project gives an example of some passing, ignored, and failing tests. +It's simple and meant for you to look over and get an idea for what all of this stuff does. + +You can build and test using the makefile if you have gcc installed (you may need to tweak +the locations of some tools in the makefile). Otherwise, the rake version will let you +test with gcc or a couple versions of IAR. You can tweak the yaml files to get those versions +running. + +Ruby is required if you're using the rake version (obviously). This version shows off most of +Unity's advanced features (automatically creating test runners, fancy summaries, etc.) + +The makefile version doesn't require anything outside of your normal build tools, but won't do the +extras for you. So that you can test right away, we've written the test runners for you and +put them in the test\no_ruby subdirectory. If you make changes to the tests or source, you might +need to update these (like when you add or remove tests). Do that for a while and you'll learn +why you really want to start using the Ruby tools.
\ No newline at end of file diff --git a/lab_6/unity/examples/example_3/src/ProductionCode.c b/lab_6/unity/examples/example_3/src/ProductionCode.c new file mode 100644 index 0000000..500b44b --- /dev/null +++ b/lab_6/unity/examples/example_3/src/ProductionCode.c @@ -0,0 +1,24 @@ + +#include "ProductionCode.h" + +int Counter = 0; +int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious array to search that is 1-based indexing instead of 0. + +// This function is supposed to search through NumbersToFind and find a particular number. +// If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since +// NumbersToFind is indexed from 1. Unfortunately it's broken +// (and should therefore be caught by our tests) +int FindFunction_WhichIsBroken(int NumberToFind) +{ + int i = 0; + while (i <= 8) //Notice I should have been in braces + i++; + if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it! + return i; + return 0; +} + +int FunctionWhichReturnsLocalVariable(void) +{ + return Counter; +} diff --git a/lab_6/unity/examples/example_3/src/ProductionCode.h b/lab_6/unity/examples/example_3/src/ProductionCode.h new file mode 100644 index 0000000..250ca0d --- /dev/null +++ b/lab_6/unity/examples/example_3/src/ProductionCode.h @@ -0,0 +1,3 @@ + +int FindFunction_WhichIsBroken(int NumberToFind); +int FunctionWhichReturnsLocalVariable(void); diff --git a/lab_6/unity/examples/example_3/src/ProductionCode2.c b/lab_6/unity/examples/example_3/src/ProductionCode2.c new file mode 100644 index 0000000..77c969f --- /dev/null +++ b/lab_6/unity/examples/example_3/src/ProductionCode2.c @@ -0,0 +1,11 @@ + +#include "ProductionCode2.h" + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction) +{ + (void)Poor; + (void)LittleFunction; + //Since There Are No Tests Yet, This Function Could Be Empty For All We Know. + // Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget + return (char*)0; +} diff --git a/lab_6/unity/examples/example_3/src/ProductionCode2.h b/lab_6/unity/examples/example_3/src/ProductionCode2.h new file mode 100644 index 0000000..34ae980 --- /dev/null +++ b/lab_6/unity/examples/example_3/src/ProductionCode2.h @@ -0,0 +1,2 @@ + +char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction); diff --git a/lab_6/unity/examples/example_3/target_gcc_32.yml b/lab_6/unity/examples/example_3/target_gcc_32.yml new file mode 100644 index 0000000..f155508 --- /dev/null +++ b/lab_6/unity/examples/example_3/target_gcc_32.yml @@ -0,0 +1,46 @@ +# Copied from ~Unity/targets/gcc_32.yml +unity_root: &unity_root '../..' +compiler: + path: gcc + source_path: 'src/' + unit_tests_path: &unit_tests_path 'test/' + build_path: &build_path 'build/' + options: + - '-c' + - '-m32' + - '-Wall' + - '-Wno-address' + - '-std=c99' + - '-pedantic' + includes: + prefix: '-I' + items: + - 'src/' + - '../../src/' + - *unit_tests_path + defines: + prefix: '-D' + items: + - UNITY_INCLUDE_DOUBLE + - UNITY_SUPPORT_TEST_CASES + object_files: + prefix: '-o' + extension: '.o' + destination: *build_path +linker: + path: gcc + options: + - -lm + - '-m32' + includes: + prefix: '-I' + object_files: + path: *build_path + extension: '.o' + bin_files: + prefix: '-o' + extension: '.exe' + destination: *build_path +colour: true +:unity: + :plugins: [] diff --git a/lab_6/unity/examples/example_3/test/TestProductionCode.c b/lab_6/unity/examples/example_3/test/TestProductionCode.c new file mode 100644 index 0000000..28a5581 --- /dev/null +++ b/lab_6/unity/examples/example_3/test/TestProductionCode.c @@ -0,0 +1,62 @@ + +#include "ProductionCode.h" +#include "unity.h" + +//sometimes you may want to get at local data in a module. +//for example: If you plan to pass by reference, this could be useful +//however, it should often be avoided +extern int Counter; + +void setUp(void) +{ + //This is run before EACH TEST + Counter = 0x5a5a; +} + +void tearDown(void) +{ +} + +void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void) +{ + //All of these should pass + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999)); + TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1)); +} + +void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void) +{ + // You should see this line fail in your test summary + TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34)); + + // Notice the rest of these didn't get a chance to run because the line above failed. + // Unit tests abort each test function on the first sign of trouble. + // Then NEXT test function runs as normal. + TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888)); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void) +{ + //This should be true because setUp set this up for us before this test + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); + + //This should be true because we can still change our answer + Counter = 0x1234; + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void) +{ + //This should be true again because setup was rerun before this test (and after we changed it to 0x1234) + TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable()); +} + +void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void) +{ + //Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell + // you what actually happened...which in this case was a failure to setup the initial condition. + TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable()); +} diff --git a/lab_6/unity/examples/example_3/test/TestProductionCode2.c b/lab_6/unity/examples/example_3/test/TestProductionCode2.c new file mode 100644 index 0000000..e2119cc --- /dev/null +++ b/lab_6/unity/examples/example_3/test/TestProductionCode2.c @@ -0,0 +1,31 @@ + +#include "ProductionCode2.h" +#include "unity.h" + +/* These should be ignored because they are commented out in various ways: +#include "whatever.h" +*/ +//#include "somethingelse.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_IgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("This Test Was Ignored On Purpose"); +} + +void test_AnotherIgnoredTest(void) +{ + TEST_IGNORE_MESSAGE("These Can Be Useful For Leaving Yourself Notes On What You Need To Do Yet"); +} + +void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void) +{ + TEST_IGNORE(); //Like This +} diff --git a/lab_6/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c b/lab_6/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c new file mode 100644 index 0000000..4d67701 --- /dev/null +++ b/lab_6/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c @@ -0,0 +1,33 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> + +char MessageBuffer[50]; + +extern void setUp(void); +extern void tearDown(void); + +extern void test_IgnoredTest(void); +extern void test_AnotherIgnoredTest(void); +extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void); + +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +int main(void) +{ + UnityBegin("test/TestProductionCode2.c"); + + RUN_TEST(test_IgnoredTest, 13); + RUN_TEST(test_AnotherIgnoredTest, 18); + RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23); + + UnityEnd(); + return 0; +} diff --git a/lab_6/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c b/lab_6/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c new file mode 100644 index 0000000..0a795ec --- /dev/null +++ b/lab_6/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c @@ -0,0 +1,37 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> + +char MessageBuffer[50]; + +extern void setUp(void); +extern void tearDown(void); + +extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void); +extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void); +extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void); + +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +int main(void) +{ + UnityBegin("test/TestProductionCode.c"); + + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20); + RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51); + RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57); + + UnityEnd(); + return 0; +} diff --git a/lab_6/unity/extras/eclipse/error_parsers.txt b/lab_6/unity/extras/eclipse/error_parsers.txt new file mode 100644 index 0000000..94e34ff --- /dev/null +++ b/lab_6/unity/extras/eclipse/error_parsers.txt @@ -0,0 +1,26 @@ +Eclipse error parsers +===================== + +These are a godsend for extracting & quickly navigating to +warnings & error messages from console output. Unforunately +I don't know how to write an Eclipse plugin so you'll have +to add them manually. + +To add a console parser to Eclipse, go to Window --> Preferences +--> C/C++ --> Build --> Settings. Click on the 'Error Parsers' +tab and then click the 'Add...' button. See the table below for +the parser fields to add. + +Eclipse will only parse the console output during a build, so +running your unit tests must be part of your build process. +Either add this to your make/rakefile, or add it as a post- +build step in your Eclipse project settings. + + +Unity unit test error parsers +----------------------------- +Severity Pattern File Line Description +------------------------------------------------------------------------------- +Error (\.+)(.*?):(\d+):(.*?):FAIL: (.*) $2 $3 $5 +Warning (\.+)(.*?):(\d+):(.*?):IGNORE: (.*) $2 $3 $5 +Warning (\.+)(.*?):(\d+):(.*?):IGNORE\s*$ $2 $3 Ignored test diff --git a/lab_6/unity/extras/fixture/rakefile.rb b/lab_6/unity/extras/fixture/rakefile.rb new file mode 100644 index 0000000..8c758fc --- /dev/null +++ b/lab_6/unity/extras/fixture/rakefile.rb @@ -0,0 +1,48 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+HERE = File.expand_path(File.dirname(__FILE__)) + '/'
+
+require 'rake'
+require 'rake/clean'
+require 'rake/testtask'
+require HERE + 'rakefile_helper'
+
+TEMP_DIRS = [
+ File.join(HERE, 'build')
+]
+
+TEMP_DIRS.each do |dir|
+ directory(dir)
+ CLOBBER.include(dir)
+end
+
+task :prepare_for_tests => TEMP_DIRS
+
+include RakefileHelpers
+
+# Load default configuration, for now
+DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'
+configure_toolchain(DEFAULT_CONFIG_FILE)
+
+task :unit => [:prepare_for_tests] do
+ run_tests
+end
+
+desc "Build and test Unity Framework"
+task :all => [:clean, :unit]
+task :default => [:clobber, :all]
+task :ci => [:no_color, :default]
+task :cruise => [:no_color, :default]
+
+desc "Load configuration"
+task :config, :config_file do |t, args|
+ configure_toolchain(args[:config_file])
+end
+
+task :no_color do
+ $colour_output = false
+end
diff --git a/lab_6/unity/extras/fixture/rakefile_helper.rb b/lab_6/unity/extras/fixture/rakefile_helper.rb new file mode 100644 index 0000000..dbc5ceb --- /dev/null +++ b/lab_6/unity/extras/fixture/rakefile_helper.rb @@ -0,0 +1,179 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+require 'yaml'
+require 'fileutils'
+require HERE+'../../auto/unity_test_summary'
+require HERE+'../../auto/generate_test_runner'
+require HERE+'../../auto/colour_reporter'
+
+module RakefileHelpers
+
+ C_EXTENSION = '.c'
+
+ def load_configuration(config_file)
+ unless ($configured)
+ $cfg_file = HERE+"../../test/targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
+ $cfg = YAML.load(File.read($cfg_file))
+ $colour_output = false unless $cfg['colour']
+ $configured = true if (config_file != DEFAULT_CONFIG_FILE)
+ end
+ end
+
+ def configure_clean
+ CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
+ end
+
+ def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
+ config_file += '.yml' unless config_file =~ /\.yml$/
+ config_file = config_file unless config_file =~ /[\\|\/]/
+ load_configuration(config_file)
+ configure_clean
+ end
+
+ def tackit(strings)
+ if strings.is_a?(Array)
+ result = "\"#{strings.join}\""
+ else
+ result = strings
+ end
+ return result
+ end
+
+ def squash(prefix, items)
+ result = ''
+ items.each { |item| result += " #{prefix}#{tackit(item)}" }
+ return result
+ end
+
+ def build_compiler_fields
+ command = tackit($cfg['compiler']['path'])
+ if $cfg['compiler']['defines']['items'].nil?
+ defines = ''
+ else
+ defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'])
+ end
+ options = squash('', $cfg['compiler']['options'])
+ includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
+ includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
+ return {:command => command, :defines => defines, :options => options, :includes => includes}
+ end
+
+ def compile(file, defines=[])
+ compiler = build_compiler_fields
+ unity_include = $cfg['compiler']['includes']['prefix']+'../../src'
+ cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " +
+ "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" +
+ "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
+ execute(cmd_str)
+ end
+
+ def build_linker_fields
+ command = tackit($cfg['linker']['path'])
+ if $cfg['linker']['options'].nil?
+ options = ''
+ else
+ options = squash('', $cfg['linker']['options'])
+ end
+ if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?)
+ includes = ''
+ else
+ includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
+ end
+ includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
+ return {:command => command, :options => options, :includes => includes}
+ end
+
+ def link_it(exe_name, obj_list)
+ linker = build_linker_fields
+ cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
+ (obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).join +
+ $cfg['linker']['bin_files']['prefix'] + ' ' +
+ $cfg['linker']['bin_files']['destination'] +
+ exe_name + $cfg['linker']['bin_files']['extension']
+ execute(cmd_str)
+ end
+
+ def build_simulator_fields
+ return nil if $cfg['simulator'].nil?
+ if $cfg['simulator']['path'].nil?
+ command = ''
+ else
+ command = (tackit($cfg['simulator']['path']) + ' ')
+ end
+ if $cfg['simulator']['pre_support'].nil?
+ pre_support = ''
+ else
+ pre_support = squash('', $cfg['simulator']['pre_support'])
+ end
+ if $cfg['simulator']['post_support'].nil?
+ post_support = ''
+ else
+ post_support = squash('', $cfg['simulator']['post_support'])
+ end
+ return {:command => command, :pre_support => pre_support, :post_support => post_support}
+ end
+
+ def execute(command_string, verbose=true)
+ report command_string
+ output = `#{command_string}`.chomp
+ report(output) if (verbose && !output.nil? && (output.length > 0))
+ if ($?.exitstatus != 0)
+ raise "Command failed. (Returned #{$?.exitstatus})"
+ end
+ return output
+ end
+
+ def report_summary
+ summary = UnityTestSummary.new
+ summary.set_root_path(HERE)
+ results_glob = "#{$cfg['compiler']['build_path']}*.test*"
+ results_glob.gsub!(/\\/, '/')
+ results = Dir[results_glob]
+ summary.set_targets(results)
+ summary.run
+ end
+
+ def run_tests
+ report 'Running Unity system tests...'
+
+ # Tack on TEST define for compiling unit tests
+ load_configuration($cfg_file)
+ test_defines = ['TEST']
+ $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
+
+ # Get a list of all source files needed
+ src_files = Dir[HERE+'src/*.c']
+ src_files += Dir[HERE+'test/*.c']
+ src_files += Dir[HERE+'test/main/*.c']
+ src_files << '../../src/unity.c'
+
+ # Build object files
+ src_files.each { |f| compile(f, test_defines) }
+ obj_list = src_files.map {|f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
+
+ # Link the test executable
+ test_base = "framework_test"
+ link_it(test_base, obj_list)
+
+ # Execute unit test and generate results file
+ simulator = build_simulator_fields
+ executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
+ if simulator.nil?
+ cmd_str = executable + " -v -r"
+ else
+ cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
+ end
+ output = execute(cmd_str)
+ test_results = $cfg['compiler']['build_path'] + test_base
+ if output.match(/OK$/m).nil?
+ test_results += '.testfail'
+ else
+ test_results += '.testpass'
+ end
+ File.open(test_results, 'w') { |f| f.print output }
+ end
+end
diff --git a/lab_6/unity/extras/fixture/readme.txt b/lab_6/unity/extras/fixture/readme.txt new file mode 100644 index 0000000..6b9a78c --- /dev/null +++ b/lab_6/unity/extras/fixture/readme.txt @@ -0,0 +1,9 @@ +Copyright (c) 2010 James Grenning and Contributed to Unity Project + +Unity Project - A Test Framework for C +Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams +[Released under MIT License. Please refer to license.txt for details] + +This Framework is an optional add-on to Unity. By including unity_framework.h in place of unity.h, +you may now work with Unity in a manner similar to CppUTest. This framework adds the concepts of +test groups and gives finer control of your tests over the command line.
\ No newline at end of file diff --git a/lab_6/unity/extras/fixture/src/unity_fixture.c b/lab_6/unity/extras/fixture/src/unity_fixture.c new file mode 100644 index 0000000..6bdbe5b --- /dev/null +++ b/lab_6/unity/extras/fixture/src/unity_fixture.c @@ -0,0 +1,398 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include <string.h> +#include <stdio.h> +#include "unity_fixture.h" +#include "unity_internals.h" + +UNITY_FIXTURE_T UnityFixture; + +//If you decide to use the function pointer approach. +int (*outputChar)(int) = putchar; + +int verbose = 0; + +void setUp(void); +void tearDown(void); +void setUp(void) { /*does nothing*/ } +void tearDown(void) { /*does nothing*/ } + +static void announceTestRun(unsigned int runNumber) +{ + UnityPrint("Unity test run "); + UnityPrintNumber(runNumber+1); + UnityPrint(" of "); + UnityPrintNumber(UnityFixture.RepeatCount); + UNITY_OUTPUT_CHAR('\n'); +} + +int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)) +{ + int result = UnityGetCommandLineOptions(argc, argv); + unsigned int r; + if (result != 0) + return result; + + for (r = 0; r < UnityFixture.RepeatCount; r++) + { + UnityBegin(argv[0]); + announceTestRun(r); + runAllTests(); + UNITY_OUTPUT_CHAR('\n'); + UnityEnd(); + } + + return UnityFailureCount(); +} + +static int selected(const char * filter, const char * name) +{ + if (filter == 0) + return 1; + return strstr(name, filter) ? 1 : 0; +} + +static int testSelected(const char* test) +{ + return selected(UnityFixture.NameFilter, test); +} + +static int groupSelected(const char* group) +{ + return selected(UnityFixture.GroupFilter, group); +} + +static void runTestCase(void) +{ + +} + +void UnityTestRunner(unityfunction* setup, + unityfunction* testBody, + unityfunction* teardown, + const char * printableName, + const char * group, + const char * name, + const char * file, int line) +{ + if (testSelected(name) && groupSelected(group)) + { + Unity.CurrentTestFailed = 0; + Unity.TestFile = file; + Unity.CurrentTestName = printableName; + Unity.CurrentTestLineNumber = line; + if (!UnityFixture.Verbose) + UNITY_OUTPUT_CHAR('.'); + else + UnityPrint(printableName); + + Unity.NumberOfTests++; + UnityMalloc_StartTest(); + UnityPointer_Init(); + + runTestCase(); + if (TEST_PROTECT()) + { + setup(); + testBody(); + } + if (TEST_PROTECT()) + { + teardown(); + } + if (TEST_PROTECT()) + { + UnityPointer_UndoAllSets(); + if (!Unity.CurrentTestFailed) + UnityMalloc_EndTest(); + } + UnityConcludeFixtureTest(); + } +} + +void UnityIgnoreTest(const char * printableName) +{ + Unity.NumberOfTests++; + Unity.CurrentTestIgnored = 1; + if (!UnityFixture.Verbose) + UNITY_OUTPUT_CHAR('!'); + else + UnityPrint(printableName); + UnityConcludeFixtureTest(); +} + + +//------------------------------------------------- +//Malloc and free stuff +// +#define MALLOC_DONT_FAIL -1 +static int malloc_count; +static int malloc_fail_countdown = MALLOC_DONT_FAIL; + +void UnityMalloc_StartTest(void) +{ + malloc_count = 0; + malloc_fail_countdown = MALLOC_DONT_FAIL; +} + +void UnityMalloc_EndTest(void) +{ + malloc_fail_countdown = MALLOC_DONT_FAIL; + if (malloc_count != 0) + { + TEST_FAIL_MESSAGE("This test leaks!"); + } +} + +void UnityMalloc_MakeMallocFailAfterCount(int countdown) +{ + malloc_fail_countdown = countdown; +} + +#ifdef malloc +#undef malloc +#endif + +#ifdef free +#undef free +#endif + +#ifdef calloc +#undef calloc +#endif + +#ifdef realloc +#undef realloc +#endif + +#include <stdlib.h> +#include <string.h> + +typedef struct GuardBytes +{ + size_t size; + char guard[sizeof(size_t)]; +} Guard; + + +static const char * end = "END"; + +void * unity_malloc(size_t size) +{ + char* mem; + Guard* guard; + + if (malloc_fail_countdown != MALLOC_DONT_FAIL) + { + if (malloc_fail_countdown == 0) + return 0; + malloc_fail_countdown--; + } + + malloc_count++; + + guard = (Guard*)malloc(size + sizeof(Guard) + 4); + guard->size = size; + mem = (char*)&(guard[1]); + memcpy(&mem[size], end, strlen(end) + 1); + + return (void*)mem; +} + +static int isOverrun(void * mem) +{ + Guard* guard = (Guard*)mem; + char* memAsChar = (char*)mem; + guard--; + + return strcmp(&memAsChar[guard->size], end) != 0; +} + +static void release_memory(void * mem) +{ + Guard* guard = (Guard*)mem; + guard--; + + malloc_count--; + free(guard); +} + +void unity_free(void * mem) +{ + int overrun = isOverrun(mem);//strcmp(&memAsChar[guard->size], end) != 0; + release_memory(mem); + if (overrun) + { + TEST_FAIL_MESSAGE("Buffer overrun detected during free()"); + } +} + +void* unity_calloc(size_t num, size_t size) +{ + void* mem = unity_malloc(num * size); + memset(mem, 0, num*size); + return mem; +} + +void* unity_realloc(void * oldMem, size_t size) +{ + Guard* guard = (Guard*)oldMem; +// char* memAsChar = (char*)oldMem; + void* newMem; + + if (oldMem == 0) + return unity_malloc(size); + + guard--; + if (isOverrun(oldMem)) + { + release_memory(oldMem); + TEST_FAIL_MESSAGE("Buffer overrun detected during realloc()"); + } + + if (size == 0) + { + release_memory(oldMem); + return 0; + } + + if (guard->size >= size) + return oldMem; + + newMem = unity_malloc(size); + memcpy(newMem, oldMem, guard->size); + unity_free(oldMem); + return newMem; +} + + +//-------------------------------------------------------- +//Automatic pointer restoration functions +typedef struct _PointerPair +{ + struct _PointerPair * next; + void ** pointer; + void * old_value; +} PointerPair; + +enum {MAX_POINTERS=50}; +static PointerPair pointer_store[MAX_POINTERS]; +static int pointer_index = 0; + +void UnityPointer_Init(void) +{ + pointer_index = 0; +} + +void UnityPointer_Set(void ** pointer, void * newValue) +{ + if (pointer_index >= MAX_POINTERS) + TEST_FAIL_MESSAGE("Too many pointers set"); + + pointer_store[pointer_index].pointer = pointer; + pointer_store[pointer_index].old_value = *pointer; + *pointer = newValue; + pointer_index++; +} + +void UnityPointer_UndoAllSets(void) +{ + while (pointer_index > 0) + { + pointer_index--; + *(pointer_store[pointer_index].pointer) = + pointer_store[pointer_index].old_value; + + } +} + +int UnityFailureCount(void) +{ + return Unity.TestFailures; +} + +int UnityGetCommandLineOptions(int argc, const char* argv[]) +{ + int i; + UnityFixture.Verbose = 0; + UnityFixture.GroupFilter = 0; + UnityFixture.NameFilter = 0; + UnityFixture.RepeatCount = 1; + + if (argc == 1) + return 0; + + for (i = 1; i < argc; ) + { + if (strcmp(argv[i], "-v") == 0) + { + UnityFixture.Verbose = 1; + i++; + } + else if (strcmp(argv[i], "-g") == 0) + { + i++; + if (i >= argc) + return 1; + UnityFixture.GroupFilter = argv[i]; + i++; + } + else if (strcmp(argv[i], "-n") == 0) + { + i++; + if (i >= argc) + return 1; + UnityFixture.NameFilter = argv[i]; + i++; + } + else if (strcmp(argv[i], "-r") == 0) + { + UnityFixture.RepeatCount = 2; + i++; + if (i < argc) + { + if (*(argv[i]) >= '0' && *(argv[i]) <= '9') + { + UnityFixture.RepeatCount = atoi(argv[i]); + i++; + } + } + } else { + // ignore unknown parameter + i++; + } + } + return 0; +} + +void UnityConcludeFixtureTest(void) +{ + if (Unity.CurrentTestIgnored) + { + if (UnityFixture.Verbose) + { + UNITY_OUTPUT_CHAR('\n'); + } + Unity.TestIgnores++; + } + else if (!Unity.CurrentTestFailed) + { + if (UnityFixture.Verbose) + { + UnityPrint(" PASS"); + UNITY_OUTPUT_CHAR('\n'); + } + } + else if (Unity.CurrentTestFailed) + { + Unity.TestFailures++; + } + + Unity.CurrentTestFailed = 0; + Unity.CurrentTestIgnored = 0; +} diff --git a/lab_6/unity/extras/fixture/src/unity_fixture.h b/lab_6/unity/extras/fixture/src/unity_fixture.h new file mode 100644 index 0000000..e176bbd --- /dev/null +++ b/lab_6/unity/extras/fixture/src/unity_fixture.h @@ -0,0 +1,86 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_FIXTURE_H_ +#define UNITY_FIXTURE_H_ + +#include "unity.h" +#include "unity_internals.h" +#include "unity_fixture_malloc_overrides.h" +#include "unity_fixture_internals.h" + +int UnityMain(int argc, const char* argv[], void (*runAllTests)(void)); + + +#define TEST_GROUP(group)\ + static const char* TEST_GROUP_##group = #group + +#define TEST_SETUP(group) void TEST_##group##_SETUP(void);\ + void TEST_##group##_SETUP(void) + +#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\ + void TEST_##group##_TEAR_DOWN(void) + + +#define TEST(group, name) \ + void TEST_##group##_##name##_(void);\ + void TEST_##group##_##name##_run(void);\ + void TEST_##group##_##name##_run(void)\ + {\ + UnityTestRunner(TEST_##group##_SETUP,\ + TEST_##group##_##name##_,\ + TEST_##group##_TEAR_DOWN,\ + "TEST(" #group ", " #name ")",\ + TEST_GROUP_##group, #name,\ + __FILE__, __LINE__);\ + }\ + void TEST_##group##_##name##_(void) + +#define IGNORE_TEST(group, name) \ + void TEST_##group##_##name##_(void);\ + void TEST_##group##_##name##_run(void);\ + void TEST_##group##_##name##_run(void)\ + {\ + UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")");\ + }\ + void TEST_##group##_##name##_(void) + +#define DECLARE_TEST_CASE(group, name) \ + void TEST_##group##_##name##_run(void) + +#define RUN_TEST_CASE(group, name) \ + { DECLARE_TEST_CASE(group, name);\ + TEST_##group##_##name##_run(); } + +//This goes at the bottom of each test file or in a separate c file +#define TEST_GROUP_RUNNER(group)\ + void TEST_##group##_GROUP_RUNNER_runAll(void);\ + void TEST_##group##_GROUP_RUNNER(void);\ + void TEST_##group##_GROUP_RUNNER(void)\ + {\ + TEST_##group##_GROUP_RUNNER_runAll();\ + }\ + void TEST_##group##_GROUP_RUNNER_runAll(void) + +//Call this from main +#define RUN_TEST_GROUP(group)\ + { void TEST_##group##_GROUP_RUNNER(void);\ + TEST_##group##_GROUP_RUNNER(); } + +//CppUTest Compatibility Macros +#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&ptr, (void*)newPointerValue) +#define TEST_ASSERT_POINTERS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_PTR(expected, actual) +#define TEST_ASSERT_BYTES_EQUAL(expected, actual) TEST_ASSERT_EQUAL_HEX8(0xff & (expected), 0xff & (actual)) +#define FAIL(message) TEST_FAIL((message)) +#define CHECK(condition) TEST_ASSERT_TRUE((condition)) +#define LONGS_EQUAL(expected, actual) TEST_ASSERT_EQUAL_INT((expected), (actual)) +#define STRCMP_EQUAL(expected, actual) TEST_ASSERT_EQUAL_STRING((expected), (actual)) +#define DOUBLES_EQUAL(expected, actual, delta) TEST_ASSERT_FLOAT_WITHIN(((expected), (actual), (delta)) + +void UnityMalloc_MakeMallocFailAfterCount(int count); + +#endif /* UNITY_FIXTURE_H_ */ diff --git a/lab_6/unity/extras/fixture/src/unity_fixture_internals.h b/lab_6/unity/extras/fixture/src/unity_fixture_internals.h new file mode 100644 index 0000000..c4099fa --- /dev/null +++ b/lab_6/unity/extras/fixture/src/unity_fixture_internals.h @@ -0,0 +1,44 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_FIXTURE_INTERNALS_H_ +#define UNITY_FIXTURE_INTERNALS_H_ + +typedef struct _UNITY_FIXTURE_T +{ + int Verbose; + unsigned int RepeatCount; + const char* NameFilter; + const char* GroupFilter; +} UNITY_FIXTURE_T; + +typedef void unityfunction(void); +void UnityTestRunner(unityfunction * setup, + unityfunction * body, + unityfunction * teardown, + const char * printableName, + const char * group, + const char * name, + const char * file, int line); + +void UnityIgnoreTest(const char * printableName); +void UnityMalloc_StartTest(void); +void UnityMalloc_EndTest(void); +int UnityFailureCount(void); +int UnityGetCommandLineOptions(int argc, const char* argv[]); +void UnityConcludeFixtureTest(void); + +void UnityPointer_Set(void ** ptr, void * newValue); +void UnityPointer_UndoAllSets(void); +void UnityPointer_Init(void); + +void UnityAssertEqualPointer(const void * expected, + const void * actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +#endif /* UNITY_FIXTURE_INTERNALS_H_ */ diff --git a/lab_6/unity/extras/fixture/src/unity_fixture_malloc_overrides.h b/lab_6/unity/extras/fixture/src/unity_fixture_malloc_overrides.h new file mode 100644 index 0000000..1e10014 --- /dev/null +++ b/lab_6/unity/extras/fixture/src/unity_fixture_malloc_overrides.h @@ -0,0 +1,21 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_ +#define UNITY_FIXTURE_MALLOC_OVERRIDES_H_ + +#define malloc unity_malloc +#define calloc unity_calloc +#define realloc unity_realloc +#define free unity_free + +void* unity_malloc(size_t size); +void* unity_calloc(size_t num, size_t size); +void* unity_realloc(void * oldMem, size_t size); +void unity_free(void * mem); + +#endif /* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */ diff --git a/lab_6/unity/extras/fixture/test/main/AllTests.c b/lab_6/unity/extras/fixture/test/main/AllTests.c new file mode 100644 index 0000000..7d0577e --- /dev/null +++ b/lab_6/unity/extras/fixture/test/main/AllTests.c @@ -0,0 +1,21 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity_fixture.h" + +static void runAllTests(void) +{ + RUN_TEST_GROUP(UnityFixture); + RUN_TEST_GROUP(UnityCommandOptions); + RUN_TEST_GROUP(LeakDetection) +} + +int main(int argc, const char* argv[]) +{ + return UnityMain(argc, argv, runAllTests); +} + diff --git a/lab_6/unity/extras/fixture/test/testunity_fixture.c b/lab_6/unity/extras/fixture/test/testunity_fixture.c new file mode 100644 index 0000000..de0c04c --- /dev/null +++ b/lab_6/unity/extras/fixture/test/testunity_fixture.c @@ -0,0 +1,39 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity_fixture.h" + +static int data = -1; + +TEST_GROUP(mygroup); + +TEST_SETUP(mygroup) +{ + data = 0; +} + +TEST_TEAR_DOWN(mygroup) +{ + data = -1; +} + +TEST(mygroup, test1) +{ + TEST_ASSERT_EQUAL_INT(0, data); +} + +TEST(mygroup, test2) +{ + TEST_ASSERT_EQUAL_INT(0, data); + data = 5; +} + +TEST(mygroup, test3) +{ + data = 7; + TEST_ASSERT_EQUAL_INT(7, data); +} diff --git a/lab_6/unity/extras/fixture/test/unity_fixture_Test.c b/lab_6/unity/extras/fixture/test/unity_fixture_Test.c new file mode 100644 index 0000000..1f209e9 --- /dev/null +++ b/lab_6/unity/extras/fixture/test/unity_fixture_Test.c @@ -0,0 +1,341 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity_fixture.h" +#include "unity_output_Spy.h" +#include <stdlib.h> +#include <string.h> + +extern UNITY_FIXTURE_T UnityFixture; + +TEST_GROUP(UnityFixture); + +TEST_SETUP(UnityFixture) +{ +} + +TEST_TEAR_DOWN(UnityFixture) +{ +} + +int my_int; +int* pointer1 = 0; +int* pointer2 = (int*)2; +int* pointer3 = (int*)3; +int int1; +int int2; +int int3; +int int4; + +TEST(UnityFixture, PointerSetting) +{ + TEST_ASSERT_POINTERS_EQUAL(pointer1, 0); + UT_PTR_SET(pointer1, &int1); + UT_PTR_SET(pointer2, &int2); + UT_PTR_SET(pointer3, &int3); + TEST_ASSERT_POINTERS_EQUAL(pointer1, &int1); + TEST_ASSERT_POINTERS_EQUAL(pointer2, &int2); + TEST_ASSERT_POINTERS_EQUAL(pointer3, &int3); + UT_PTR_SET(pointer1, &int4); + UnityPointer_UndoAllSets(); + TEST_ASSERT_POINTERS_EQUAL(pointer1, 0); + TEST_ASSERT_POINTERS_EQUAL(pointer2, (int*)2); + TEST_ASSERT_POINTERS_EQUAL(pointer3, (int*)3); +} + +TEST(UnityFixture, ForceMallocFail) +{ + void* m; + void* mfails; + UnityMalloc_MakeMallocFailAfterCount(1); + m = malloc(10); + CHECK(m); + mfails = malloc(10); + TEST_ASSERT_POINTERS_EQUAL(0, mfails); + free(m); +} + +TEST(UnityFixture, ReallocSmallerIsUnchanged) +{ + void* m1 = malloc(10); + void* m2 = realloc(m1, 5); + TEST_ASSERT_POINTERS_EQUAL(m1, m2); + free(m2); +} + +TEST(UnityFixture, ReallocSameIsUnchanged) +{ + void* m1 = malloc(10); + void* m2 = realloc(m1, 10); + TEST_ASSERT_POINTERS_EQUAL(m1, m2); + free(m2); +} + +TEST(UnityFixture, ReallocLargerNeeded) +{ + void* m1 = malloc(10); + void* m2; + strcpy((char*)m1, "123456789"); + m2 = realloc(m1, 15); + CHECK(m1 != m2); + STRCMP_EQUAL("123456789", m2); + free(m2); +} + +TEST(UnityFixture, ReallocNullPointerIsLikeMalloc) +{ + void* m = realloc(0, 15); + CHECK(m != 0); + free(m); +} + +TEST(UnityFixture, ReallocSizeZeroFreesMemAndReturnsNullPointer) +{ + void* m1 = malloc(10); + void* m2 = realloc(m1, 0); + TEST_ASSERT_POINTERS_EQUAL(0, m2); +} + +TEST(UnityFixture, CallocFillsWithZero) +{ + void* m = calloc(3, sizeof(char)); + char* s = (char*)m; + TEST_ASSERT_BYTES_EQUAL(0, s[0]); + TEST_ASSERT_BYTES_EQUAL(0, s[1]); + TEST_ASSERT_BYTES_EQUAL(0, s[2]); + free(m); +} + +char *p1; +char *p2; + +TEST(UnityFixture, PointerSet) +{ + char c1; + char c2; + char newC1; + char newC2; + p1 = &c1; + p2 = &c2; + + UnityPointer_Init(); + UT_PTR_SET(p1, &newC1); + UT_PTR_SET(p2, &newC2); + TEST_ASSERT_POINTERS_EQUAL(&newC1, p1); + TEST_ASSERT_POINTERS_EQUAL(&newC2, p2); + UnityPointer_UndoAllSets(); + TEST_ASSERT_POINTERS_EQUAL(&c1, p1); + TEST_ASSERT_POINTERS_EQUAL(&c2, p2); +} + +//------------------------------------------------------------ + +TEST_GROUP(UnityCommandOptions); + +int savedVerbose; +int savedRepeat; +const char* savedName; +const char* savedGroup; + +TEST_SETUP(UnityCommandOptions) +{ + savedVerbose = UnityFixture.Verbose; + savedRepeat = UnityFixture.RepeatCount; + savedName = UnityFixture.NameFilter; + savedGroup = UnityFixture.GroupFilter; +} + +TEST_TEAR_DOWN(UnityCommandOptions) +{ + UnityFixture.Verbose = savedVerbose; + UnityFixture.RepeatCount= savedRepeat; + UnityFixture.NameFilter = savedName; + UnityFixture.GroupFilter = savedGroup; +} + + +static const char* noOptions[] = { + "testrunner.exe" +}; + +TEST(UnityCommandOptions, DefaultOptions) +{ + UnityGetCommandLineOptions(1, noOptions); + TEST_ASSERT_EQUAL(0, UnityFixture.Verbose); + TEST_ASSERT_POINTERS_EQUAL(0, UnityFixture.GroupFilter); + TEST_ASSERT_POINTERS_EQUAL(0, UnityFixture.NameFilter); + TEST_ASSERT_EQUAL(1, UnityFixture.RepeatCount); +} + +static const char* verbose[] = { + "testrunner.exe", + "-v" +}; + +TEST(UnityCommandOptions, OptionVerbose) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(2, verbose)); + TEST_ASSERT_EQUAL(1, UnityFixture.Verbose); +} + +static const char* group[] = { + "testrunner.exe", + "-g", "groupname" +}; + +TEST(UnityCommandOptions, OptionSelectTestByGroup) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(3, group)); + STRCMP_EQUAL("groupname", UnityFixture.GroupFilter); +} + +static const char* name[] = { + "testrunner.exe", + "-n", "testname" +}; + +TEST(UnityCommandOptions, OptionSelectTestByName) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(3, name)); + STRCMP_EQUAL("testname", UnityFixture.NameFilter); +} + +static const char* repeat[] = { + "testrunner.exe", + "-r", "99" +}; + +TEST(UnityCommandOptions, OptionSelectRepeatTestsDefaultCount) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(2, repeat)); + TEST_ASSERT_EQUAL(2, UnityFixture.RepeatCount); +} + +TEST(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(3, repeat)); + TEST_ASSERT_EQUAL(99, UnityFixture.RepeatCount); +} + +static const char* multiple[] = { + "testrunner.exe", + "-v", + "-g", "groupname", + "-n", "testname", + "-r", "98" +}; + +TEST(UnityCommandOptions, MultipleOptions) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(8, multiple)); + TEST_ASSERT_EQUAL(1, UnityFixture.Verbose); + STRCMP_EQUAL("groupname", UnityFixture.GroupFilter); + STRCMP_EQUAL("testname", UnityFixture.NameFilter); + TEST_ASSERT_EQUAL(98, UnityFixture.RepeatCount); +} + +static const char* dashRNotLast[] = { + "testrunner.exe", + "-v", + "-g", "gggg", + "-r", + "-n", "tttt", +}; + +TEST(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(7, dashRNotLast)); + TEST_ASSERT_EQUAL(1, UnityFixture.Verbose); + STRCMP_EQUAL("gggg", UnityFixture.GroupFilter); + STRCMP_EQUAL("tttt", UnityFixture.NameFilter); + TEST_ASSERT_EQUAL(2, UnityFixture.RepeatCount); +} + +static const char* unknownCommand[] = { + "testrunner.exe", + "-v", + "-g", "groupname", + "-n", "testname", + "-r", "98", + "-z" +}; +TEST(UnityCommandOptions, UnknownCommandIsIgnored) +{ + TEST_ASSERT_EQUAL(0, UnityGetCommandLineOptions(9, unknownCommand)); + TEST_ASSERT_EQUAL(1, UnityFixture.Verbose); + STRCMP_EQUAL("groupname", UnityFixture.GroupFilter); + STRCMP_EQUAL("testname", UnityFixture.NameFilter); + TEST_ASSERT_EQUAL(98, UnityFixture.RepeatCount); +} + + +//------------------------------------------------------------ + +TEST_GROUP(LeakDetection); + +TEST_SETUP(LeakDetection) +{ + UnityOutputCharSpy_Create(1000); +} + +TEST_TEAR_DOWN(LeakDetection) +{ + UnityOutputCharSpy_Destroy(); +} + +#define EXPECT_ABORT_BEGIN \ + { \ + jmp_buf TestAbortFrame; \ + memcpy(TestAbortFrame, Unity.AbortFrame, sizeof(jmp_buf)); \ + if (TEST_PROTECT()) \ + { + +#define EXPECT_ABORT_END \ + } \ + memcpy(Unity.AbortFrame, TestAbortFrame, sizeof(jmp_buf)); \ + } + +TEST(LeakDetection, DetectsLeak) +{ + void* m = malloc(10); + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + UnityMalloc_EndTest(); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + CHECK(strstr(UnityOutputCharSpy_Get(), "This test leaks!")); + free(m); + Unity.CurrentTestFailed = 0; +} + +TEST(LeakDetection, BufferOverrunFoundDuringFree) +{ + void* m = malloc(10); + char* s = (char*)m; + s[10] = (char)0xFF; + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + free(m); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()")); + Unity.CurrentTestFailed = 0; +} + +TEST(LeakDetection, BufferOverrunFoundDuringRealloc) +{ + void* m = malloc(10); + char* s = (char*)m; + s[10] = (char)0xFF; + UnityOutputCharSpy_Enable(1); + EXPECT_ABORT_BEGIN + m = realloc(m, 100); + EXPECT_ABORT_END + UnityOutputCharSpy_Enable(0); + CHECK(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()")); + Unity.CurrentTestFailed = 0; +} diff --git a/lab_6/unity/extras/fixture/test/unity_fixture_TestRunner.c b/lab_6/unity/extras/fixture/test/unity_fixture_TestRunner.c new file mode 100644 index 0000000..6fb0602 --- /dev/null +++ b/lab_6/unity/extras/fixture/test/unity_fixture_TestRunner.c @@ -0,0 +1,41 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#include "unity_fixture.h" + +TEST_GROUP_RUNNER(UnityFixture) +{ + RUN_TEST_CASE(UnityFixture, PointerSetting); + RUN_TEST_CASE(UnityFixture, ForceMallocFail); + RUN_TEST_CASE(UnityFixture, ReallocSmallerIsUnchanged); + RUN_TEST_CASE(UnityFixture, ReallocSameIsUnchanged); + RUN_TEST_CASE(UnityFixture, ReallocLargerNeeded); + RUN_TEST_CASE(UnityFixture, ReallocNullPointerIsLikeMalloc); + RUN_TEST_CASE(UnityFixture, ReallocSizeZeroFreesMemAndReturnsNullPointer); + RUN_TEST_CASE(UnityFixture, CallocFillsWithZero); + RUN_TEST_CASE(UnityFixture, PointerSet); +} + +TEST_GROUP_RUNNER(UnityCommandOptions) +{ + RUN_TEST_CASE(UnityCommandOptions, DefaultOptions); + RUN_TEST_CASE(UnityCommandOptions, OptionVerbose); + RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByGroup); + RUN_TEST_CASE(UnityCommandOptions, OptionSelectTestByName); + RUN_TEST_CASE(UnityCommandOptions, OptionSelectRepeatTestsDefaultCount); + RUN_TEST_CASE(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount); + RUN_TEST_CASE(UnityCommandOptions, MultipleOptions); + RUN_TEST_CASE(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified); + RUN_TEST_CASE(UnityCommandOptions, UnknownCommandIsIgnored); +} + +TEST_GROUP_RUNNER(LeakDetection) +{ + RUN_TEST_CASE(LeakDetection, DetectsLeak); + RUN_TEST_CASE(LeakDetection, BufferOverrunFoundDuringFree); + RUN_TEST_CASE(LeakDetection, BufferOverrunFoundDuringRealloc); +} diff --git a/lab_6/unity/extras/fixture/test/unity_output_Spy.c b/lab_6/unity/extras/fixture/test/unity_output_Spy.c new file mode 100644 index 0000000..0a0ad04 --- /dev/null +++ b/lab_6/unity/extras/fixture/test/unity_output_Spy.c @@ -0,0 +1,56 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + + +#include "unity_output_Spy.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +static int size; +static int count; +static char* buffer; +static int spy_enable; + +void UnityOutputCharSpy_Create(int s) +{ + size = s; + count = 0; + spy_enable = 0; + buffer = malloc(size); + memset(buffer, 0, size); +} + +void UnityOutputCharSpy_Destroy(void) +{ + size = 0; + free(buffer); +} + +int UnityOutputCharSpy_OutputChar(int c) +{ + if (spy_enable) + { + if (count < (size-1)) + buffer[count++] = c; + } + else + { + putchar(c); + } + return c; +} + +const char * UnityOutputCharSpy_Get(void) +{ + return buffer; +} + +void UnityOutputCharSpy_Enable(int enable) +{ + spy_enable = enable; +} diff --git a/lab_6/unity/extras/fixture/test/unity_output_Spy.h b/lab_6/unity/extras/fixture/test/unity_output_Spy.h new file mode 100644 index 0000000..791f6a5 --- /dev/null +++ b/lab_6/unity/extras/fixture/test/unity_output_Spy.h @@ -0,0 +1,17 @@ +//- Copyright (c) 2010 James Grenning and Contributed to Unity Project +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef D_unity_output_Spy_H +#define D_unity_output_Spy_H + +void UnityOutputCharSpy_Create(int s); +void UnityOutputCharSpy_Destroy(void); +int UnityOutputCharSpy_OutputChar(int c); +const char * UnityOutputCharSpy_Get(void); +void UnityOutputCharSpy_Enable(int enable); + +#endif diff --git a/lab_6/unity/release/build.info b/lab_6/unity/release/build.info new file mode 100644 index 0000000..7871b21 --- /dev/null +++ b/lab_6/unity/release/build.info @@ -0,0 +1,2 @@ +118 + diff --git a/lab_6/unity/release/version.info b/lab_6/unity/release/version.info new file mode 100644 index 0000000..6b2d349 --- /dev/null +++ b/lab_6/unity/release/version.info @@ -0,0 +1,2 @@ +2.1.0 + diff --git a/lab_6/unity/src/foo.c b/lab_6/unity/src/foo.c new file mode 100644 index 0000000..32645d6 --- /dev/null +++ b/lab_6/unity/src/foo.c @@ -0,0 +1,6 @@ +#include "foo.h"
+
+uint16_t squareNumber (uint8_t numberToBeSquared)
+{
+ return ((uint16_t) numberToBeSquared * numberToBeSquared);
+}
diff --git a/lab_6/unity/src/foo.h b/lab_6/unity/src/foo.h new file mode 100644 index 0000000..fcc0656 --- /dev/null +++ b/lab_6/unity/src/foo.h @@ -0,0 +1,9 @@ +#ifndef _FOO_H
+#define _FOO_H
+
+ #include <stdint.h>
+
+ // Function prototype.
+ uint16_t squareNumber (uint8_t numberToBeSquared);
+
+#endif // _FOO_H
diff --git a/lab_6/unity/src/unity.c b/lab_6/unity/src/unity.c new file mode 100644 index 0000000..d349f6e --- /dev/null +++ b/lab_6/unity/src/unity.c @@ -0,0 +1,1177 @@ +/* =========================================================================
+ Unity Project - A Test Framework for C
+ Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
+ [Released under MIT License. Please refer to license.txt for details]
+============================================================================ */
+
+#include "unity.h"
+
+#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
+#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
+/// return prematurely if we are already in failure or ignore state
+#define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
+#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); }
+
+struct _Unity Unity;
+
+const char UnityStrOk[] = "OK";
+const char UnityStrPass[] = "PASS";
+const char UnityStrFail[] = "FAIL";
+const char UnityStrIgnore[] = "IGNORE";
+const char UnityStrNull[] = "NULL";
+const char UnityStrSpacer[] = ". ";
+const char UnityStrExpected[] = " Expected ";
+const char UnityStrWas[] = " Was ";
+const char UnityStrTo[] = " To ";
+const char UnityStrElement[] = " Element ";
+const char UnityStrByte[] = " Byte ";
+const char UnityStrMemory[] = " Memory Mismatch.";
+const char UnityStrDelta[] = " Values Not Within Delta ";
+const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
+const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
+const char UnityStrNullPointerForActual[] = " Actual pointer was NULL";
+const char UnityStrNot[] = "Not ";
+const char UnityStrInf[] = "Infinity";
+const char UnityStrNegInf[] = "Negative Infinity";
+const char UnityStrNaN[] = "NaN";
+const char UnityStrDet[] = "Determinate";
+const char UnityStrErrFloat[] = "Unity Floating Point Disabled";
+const char UnityStrErrDouble[] = "Unity Double Precision Disabled";
+const char UnityStrErr64[] = "Unity 64-bit Support Disabled";
+const char UnityStrBreaker[] = "-----------------------";
+const char UnityStrResultsTests[] = " Tests ";
+const char UnityStrResultsFailures[] = " Failures ";
+const char UnityStrResultsIgnored[] = " Ignored ";
+
+#ifndef UNITY_EXCLUDE_FLOAT
+// Dividing by these constants produces +/- infinity.
+// The rationale is given in UnityAssertFloatIsInf's body.
+static const _UF f_zero = 0.0f;
+#ifndef UNITY_EXCLUDE_DOUBLE
+static const _UD d_zero = 0.0;
+#endif
+#endif
+
+// compiler-generic print formatting masks
+const _U_UINT UnitySizeMask[] =
+{
+ 255u, // 0xFF
+ 65535u, // 0xFFFF
+ 65535u,
+ 4294967295u, // 0xFFFFFFFF
+ 4294967295u,
+ 4294967295u,
+ 4294967295u
+#ifdef UNITY_SUPPORT_64
+ ,0xFFFFFFFFFFFFFFFF
+#endif
+};
+
+void UnityPrintFail(void);
+void UnityPrintOk(void);
+
+//-----------------------------------------------
+// Pretty Printers & Test Result Output Handlers
+//-----------------------------------------------
+
+void UnityPrint(const char* string)
+{
+ const char* pch = string;
+
+ if (pch != NULL)
+ {
+ while (*pch)
+ {
+ // printable characters plus CR & LF are printed
+ if ((*pch <= 126) && (*pch >= 32))
+ {
+ UNITY_OUTPUT_CHAR(*pch);
+ }
+ //write escaped carriage returns
+ else if (*pch == 13)
+ {
+ UNITY_OUTPUT_CHAR('\\');
+ UNITY_OUTPUT_CHAR('r');
+ }
+ //write escaped line feeds
+ else if (*pch == 10)
+ {
+ UNITY_OUTPUT_CHAR('\\');
+ UNITY_OUTPUT_CHAR('n');
+ }
+ // unprintable characters are shown as codes
+ else
+ {
+ UNITY_OUTPUT_CHAR('\\');
+ UnityPrintNumberHex((_U_UINT)*pch, 2);
+ }
+ pch++;
+ }
+ }
+}
+
+//-----------------------------------------------
+void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
+{
+ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
+ {
+ UnityPrintNumber(number);
+ }
+ else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
+ {
+ UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
+ }
+ else
+ {
+ UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
+ }
+}
+
+//-----------------------------------------------
+/// basically do an itoa using as little ram as possible
+void UnityPrintNumber(const _U_SINT number_to_print)
+{
+ _U_SINT divisor = 1;
+ _U_SINT next_divisor;
+ _U_UINT number;
+
+ if (number_to_print == (1l << (UNITY_LONG_WIDTH-1)))
+ {
+ //The largest representable negative number
+ UNITY_OUTPUT_CHAR('-');
+ number = (1ul << (UNITY_LONG_WIDTH-1));
+ }
+ else if (number_to_print < 0)
+ {
+ //Some other negative number
+ UNITY_OUTPUT_CHAR('-');
+ number = (_U_UINT)(-number_to_print);
+ }
+ else
+ {
+ //Positive number
+ number = (_U_UINT)number_to_print;
+ }
+
+ // figure out initial divisor
+ while (number / divisor > 9)
+ {
+ next_divisor = divisor * 10;
+ if (next_divisor > divisor)
+ divisor = next_divisor;
+ else
+ break;
+ }
+
+ // now mod and print, then divide divisor
+ do
+ {
+ UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
+ divisor /= 10;
+ }
+ while (divisor > 0);
+}
+
+//-----------------------------------------------
+/// basically do an itoa using as little ram as possible
+void UnityPrintNumberUnsigned(const _U_UINT number)
+{
+ _U_UINT divisor = 1;
+ _U_UINT next_divisor;
+
+ // figure out initial divisor
+ while (number / divisor > 9)
+ {
+ next_divisor = divisor * 10;
+ if (next_divisor > divisor)
+ divisor = next_divisor;
+ else
+ break;
+ }
+
+ // now mod and print, then divide divisor
+ do
+ {
+ UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
+ divisor /= 10;
+ }
+ while (divisor > 0);
+}
+
+//-----------------------------------------------
+void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
+{
+ _U_UINT nibble;
+ char nibbles = nibbles_to_print;
+ UNITY_OUTPUT_CHAR('0');
+ UNITY_OUTPUT_CHAR('x');
+
+ while (nibbles > 0)
+ {
+ nibble = (number >> (--nibbles << 2)) & 0x0000000F;
+ if (nibble <= 9)
+ {
+ UNITY_OUTPUT_CHAR((char)('0' + nibble));
+ }
+ else
+ {
+ UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
+ }
+ }
+}
+
+//-----------------------------------------------
+void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
+{
+ _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
+ _US32 i;
+
+ for (i = 0; i < UNITY_INT_WIDTH; i++)
+ {
+ if (current_bit & mask)
+ {
+ if (current_bit & number)
+ {
+ UNITY_OUTPUT_CHAR('1');
+ }
+ else
+ {
+ UNITY_OUTPUT_CHAR('0');
+ }
+ }
+ else
+ {
+ UNITY_OUTPUT_CHAR('X');
+ }
+ current_bit = current_bit >> 1;
+ }
+}
+
+//-----------------------------------------------
+#ifdef UNITY_FLOAT_VERBOSE
+#include <string.h>
+void UnityPrintFloat(_UF number)
+{
+ char TempBuffer[32];
+ sprintf(TempBuffer, "%.6f", number);
+ UnityPrint(TempBuffer);
+}
+#endif
+
+//-----------------------------------------------
+
+void UnityPrintFail(void)
+{
+ UnityPrint(UnityStrFail);
+}
+
+void UnityPrintOk(void)
+{
+ UnityPrint(UnityStrOk);
+}
+
+//-----------------------------------------------
+static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
+{
+ UnityPrint(file);
+ UNITY_OUTPUT_CHAR(':');
+ UnityPrintNumber((_U_SINT)line);
+ UNITY_OUTPUT_CHAR(':');
+ UnityPrint(Unity.CurrentTestName);
+ UNITY_OUTPUT_CHAR(':');
+}
+
+//-----------------------------------------------
+static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
+{
+ UnityTestResultsBegin(Unity.TestFile, line);
+ UnityPrint(UnityStrFail);
+ UNITY_OUTPUT_CHAR(':');
+}
+
+//-----------------------------------------------
+void UnityConcludeTest(void)
+{
+ if (Unity.CurrentTestIgnored)
+ {
+ Unity.TestIgnores++;
+ }
+ else if (!Unity.CurrentTestFailed)
+ {
+ UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
+ UnityPrint(UnityStrPass);
+ }
+ else
+ {
+ Unity.TestFailures++;
+ }
+
+ Unity.CurrentTestFailed = 0;
+ Unity.CurrentTestIgnored = 0;
+ UNITY_PRINT_EOL;
+}
+
+//-----------------------------------------------
+static void UnityAddMsgIfSpecified(const char* msg)
+{
+ if (msg)
+ {
+ UnityPrint(UnityStrSpacer);
+ UnityPrint(msg);
+ }
+}
+
+//-----------------------------------------------
+static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
+{
+ UnityPrint(UnityStrExpected);
+ if (expected != NULL)
+ {
+ UNITY_OUTPUT_CHAR('\'');
+ UnityPrint(expected);
+ UNITY_OUTPUT_CHAR('\'');
+ }
+ else
+ {
+ UnityPrint(UnityStrNull);
+ }
+ UnityPrint(UnityStrWas);
+ if (actual != NULL)
+ {
+ UNITY_OUTPUT_CHAR('\'');
+ UnityPrint(actual);
+ UNITY_OUTPUT_CHAR('\'');
+ }
+ else
+ {
+ UnityPrint(UnityStrNull);
+ }
+}
+
+//-----------------------------------------------
+// Assertion & Control Helpers
+//-----------------------------------------------
+
+static int UnityCheckArraysForNull(UNITY_PTR_ATTRIBUTE const void* expected, UNITY_PTR_ATTRIBUTE const void* actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
+{
+ //return true if they are both NULL
+ if ((expected == NULL) && (actual == NULL))
+ return 1;
+
+ //throw error if just expected is NULL
+ if (expected == NULL)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrNullPointerForExpected);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ //throw error if just actual is NULL
+ if (actual == NULL)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrNullPointerForActual);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ //return false if neither is NULL
+ return 0;
+}
+
+//-----------------------------------------------
+// Assertion Functions
+//-----------------------------------------------
+
+void UnityAssertBits(const _U_SINT mask,
+ const _U_SINT expected,
+ const _U_SINT actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ UNITY_SKIP_EXECUTION;
+
+ if ((mask & expected) != (mask & actual))
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrExpected);
+ UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
+ UnityPrint(UnityStrWas);
+ UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertEqualNumber(const _U_SINT expected,
+ const _U_SINT actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_DISPLAY_STYLE_T style)
+{
+ UNITY_SKIP_EXECUTION;
+
+ if (expected != actual)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(expected, style);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(actual, style);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected,
+ UNITY_PTR_ATTRIBUTE const void* actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_DISPLAY_STYLE_T style)
+{
+ _UU32 elements = num_elements;
+ UNITY_PTR_ATTRIBUTE const _US8* ptr_exp = (UNITY_PTR_ATTRIBUTE const _US8*)expected;
+ UNITY_PTR_ATTRIBUTE const _US8* ptr_act = (UNITY_PTR_ATTRIBUTE const _US8*)actual;
+
+ UNITY_SKIP_EXECUTION;
+
+ if (elements == 0)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrPointless);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE const void*)expected, (UNITY_PTR_ATTRIBUTE const void*)actual, lineNumber, msg) == 1)
+ return;
+
+ // If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
+ // as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
+ // variants do not. Therefore remove this flag.
+ switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
+ {
+ case UNITY_DISPLAY_STYLE_HEX8:
+ case UNITY_DISPLAY_STYLE_INT8:
+ case UNITY_DISPLAY_STYLE_UINT8:
+ while (elements--)
+ {
+ if (*ptr_exp != *ptr_act)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(*ptr_exp, style);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(*ptr_act, style);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_exp += 1;
+ ptr_act += 1;
+ }
+ break;
+ case UNITY_DISPLAY_STYLE_HEX16:
+ case UNITY_DISPLAY_STYLE_INT16:
+ case UNITY_DISPLAY_STYLE_UINT16:
+ while (elements--)
+ {
+ if (*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_exp, style);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US16*)ptr_act, style);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_exp += 2;
+ ptr_act += 2;
+ }
+ break;
+#ifdef UNITY_SUPPORT_64
+ case UNITY_DISPLAY_STYLE_HEX64:
+ case UNITY_DISPLAY_STYLE_INT64:
+ case UNITY_DISPLAY_STYLE_UINT64:
+ while (elements--)
+ {
+ if (*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_exp, style);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US64*)ptr_act, style);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_exp += 8;
+ ptr_act += 8;
+ }
+ break;
+#endif
+ default:
+ while (elements--)
+ {
+ if (*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp != *(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_exp, style);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(*(UNITY_PTR_ATTRIBUTE const _US32*)ptr_act, style);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_exp += 4;
+ ptr_act += 4;
+ }
+ break;
+ }
+}
+
+//-----------------------------------------------
+#ifndef UNITY_EXCLUDE_FLOAT
+void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
+ UNITY_PTR_ATTRIBUTE const _UF* actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ _UU32 elements = num_elements;
+ UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
+ UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
+ _UF diff, tol;
+
+ UNITY_SKIP_EXECUTION;
+
+ if (elements == 0)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrPointless);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE const void*)expected, (UNITY_PTR_ATTRIBUTE const void*)actual, lineNumber, msg) == 1)
+ return;
+
+ while (elements--)
+ {
+ diff = *ptr_expected - *ptr_actual;
+ if (diff < 0.0f)
+ diff = 0.0f - diff;
+ tol = UNITY_FLOAT_PRECISION * *ptr_expected;
+ if (tol < 0.0f)
+ tol = 0.0f - tol;
+
+ //This first part of this condition will catch any NaN or Infinite values
+ if ((diff * 0.0f != 0.0f) || (diff > tol))
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+#ifdef UNITY_FLOAT_VERBOSE
+ UnityPrint(UnityStrExpected);
+ UnityPrintFloat(*ptr_expected);
+ UnityPrint(UnityStrWas);
+ UnityPrintFloat(*ptr_actual);
+#else
+ UnityPrint(UnityStrDelta);
+#endif
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_expected++;
+ ptr_actual++;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertFloatsWithin(const _UF delta,
+ const _UF expected,
+ const _UF actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ _UF diff = actual - expected;
+ _UF pos_delta = delta;
+
+ UNITY_SKIP_EXECUTION;
+
+ if (diff < 0.0f)
+ {
+ diff = 0.0f - diff;
+ }
+ if (pos_delta < 0.0f)
+ {
+ pos_delta = 0.0f - pos_delta;
+ }
+
+ //This first part of this condition will catch any NaN or Infinite values
+ if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
+ {
+ UnityTestResultsFailBegin(lineNumber);
+#ifdef UNITY_FLOAT_VERBOSE
+ UnityPrint(UnityStrExpected);
+ UnityPrintFloat(expected);
+ UnityPrint(UnityStrWas);
+ UnityPrintFloat(actual);
+#else
+ UnityPrint(UnityStrDelta);
+#endif
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertFloatSpecial(const _UF actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_FLOAT_TRAIT_T style)
+{
+ const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
+ _U_SINT should_be_trait = ((_U_SINT)style & 1);
+ _U_SINT is_trait = !should_be_trait;
+ _U_SINT trait_index = style >> 1;
+
+ UNITY_SKIP_EXECUTION;
+
+ switch(style)
+ {
+ //To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
+ //We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
+ case UNITY_FLOAT_IS_INF:
+ case UNITY_FLOAT_IS_NOT_INF:
+ is_trait = ((1.0f / f_zero) == actual) ? 1 : 0;
+ break;
+ case UNITY_FLOAT_IS_NEG_INF:
+ case UNITY_FLOAT_IS_NOT_NEG_INF:
+ is_trait = ((-1.0f / f_zero) == actual) ? 1 : 0;
+ break;
+
+ //NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
+ case UNITY_FLOAT_IS_NAN:
+ case UNITY_FLOAT_IS_NOT_NAN:
+ is_trait = (actual == actual) ? 0 : 1;
+ break;
+
+ //A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
+ case UNITY_FLOAT_IS_DET:
+ case UNITY_FLOAT_IS_NOT_DET:
+ if ( (actual != actual) || ((1.0f / f_zero) == actual) || ((-1.0f / f_zero) == actual) )
+ is_trait = 0;
+ else
+ is_trait = 1;
+ break;
+ default:
+ ;
+ }
+
+ if (is_trait != should_be_trait)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrExpected);
+ if (!should_be_trait)
+ UnityPrint(UnityStrNot);
+ UnityPrint(trait_names[trait_index]);
+ UnityPrint(UnityStrWas);
+#ifdef UNITY_FLOAT_VERBOSE
+ UnityPrintFloat(actual);
+#else
+ if (should_be_trait)
+ UnityPrint(UnityStrNot);
+ UnityPrint(trait_names[trait_index]);
+#endif
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+#endif //not UNITY_EXCLUDE_FLOAT
+
+//-----------------------------------------------
+#ifndef UNITY_EXCLUDE_DOUBLE
+void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
+ UNITY_PTR_ATTRIBUTE const _UD* actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ _UU32 elements = num_elements;
+ UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
+ UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
+ _UD diff, tol;
+
+ UNITY_SKIP_EXECUTION;
+
+ if (elements == 0)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrPointless);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
+ return;
+
+ while (elements--)
+ {
+ diff = *ptr_expected - *ptr_actual;
+ if (diff < 0.0)
+ diff = 0.0 - diff;
+ tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
+ if (tol < 0.0)
+ tol = 0.0 - tol;
+
+ //This first part of this condition will catch any NaN or Infinite values
+ if ((diff * 0.0 != 0.0) || (diff > tol))
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+#ifdef UNITY_DOUBLE_VERBOSE
+ UnityPrint(UnityStrExpected);
+ UnityPrintFloat((float)(*ptr_expected));
+ UnityPrint(UnityStrWas);
+ UnityPrintFloat((float)(*ptr_actual));
+#else
+ UnityPrint(UnityStrDelta);
+#endif
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_expected++;
+ ptr_actual++;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertDoublesWithin(const _UD delta,
+ const _UD expected,
+ const _UD actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ _UD diff = actual - expected;
+ _UD pos_delta = delta;
+
+ UNITY_SKIP_EXECUTION;
+
+ if (diff < 0.0)
+ {
+ diff = 0.0 - diff;
+ }
+ if (pos_delta < 0.0)
+ {
+ pos_delta = 0.0 - pos_delta;
+ }
+
+ //This first part of this condition will catch any NaN or Infinite values
+ if ((diff * 0.0 != 0.0) || (pos_delta < diff))
+ {
+ UnityTestResultsFailBegin(lineNumber);
+#ifdef UNITY_DOUBLE_VERBOSE
+ UnityPrint(UnityStrExpected);
+ UnityPrintFloat((float)expected);
+ UnityPrint(UnityStrWas);
+ UnityPrintFloat((float)actual);
+#else
+ UnityPrint(UnityStrDelta);
+#endif
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+//-----------------------------------------------
+
+void UnityAssertDoubleSpecial(const _UD actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_FLOAT_TRAIT_T style)
+{
+ const char* trait_names[] = { UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet };
+ _U_SINT should_be_trait = ((_U_SINT)style & 1);
+ _U_SINT is_trait = !should_be_trait;
+ _U_SINT trait_index = style >> 1;
+
+ UNITY_SKIP_EXECUTION;
+
+ switch(style)
+ {
+ //To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
+ //We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise
+ case UNITY_FLOAT_IS_INF:
+ case UNITY_FLOAT_IS_NOT_INF:
+ is_trait = ((1.0 / d_zero) == actual) ? 1 : 0;
+ break;
+ case UNITY_FLOAT_IS_NEG_INF:
+ case UNITY_FLOAT_IS_NOT_NEG_INF:
+ is_trait = ((-1.0 / d_zero) == actual) ? 1 : 0;
+ break;
+
+ //NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN.
+ case UNITY_FLOAT_IS_NAN:
+ case UNITY_FLOAT_IS_NOT_NAN:
+ is_trait = (actual == actual) ? 0 : 1;
+ break;
+
+ //A determinate number is non infinite and not NaN. (therefore the opposite of the two above)
+ case UNITY_FLOAT_IS_DET:
+ case UNITY_FLOAT_IS_NOT_DET:
+ if ( (actual != actual) || ((1.0 / d_zero) == actual) || ((-1.0 / d_zero) == actual) )
+ is_trait = 0;
+ else
+ is_trait = 1;
+ break;
+ default:
+ ;
+ }
+
+ if (is_trait != should_be_trait)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrExpected);
+ if (!should_be_trait)
+ UnityPrint(UnityStrNot);
+ UnityPrint(trait_names[trait_index]);
+ UnityPrint(UnityStrWas);
+#ifdef UNITY_DOUBLE_VERBOSE
+ UnityPrintFloat(actual);
+#else
+ if (should_be_trait)
+ UnityPrint(UnityStrNot);
+ UnityPrint(trait_names[trait_index]);
+#endif
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+
+#endif // not UNITY_EXCLUDE_DOUBLE
+
+//-----------------------------------------------
+void UnityAssertNumbersWithin( const _U_SINT delta,
+ const _U_SINT expected,
+ const _U_SINT actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_DISPLAY_STYLE_T style)
+{
+ UNITY_SKIP_EXECUTION;
+
+ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
+ {
+ if (actual > expected)
+ Unity.CurrentTestFailed = ((actual - expected) > delta);
+ else
+ Unity.CurrentTestFailed = ((expected - actual) > delta);
+ }
+ else
+ {
+ if ((_U_UINT)actual > (_U_UINT)expected)
+ Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > (_U_UINT)delta);
+ else
+ Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > (_U_UINT)delta);
+ }
+
+ if (Unity.CurrentTestFailed)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrDelta);
+ UnityPrintNumberByStyle(delta, style);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(expected, style);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(actual, style);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertEqualString(const char* expected,
+ const char* actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ _UU32 i;
+
+ UNITY_SKIP_EXECUTION;
+
+ // if both pointers not null compare the strings
+ if (expected && actual)
+ {
+ for (i = 0; expected[i] || actual[i]; i++)
+ {
+ if (expected[i] != actual[i])
+ {
+ Unity.CurrentTestFailed = 1;
+ break;
+ }
+ }
+ }
+ else
+ { // handle case of one pointers being null (if both null, test should pass)
+ if (expected != actual)
+ {
+ Unity.CurrentTestFailed = 1;
+ }
+ }
+
+ if (Unity.CurrentTestFailed)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrintExpectedAndActualStrings(expected, actual);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+}
+
+//-----------------------------------------------
+void UnityAssertEqualStringArray( const char** expected,
+ const char** actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ _UU32 i, j = 0;
+
+ UNITY_SKIP_EXECUTION;
+
+ // if no elements, it's an error
+ if (num_elements == 0)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrPointless);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE void*)expected, (UNITY_PTR_ATTRIBUTE void*)actual, lineNumber, msg) == 1)
+ return;
+
+ do
+ {
+ // if both pointers not null compare the strings
+ if (expected[j] && actual[j])
+ {
+ for (i = 0; expected[j][i] || actual[j][i]; i++)
+ {
+ if (expected[j][i] != actual[j][i])
+ {
+ Unity.CurrentTestFailed = 1;
+ break;
+ }
+ }
+ }
+ else
+ { // handle case of one pointers being null (if both null, test should pass)
+ if (expected[j] != actual[j])
+ {
+ Unity.CurrentTestFailed = 1;
+ }
+ }
+
+ if (Unity.CurrentTestFailed)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ if (num_elements > 1)
+ {
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((j), UNITY_DISPLAY_STYLE_UINT);
+ }
+ UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ } while (++j < num_elements);
+}
+
+//-----------------------------------------------
+void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected,
+ UNITY_PTR_ATTRIBUTE const void* actual,
+ const _UU32 length,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber)
+{
+ UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected;
+ UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual;
+ _UU32 elements = num_elements;
+ _UU32 bytes;
+
+ UNITY_SKIP_EXECUTION;
+
+ if ((elements == 0) || (length == 0))
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrPointless);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+
+ if (UnityCheckArraysForNull((UNITY_PTR_ATTRIBUTE const void*)expected, (UNITY_PTR_ATTRIBUTE const void*)actual, lineNumber, msg) == 1)
+ return;
+
+ while (elements--)
+ {
+ /////////////////////////////////////
+ bytes = length;
+ while (bytes--)
+ {
+ if (*ptr_exp != *ptr_act)
+ {
+ UnityTestResultsFailBegin(lineNumber);
+ UnityPrint(UnityStrMemory);
+ if (num_elements > 1)
+ {
+ UnityPrint(UnityStrElement);
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
+ }
+ UnityPrint(UnityStrByte);
+ UnityPrintNumberByStyle((length - bytes - 1), UNITY_DISPLAY_STYLE_UINT);
+ UnityPrint(UnityStrExpected);
+ UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
+ UnityPrint(UnityStrWas);
+ UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
+ UnityAddMsgIfSpecified(msg);
+ UNITY_FAIL_AND_BAIL;
+ }
+ ptr_exp += 1;
+ ptr_act += 1;
+ }
+ /////////////////////////////////////
+
+ }
+}
+
+//-----------------------------------------------
+// Control Functions
+//-----------------------------------------------
+
+void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
+{
+ UNITY_SKIP_EXECUTION;
+
+ UnityTestResultsBegin(Unity.TestFile, line);
+ UnityPrintFail();
+ if (msg != NULL)
+ {
+ UNITY_OUTPUT_CHAR(':');
+ if (msg[0] != ' ')
+ {
+ UNITY_OUTPUT_CHAR(' ');
+ }
+ UnityPrint(msg);
+ }
+ UNITY_FAIL_AND_BAIL;
+}
+
+//-----------------------------------------------
+void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
+{
+ UNITY_SKIP_EXECUTION;
+
+ UnityTestResultsBegin(Unity.TestFile, line);
+ UnityPrint(UnityStrIgnore);
+ if (msg != NULL)
+ {
+ UNITY_OUTPUT_CHAR(':');
+ UNITY_OUTPUT_CHAR(' ');
+ UnityPrint(msg);
+ }
+ UNITY_IGNORE_AND_BAIL;
+}
+
+//-----------------------------------------------
+#if defined(UNITY_WEAK_ATTRIBUTE)
+ void setUp(void);
+ void tearDown(void);
+ UNITY_WEAK_ATTRIBUTE void setUp(void) { }
+ UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
+#elif defined(UNITY_WEAK_PRAGMA)
+# pragma weak setUp
+ void setUp(void);
+# pragma weak tearDown
+ void tearDown(void);
+#else
+ void setUp(void);
+ void tearDown(void);
+#endif
+//-----------------------------------------------
+void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
+{
+ Unity.CurrentTestName = FuncName;
+ Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
+ Unity.NumberOfTests++;
+ if (TEST_PROTECT())
+ {
+ setUp();
+ Func();
+ }
+ if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
+ {
+ tearDown();
+ }
+ UnityConcludeTest();
+}
+
+//-----------------------------------------------
+void UnityBegin(const char* filename)
+{
+ Unity.TestFile = filename;
+ Unity.CurrentTestName = NULL;
+ Unity.CurrentTestLineNumber = 0;
+ Unity.NumberOfTests = 0;
+ Unity.TestFailures = 0;
+ Unity.TestIgnores = 0;
+ Unity.CurrentTestFailed = 0;
+ Unity.CurrentTestIgnored = 0;
+
+ UNITY_OUTPUT_START();
+}
+
+//-----------------------------------------------
+int UnityEnd(void)
+{
+ UNITY_PRINT_EOL;
+ UnityPrint(UnityStrBreaker);
+ UNITY_PRINT_EOL;
+ UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
+ UnityPrint(UnityStrResultsTests);
+ UnityPrintNumber((_U_SINT)(Unity.TestFailures));
+ UnityPrint(UnityStrResultsFailures);
+ UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
+ UnityPrint(UnityStrResultsIgnored);
+ UNITY_PRINT_EOL;
+ if (Unity.TestFailures == 0U)
+ {
+ UnityPrintOk();
+ }
+ else
+ {
+ UnityPrintFail();
+ }
+ UNITY_PRINT_EOL;
+ UNITY_OUTPUT_COMPLETE();
+ return (int)(Unity.TestFailures);
+}
+
+//-----------------------------------------------
diff --git a/lab_6/unity/src/unity.h b/lab_6/unity/src/unity.h new file mode 100644 index 0000000..80e6126 --- /dev/null +++ b/lab_6/unity/src/unity.h @@ -0,0 +1,272 @@ +/* ==========================================
+ Unity Project - A Test Framework for C
+ Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
+ [Released under MIT License. Please refer to license.txt for details]
+========================================== */
+
+#ifndef UNITY_FRAMEWORK_H
+#define UNITY_FRAMEWORK_H
+#define UNITY
+
+#include "unity_internals.h"
+
+//-------------------------------------------------------
+// Configuration Options
+//-------------------------------------------------------
+// All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above.
+
+// Integers/longs/pointers
+// - Unity attempts to automatically discover your integer sizes
+// - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h>
+// - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h>
+// - define UNITY_EXCLUDE_SIZEOF to stop attempting to use sizeof in macros
+// - If you cannot use the automatic methods above, you can force Unity by using these options:
+// - define UNITY_SUPPORT_64
+// - define UNITY_INT_WIDTH
+// - UNITY_LONG_WIDTH
+// - UNITY_POINTER_WIDTH
+
+// Floats
+// - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons
+// - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT
+// - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats
+// - define UNITY_FLOAT_VERBOSE to print floating point values in errors (uses sprintf)
+// - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons
+// - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default)
+// - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE
+// - define UNITY_DOUBLE_TYPE to specify something other than double
+// - define UNITY_DOUBLE_VERBOSE to print floating point values in errors (uses sprintf)
+
+// Output
+// - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired
+
+// Optimization
+// - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge
+// - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests.
+
+// Test Cases
+// - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script
+
+// Parameterized Tests
+// - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing
+
+//-------------------------------------------------------
+// Basic Fail and Ignore
+//-------------------------------------------------------
+
+#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, message)
+#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL)
+#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, message)
+#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL)
+#define TEST_ONLY()
+
+//-------------------------------------------------------
+// Test Asserts (simple)
+//-------------------------------------------------------
+
+//Boolean
+#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE")
+#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE")
+#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE")
+#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE")
+#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL")
+#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL")
+
+//Integers (of all sizes)
+#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
+#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(-1), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(0), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(-1), (actual), __LINE__, NULL)
+#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(0), (actual), __LINE__, NULL)
+
+//Integer Ranges (of all sizes)
+#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, __LINE__, NULL)
+
+//Structs and Strings
+#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, __LINE__, NULL)
+
+//Arrays
+#define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, __LINE__, NULL)
+
+//Floating Point (If Enabled)
+#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, __LINE__, NULL)
+#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, __LINE__, NULL)
+
+//Double (If Enabled)
+#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, __LINE__, NULL)
+#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, __LINE__, NULL)
+#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, __LINE__, NULL)
+
+//-------------------------------------------------------
+// Test Asserts (with additional messages)
+//-------------------------------------------------------
+
+//Boolean
+#define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, message)
+#define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, message)
+#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, message)
+#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, message)
+#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, message)
+#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, message)
+
+//Integers (of all sizes)
+#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, message)
+#define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, message)
+#define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(-1), (actual), __LINE__, message)
+#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(0), (actual), __LINE__, message)
+#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(-1), (actual), __LINE__, message)
+#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(0), (actual), __LINE__, message)
+
+//Integer Ranges (of all sizes)
+#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, __LINE__, message)
+
+//Structs and Strings
+#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, __LINE__, message)
+#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, __LINE__, message)
+#define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, __LINE__, message)
+
+//Arrays
+#define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, __LINE__, message)
+
+//Floating Point (If Enabled)
+#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, __LINE__, message)
+#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, __LINE__, message)
+#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, __LINE__, message)
+
+//Double (If Enabled)
+#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, message)
+#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, __LINE__, message)
+#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, __LINE__, message)
+#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, __LINE__, message)
+
+//end of UNITY_FRAMEWORK_H
+#endif
diff --git a/lab_6/unity/src/unity_internals.h b/lab_6/unity/src/unity_internals.h new file mode 100644 index 0000000..1552915 --- /dev/null +++ b/lab_6/unity/src/unity_internals.h @@ -0,0 +1,692 @@ +/* ==========================================
+ Unity Project - A Test Framework for C
+ Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
+ [Released under MIT License. Please refer to license.txt for details]
+========================================== */
+
+#ifndef UNITY_INTERNALS_H
+#define UNITY_INTERNALS_H
+
+#ifdef UNITY_INCLUDE_CONFIG_H
+#include "unity_config.h"
+#endif
+
+#include <setjmp.h>
+
+// Unity Attempts to Auto-Detect Integer Types
+// Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h>
+// Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h>
+// Attempt 3: Deduced from sizeof() macros
+#ifndef UNITY_EXCLUDE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifndef UNITY_EXCLUDE_LIMITS_H
+#include <limits.h>
+#endif
+
+#ifndef UNITY_EXCLUDE_SIZEOF
+#ifndef UINT_MAX
+#define UINT_MAX (sizeof(unsigned int) * 256 - 1)
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX (sizeof(unsigned long) * 256 - 1)
+#endif
+#ifndef UINTPTR_MAX
+//apparently this is not a constant expression: (sizeof(unsigned int *) * 256 - 1) so we have to just let this fall through
+#endif
+#endif
+//-------------------------------------------------------
+// Guess Widths If Not Specified
+//-------------------------------------------------------
+
+// Determine the size of an int, if not already specificied.
+// We cannot use sizeof(int), because it is not yet defined
+// at this stage in the trnslation of the C program.
+// Therefore, infer it from UINT_MAX if possible.
+#ifndef UNITY_INT_WIDTH
+ #ifdef UINT_MAX
+ #if (UINT_MAX == 0xFFFF)
+ #define UNITY_INT_WIDTH (16)
+ #elif (UINT_MAX == 0xFFFFFFFF)
+ #define UNITY_INT_WIDTH (32)
+ #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF)
+ #define UNITY_INT_WIDTH (64)
+ #endif
+ #endif
+#endif
+#ifndef UNITY_INT_WIDTH
+ #define UNITY_INT_WIDTH (32)
+#endif
+
+// Determine the size of a long, if not already specified,
+// by following the process used above to define
+// UNITY_INT_WIDTH.
+#ifndef UNITY_LONG_WIDTH
+ #ifdef ULONG_MAX
+ #if (ULONG_MAX == 0xFFFF)
+ #define UNITY_LONG_WIDTH (16)
+ #elif (ULONG_MAX == 0xFFFFFFFF)
+ #define UNITY_LONG_WIDTH (32)
+ #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF)
+ #define UNITY_LONG_WIDTH (64)
+ #endif
+ #endif
+#endif
+#ifndef UNITY_LONG_WIDTH
+ #define UNITY_LONG_WIDTH (32)
+#endif
+
+// Determine the size of a pointer, if not already specified,
+// by following the process used above to define
+// UNITY_INT_WIDTH.
+#ifndef UNITY_POINTER_WIDTH
+ #ifdef UINTPTR_MAX
+ #if (UINTPTR_MAX <= 0xFFFF)
+ #define UNITY_POINTER_WIDTH (16)
+ #elif (UINTPTR_MAX <= 0xFFFFFFFF)
+ #define UNITY_POINTER_WIDTH (32)
+ #elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF)
+ #define UNITY_POINTER_WIDTH (64)
+ #endif
+ #endif
+#endif
+#ifndef UNITY_POINTER_WIDTH
+ #ifdef INTPTR_MAX
+ #if (INTPTR_MAX <= 0x7FFF)
+ #define UNITY_POINTER_WIDTH (16)
+ #elif (INTPTR_MAX <= 0x7FFFFFFF)
+ #define UNITY_POINTER_WIDTH (32)
+ #elif (INTPTR_MAX <= 0x7FFFFFFFFFFFFFFF)
+ #define UNITY_POINTER_WIDTH (64)
+ #endif
+ #endif
+#endif
+#ifndef UNITY_POINTER_WIDTH
+ #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH
+#endif
+
+//-------------------------------------------------------
+// Int Support (Define types based on detected sizes)
+//-------------------------------------------------------
+
+#if (UNITY_INT_WIDTH == 32)
+ typedef unsigned char _UU8;
+ typedef unsigned short _UU16;
+ typedef unsigned int _UU32;
+ typedef signed char _US8;
+ typedef signed short _US16;
+ typedef signed int _US32;
+#elif (UNITY_INT_WIDTH == 16)
+ typedef unsigned char _UU8;
+ typedef unsigned int _UU16;
+ typedef unsigned long _UU32;
+ typedef signed char _US8;
+ typedef signed int _US16;
+ typedef signed long _US32;
+#else
+ #error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported)
+#endif
+
+//-------------------------------------------------------
+// 64-bit Support
+//-------------------------------------------------------
+
+#ifndef UNITY_SUPPORT_64
+#if UNITY_LONG_WIDTH > 32
+#define UNITY_SUPPORT_64
+#endif
+#endif
+#ifndef UNITY_SUPPORT_64
+#if UNITY_POINTER_WIDTH > 32
+#define UNITY_SUPPORT_64
+#endif
+#endif
+
+#ifndef UNITY_SUPPORT_64
+
+//No 64-bit Support
+typedef _UU32 _U_UINT;
+typedef _US32 _U_SINT;
+
+#else
+
+//64-bit Support
+#if (UNITY_LONG_WIDTH == 32)
+ typedef unsigned long long _UU64;
+ typedef signed long long _US64;
+#elif (UNITY_LONG_WIDTH == 64)
+ typedef unsigned long _UU64;
+ typedef signed long _US64;
+#else
+ #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported)
+#endif
+typedef _UU64 _U_UINT;
+typedef _US64 _U_SINT;
+
+#endif
+
+//-------------------------------------------------------
+// Pointer Support
+//-------------------------------------------------------
+
+#if (UNITY_POINTER_WIDTH == 32)
+ typedef _UU32 _UP;
+#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32
+#elif (UNITY_POINTER_WIDTH == 64)
+ typedef _UU64 _UP;
+#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64
+#elif (UNITY_POINTER_WIDTH == 16)
+ typedef _UU16 _UP;
+#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16
+#else
+ #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported)
+#endif
+
+#ifndef UNITY_PTR_ATTRIBUTE
+ #define UNITY_PTR_ATTRIBUTE
+#endif
+
+//-------------------------------------------------------
+// Float Support
+//-------------------------------------------------------
+
+#ifdef UNITY_EXCLUDE_FLOAT
+
+//No Floating Point Support
+#undef UNITY_INCLUDE_FLOAT
+#undef UNITY_FLOAT_PRECISION
+#undef UNITY_FLOAT_TYPE
+#undef UNITY_FLOAT_VERBOSE
+
+#else
+
+#ifndef UNITY_INCLUDE_FLOAT
+#define UNITY_INCLUDE_FLOAT
+#endif
+
+//Floating Point Support
+#ifndef UNITY_FLOAT_PRECISION
+#define UNITY_FLOAT_PRECISION (0.00001f)
+#endif
+#ifndef UNITY_FLOAT_TYPE
+#define UNITY_FLOAT_TYPE float
+#endif
+typedef UNITY_FLOAT_TYPE _UF;
+
+#endif
+
+//-------------------------------------------------------
+// Double Float Support
+//-------------------------------------------------------
+
+//unlike FLOAT, we DON'T include by default
+#ifndef UNITY_EXCLUDE_DOUBLE
+#ifndef UNITY_INCLUDE_DOUBLE
+#define UNITY_EXCLUDE_DOUBLE
+#endif
+#endif
+
+#ifdef UNITY_EXCLUDE_DOUBLE
+
+//No Floating Point Support
+#undef UNITY_DOUBLE_PRECISION
+#undef UNITY_DOUBLE_TYPE
+#undef UNITY_DOUBLE_VERBOSE
+
+#ifdef UNITY_INCLUDE_DOUBLE
+#undef UNITY_INCLUDE_DOUBLE
+#endif
+
+#else
+
+//Double Floating Point Support
+#ifndef UNITY_DOUBLE_PRECISION
+#define UNITY_DOUBLE_PRECISION (1e-12f)
+#endif
+#ifndef UNITY_DOUBLE_TYPE
+#define UNITY_DOUBLE_TYPE double
+#endif
+typedef UNITY_DOUBLE_TYPE _UD;
+
+#endif
+
+#ifdef UNITY_DOUBLE_VERBOSE
+#ifndef UNITY_FLOAT_VERBOSE
+#define UNITY_FLOAT_VERBOSE
+#endif
+#endif
+
+//-------------------------------------------------------
+// Output Method: stdout (DEFAULT)
+//-------------------------------------------------------
+#ifndef UNITY_OUTPUT_CHAR
+//Default to using putchar, which is defined in stdio.h
+#include <stdio.h>
+#define UNITY_OUTPUT_CHAR(a) putchar(a)
+#else
+//If defined as something else, make sure we declare it here so it's ready for use
+extern int UNITY_OUTPUT_CHAR(int);
+#endif
+
+#ifndef UNITY_OUTPUT_START
+#define UNITY_OUTPUT_START()
+#endif
+
+#ifndef UNITY_OUTPUT_COMPLETE
+#define UNITY_OUTPUT_COMPLETE()
+#endif
+
+//-------------------------------------------------------
+// Footprint
+//-------------------------------------------------------
+
+#ifndef UNITY_LINE_TYPE
+#define UNITY_LINE_TYPE _U_UINT
+#endif
+
+#ifndef UNITY_COUNTER_TYPE
+#define UNITY_COUNTER_TYPE _U_UINT
+#endif
+
+//-------------------------------------------------------
+// Language Features Available
+//-------------------------------------------------------
+#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA)
+# ifdef __GNUC__ // includes clang
+# if !(defined(__WIN32__) && defined(__clang__))
+# define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
+# endif
+# endif
+#endif
+
+#ifdef UNITY_NO_WEAK
+# undef UNITY_WEAK_ATTRIBUTE
+# undef UNITY_WEAK_PRAGMA
+#endif
+
+
+//-------------------------------------------------------
+// Internal Structs Needed
+//-------------------------------------------------------
+
+typedef void (*UnityTestFunction)(void);
+
+#define UNITY_DISPLAY_RANGE_INT (0x10)
+#define UNITY_DISPLAY_RANGE_UINT (0x20)
+#define UNITY_DISPLAY_RANGE_HEX (0x40)
+#define UNITY_DISPLAY_RANGE_AUTO (0x80)
+
+typedef enum
+{
+#if (UNITY_INT_WIDTH == 16)
+ UNITY_DISPLAY_STYLE_INT = 2 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
+#elif (UNITY_INT_WIDTH == 32)
+ UNITY_DISPLAY_STYLE_INT = 4 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
+#elif (UNITY_INT_WIDTH == 64)
+ UNITY_DISPLAY_STYLE_INT = 8 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
+#endif
+ UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT,
+ UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT,
+ UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT,
+#ifdef UNITY_SUPPORT_64
+ UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT,
+#endif
+
+#if (UNITY_INT_WIDTH == 16)
+ UNITY_DISPLAY_STYLE_UINT = 2 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
+#elif (UNITY_INT_WIDTH == 32)
+ UNITY_DISPLAY_STYLE_UINT = 4 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
+#elif (UNITY_INT_WIDTH == 64)
+ UNITY_DISPLAY_STYLE_UINT = 8 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
+#endif
+ UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT,
+ UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT,
+ UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT,
+#ifdef UNITY_SUPPORT_64
+ UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT,
+#endif
+ UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX,
+ UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX,
+ UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX,
+#ifdef UNITY_SUPPORT_64
+ UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX,
+#endif
+ UNITY_DISPLAY_STYLE_UNKNOWN
+} UNITY_DISPLAY_STYLE_T;
+
+#ifndef UNITY_EXCLUDE_FLOAT
+typedef enum _UNITY_FLOAT_TRAIT_T
+{
+ UNITY_FLOAT_IS_NOT_INF = 0,
+ UNITY_FLOAT_IS_INF,
+ UNITY_FLOAT_IS_NOT_NEG_INF,
+ UNITY_FLOAT_IS_NEG_INF,
+ UNITY_FLOAT_IS_NOT_NAN,
+ UNITY_FLOAT_IS_NAN,
+ UNITY_FLOAT_IS_NOT_DET,
+ UNITY_FLOAT_IS_DET,
+} UNITY_FLOAT_TRAIT_T;
+#endif
+
+struct _Unity
+{
+ const char* TestFile;
+ const char* CurrentTestName;
+ UNITY_LINE_TYPE CurrentTestLineNumber;
+ UNITY_COUNTER_TYPE NumberOfTests;
+ UNITY_COUNTER_TYPE TestFailures;
+ UNITY_COUNTER_TYPE TestIgnores;
+ UNITY_COUNTER_TYPE CurrentTestFailed;
+ UNITY_COUNTER_TYPE CurrentTestIgnored;
+ jmp_buf AbortFrame;
+};
+
+extern struct _Unity Unity;
+
+//-------------------------------------------------------
+// Test Suite Management
+//-------------------------------------------------------
+
+void UnityBegin(const char* filename);
+int UnityEnd(void);
+void UnityConcludeTest(void);
+void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
+
+//-------------------------------------------------------
+// Test Output
+//-------------------------------------------------------
+
+void UnityPrint(const char* string);
+void UnityPrintMask(const _U_UINT mask, const _U_UINT number);
+void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style);
+void UnityPrintNumber(const _U_SINT number);
+void UnityPrintNumberUnsigned(const _U_UINT number);
+void UnityPrintNumberHex(const _U_UINT number, const char nibbles);
+
+#ifdef UNITY_FLOAT_VERBOSE
+void UnityPrintFloat(const _UF number);
+#endif
+
+//-------------------------------------------------------
+// Test Assertion Fuctions
+//-------------------------------------------------------
+// Use the macros below this section instead of calling
+// these directly. The macros have a consistent naming
+// convention and will pull in file and line information
+// for you.
+
+void UnityAssertEqualNumber(const _U_SINT expected,
+ const _U_SINT actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_DISPLAY_STYLE_T style);
+
+void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected,
+ UNITY_PTR_ATTRIBUTE const void* actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_DISPLAY_STYLE_T style);
+
+void UnityAssertBits(const _U_SINT mask,
+ const _U_SINT expected,
+ const _U_SINT actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertEqualString(const char* expected,
+ const char* actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertEqualStringArray( const char** expected,
+ const char** actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected,
+ UNITY_PTR_ATTRIBUTE const void* actual,
+ const _UU32 length,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertNumbersWithin(const _U_SINT delta,
+ const _U_SINT expected,
+ const _U_SINT actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_DISPLAY_STYLE_T style);
+
+void UnityFail(const char* message, const UNITY_LINE_TYPE line);
+
+void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);
+
+#ifndef UNITY_EXCLUDE_FLOAT
+void UnityAssertFloatsWithin(const _UF delta,
+ const _UF expected,
+ const _UF actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
+ UNITY_PTR_ATTRIBUTE const _UF* actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertFloatSpecial(const _UF actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_FLOAT_TRAIT_T style);
+#endif
+
+#ifndef UNITY_EXCLUDE_DOUBLE
+void UnityAssertDoublesWithin(const _UD delta,
+ const _UD expected,
+ const _UD actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
+ UNITY_PTR_ATTRIBUTE const _UD* actual,
+ const _UU32 num_elements,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber);
+
+void UnityAssertDoubleSpecial(const _UD actual,
+ const char* msg,
+ const UNITY_LINE_TYPE lineNumber,
+ const UNITY_FLOAT_TRAIT_T style);
+#endif
+
+//-------------------------------------------------------
+// Error Strings We Might Need
+//-------------------------------------------------------
+
+extern const char UnityStrErrFloat[];
+extern const char UnityStrErrDouble[];
+extern const char UnityStrErr64[];
+
+//-------------------------------------------------------
+// Test Running Macros
+//-------------------------------------------------------
+
+#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0)
+
+#define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);}
+
+//This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__)
+#ifndef RUN_TEST
+#ifdef __STDC_VERSION__
+#if __STDC_VERSION__ >= 199901L
+#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__))
+#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway)
+#define RUN_TEST_FIRST_HELPER(first,...) first, #first
+#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway)
+#define RUN_TEST_SECOND_HELPER(first,second,...) second
+#endif
+#endif
+#endif
+
+//If we can't do the tricky version, we'll just have to require them to always include the line number
+#ifndef RUN_TEST
+#ifdef CMOCK
+#define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num)
+#else
+#define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__)
+#endif
+#endif
+
+#define TEST_LINE_NUM (Unity.CurrentTestLineNumber)
+#define TEST_IS_IGNORED (Unity.CurrentTestIgnored)
+#define UNITY_NEW_TEST(a) \
+ Unity.CurrentTestName = a; \
+ Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \
+ Unity.NumberOfTests++;
+
+#ifndef UNITY_BEGIN
+#define UNITY_BEGIN() UnityBegin(__FILE__)
+#endif
+
+#ifndef UNITY_END
+#define UNITY_END() UnityEnd()
+#endif
+
+//-------------------------------------------------------
+// Basic Fail and Ignore
+//-------------------------------------------------------
+
+#define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)line);
+#define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)line);
+
+//-------------------------------------------------------
+// Test Asserts
+//-------------------------------------------------------
+
+#define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, message);}
+#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)line, message)
+#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)line, message)
+
+#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
+#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
+#define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16)
+#define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32)
+#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
+#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU8 )(expected), (_U_SINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8)
+#define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU16)(expected), (_U_SINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16)
+#define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU32)(expected), (_U_SINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32)
+#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
+#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
+#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
+#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((_U_SINT)(mask), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line)
+
+#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
+#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US8 )(delta), (_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
+#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US16)(delta), (_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16)
+#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US32)(delta), (_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32)
+#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
+#define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8)
+#define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16)
+#define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32)
+#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
+#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
+#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
+
+#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UP)(expected), (_U_SINT)(_UP)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER)
+#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line)
+
+#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
+#define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
+#define UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16)
+#define UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32)
+#define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
+#define UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8)
+#define UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16)
+#define UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32)
+#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
+#define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
+#define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
+#define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(_UP*)(expected), (const void*)(_UP*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER)
+#define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((const char**)(expected), (const char**)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
+
+#ifdef UNITY_SUPPORT_64
+#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
+#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
+#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
+#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
+#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
+#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
+#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
+#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
+#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
+#else
+#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
+#endif
+
+#ifdef UNITY_EXCLUDE_FLOAT
+#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
+#else
+#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((_UF)(delta), (_UF)(expected), (_UF)(actual), (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((_UF)(expected) * (_UF)UNITY_FLOAT_PRECISION, (_UF)expected, (_UF)actual, (UNITY_LINE_TYPE)line, message)
+#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((_UF*)(expected), (_UF*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NEG_INF)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN)
+#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_INF)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NEG_INF)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN)
+#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET)
+#endif
+
+#ifdef UNITY_EXCLUDE_DOUBLE
+#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
+#else
+#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((_UD)(delta), (_UD)(expected), (_UD)(actual), (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((_UD)(expected) * (_UD)UNITY_DOUBLE_PRECISION, (_UD)expected, (_UD)actual, (UNITY_LINE_TYPE)line, message)
+#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((_UD*)(expected), (_UD*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NEG_INF)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_INF)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NEG_INF)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN)
+#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET)
+#endif
+
+//End of UNITY_INTERNALS_H
+#endif
diff --git a/lab_6/unity/test/expectdata/testsample_cmd.c b/lab_6/unity/test/expectdata/testsample_cmd.c new file mode 100644 index 0000000..3bd5c08 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_cmd.c @@ -0,0 +1,57 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_def.c b/lab_6/unity/test/expectdata/testsample_def.c new file mode 100644 index 0000000..0c95c76 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_def.c @@ -0,0 +1,53 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_cmd.c b/lab_6/unity/test/expectdata/testsample_mock_cmd.c new file mode 100644 index 0000000..d047b2a --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_cmd.c @@ -0,0 +1,79 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_def.c b/lab_6/unity/test/expectdata/testsample_mock_def.c new file mode 100644 index 0000000..3a90549 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_def.c @@ -0,0 +1,75 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_new1.c b/lab_6/unity/test/expectdata/testsample_mock_new1.c new file mode 100644 index 0000000..7f49c2e --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_new1.c @@ -0,0 +1,88 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include "one.h" +#include "two.h" +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_new2.c b/lab_6/unity/test/expectdata/testsample_mock_new2.c new file mode 100644 index 0000000..daeb82e --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_new2.c @@ -0,0 +1,88 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Suite Setup===== +static int suite_setup(void) +{ +a_custom_setup(); +} + +//=======Suite Teardown===== +static int suite_teardown(int num_failures) +{ +a_custom_teardown(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + suite_setup(); + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return suite_teardown(UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_param.c b/lab_6/unity/test/expectdata/testsample_mock_param.c new file mode 100644 index 0000000..0f6b05a --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_param.c @@ -0,0 +1,76 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST_NO_ARGS +#define RUN_TEST(TestFunc, TestLineNum, ...) \ +{ \ + Unity.CurrentTestName = #TestFunc "(" #__VA_ARGS__ ")"; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(__VA_ARGS__); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); + RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); + + CMock_Guts_MemFreeFinal(); + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_run1.c b/lab_6/unity/test/expectdata/testsample_mock_run1.c new file mode 100644 index 0000000..7f49c2e --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_run1.c @@ -0,0 +1,88 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include "one.h" +#include "two.h" +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_run2.c b/lab_6/unity/test/expectdata/testsample_mock_run2.c new file mode 100644 index 0000000..daeb82e --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_run2.c @@ -0,0 +1,88 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Suite Setup===== +static int suite_setup(void) +{ +a_custom_setup(); +} + +//=======Suite Teardown===== +static int suite_teardown(int num_failures) +{ +a_custom_teardown(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + suite_setup(); + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return suite_teardown(UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_mock_yaml.c b/lab_6/unity/test/expectdata/testsample_mock_yaml.c new file mode 100644 index 0000000..35377d7 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_mock_yaml.c @@ -0,0 +1,89 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + CMock_Init(); \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include "two.h" +#include "three.h" +#include <four.h> +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include <setjmp.h> +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Suite Setup===== +static int suite_setup(void) +{ +a_yaml_setup(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + suite_setup(); + UnityBegin("testdata/mocksample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + CMock_Guts_MemFreeFinal(); + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_new1.c b/lab_6/unity/test/expectdata/testsample_new1.c new file mode 100644 index 0000000..1bba7ea --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_new1.c @@ -0,0 +1,63 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "one.h" +#include "two.h" +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_new2.c b/lab_6/unity/test/expectdata/testsample_new2.c new file mode 100644 index 0000000..4ce6639 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_new2.c @@ -0,0 +1,66 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Suite Setup===== +static int suite_setup(void) +{ +a_custom_setup(); +} + +//=======Suite Teardown===== +static int suite_teardown(int num_failures) +{ +a_custom_teardown(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + suite_setup(); + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return suite_teardown(UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_param.c b/lab_6/unity/test/expectdata/testsample_param.c new file mode 100644 index 0000000..950eeb3 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_param.c @@ -0,0 +1,54 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST_NO_ARGS +#define RUN_TEST(TestFunc, TestLineNum, ...) \ +{ \ + Unity.CurrentTestName = #TestFunc "(" #__VA_ARGS__ ")"; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(__VA_ARGS__); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); + RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); + + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_run1.c b/lab_6/unity/test/expectdata/testsample_run1.c new file mode 100644 index 0000000..1bba7ea --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_run1.c @@ -0,0 +1,63 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "one.h" +#include "two.h" +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_run2.c b/lab_6/unity/test/expectdata/testsample_run2.c new file mode 100644 index 0000000..4ce6639 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_run2.c @@ -0,0 +1,66 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include <setjmp.h> +#include <stdio.h> +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Suite Setup===== +static int suite_setup(void) +{ +a_custom_setup(); +} + +//=======Suite Teardown===== +static int suite_teardown(int num_failures) +{ +a_custom_teardown(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + suite_setup(); + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return suite_teardown(UnityEnd()); +} diff --git a/lab_6/unity/test/expectdata/testsample_yaml.c b/lab_6/unity/test/expectdata/testsample_yaml.c new file mode 100644 index 0000000..96ba511 --- /dev/null +++ b/lab_6/unity/test/expectdata/testsample_yaml.c @@ -0,0 +1,67 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "two.h" +#include "three.h" +#include <four.h> +#include <setjmp.h> +#include <stdio.h> +#include "CException.h" +#include "funky.h" +#include "stanky.h" +#include <setjmp.h> + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Suite Setup===== +static int suite_setup(void) +{ +a_yaml_setup(); +} + +//=======Test Reset Option===== +void resetTest(void); +void resetTest(void) +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + suite_setup(); + UnityBegin("testdata/testsample.c"); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/lab_6/unity/test/rakefile b/lab_6/unity/test/rakefile new file mode 100644 index 0000000..779605e --- /dev/null +++ b/lab_6/unity/test/rakefile @@ -0,0 +1,60 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/'
+
+require 'rake'
+require 'rake/clean'
+require UNITY_ROOT + 'rakefile_helper'
+
+TEMP_DIRS = [
+ File.join(UNITY_ROOT, 'build')
+]
+
+TEMP_DIRS.each do |dir|
+ directory(dir)
+ CLOBBER.include(dir)
+end
+
+task :prepare_for_tests => TEMP_DIRS
+
+include RakefileHelpers
+
+# Load proper GCC as defult configuration
+DEFAULT_CONFIG_FILE = 'gcc_32.yml'
+configure_toolchain(DEFAULT_CONFIG_FILE)
+
+desc "Test unity with its own unit tests"
+task :unit => [:prepare_for_tests] do
+ run_tests get_unit_test_files
+end
+
+desc "Test unity's helper scripts"
+task :scripts => [:prepare_for_tests] do
+ Dir['tests/test_*.rb'].each do |scriptfile|
+ require "./"+scriptfile
+ end
+end
+
+desc "Generate test summary"
+task :summary do
+ report_summary
+end
+
+desc "Build and test Unity"
+task :all => [:clean, :prepare_for_tests, :scripts, :unit, :summary]
+task :default => [:clobber, :all]
+task :ci => [:no_color, :default]
+task :cruise => [:no_color, :default]
+
+desc "Load configuration"
+task :config, :config_file do |t, args|
+ configure_toolchain(args[:config_file])
+end
+
+task :no_color do
+ $colour_output = false
+end
diff --git a/lab_6/unity/test/rakefile_helper.rb b/lab_6/unity/test/rakefile_helper.rb new file mode 100644 index 0000000..935a4f4 --- /dev/null +++ b/lab_6/unity/test/rakefile_helper.rb @@ -0,0 +1,249 @@ +# ==========================================
+# Unity Project - A Test Framework for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+require 'yaml'
+require 'fileutils'
+require UNITY_ROOT + '../auto/unity_test_summary'
+require UNITY_ROOT + '../auto/generate_test_runner'
+require UNITY_ROOT + '../auto/colour_reporter'
+
+module RakefileHelpers
+
+ C_EXTENSION = '.c'
+
+ def load_configuration(config_file)
+ unless ($configured)
+ $cfg_file = "targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
+ $cfg = YAML.safe_load(File.read($cfg_file), permitted_classes: [Symbol], permitted_symbols: [], aliases: true)
+ $colour_output = false unless $cfg['colour']
+ $configured = true if (config_file != DEFAULT_CONFIG_FILE)
+ end
+ end
+
+ def configure_clean
+ CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
+ end
+
+ def configure_toolchain(config_file=DEFAULT_CONFIG_FILE)
+ config_file += '.yml' unless config_file =~ /\.yml$/
+ config_file = config_file unless config_file =~ /[\\|\/]/
+ load_configuration(config_file)
+ configure_clean
+ end
+
+ def get_unit_test_files
+ path = $cfg['compiler']['unit_tests_path'] + 'test*' + C_EXTENSION
+ path.gsub!(/\\/, '/')
+ FileList.new(path)
+ end
+
+ def get_local_include_dirs
+ include_dirs = $cfg['compiler']['includes']['items'].dup
+ include_dirs.delete_if {|dir| dir.is_a?(Array)}
+ return include_dirs
+ end
+
+ def extract_headers(filename)
+ includes = []
+ lines = File.readlines(filename)
+ lines.each do |line|
+ m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
+ if not m.nil?
+ includes << m[1]
+ end
+ end
+ return includes
+ end
+
+ def find_source_file(header, paths)
+ paths.each do |dir|
+ src_file = dir + header.ext(C_EXTENSION)
+ if (File.exist?(src_file))
+ return src_file
+ end
+ end
+ return nil
+ end
+
+ def tackit(strings)
+ if strings.is_a?(Array)
+ result = "\"#{strings.join}\""
+ else
+ result = strings
+ end
+ return result
+ end
+
+ def squash(prefix, items)
+ result = ''
+ items.each { |item| result += " #{prefix}#{tackit(item)}" }
+ return result
+ end
+
+ def should(behave, &block)
+ if block
+ puts "Should " + behave
+ yield block
+ else
+ puts "UNIMPLEMENTED CASE: Should #{behave}"
+ end
+ end
+
+ def build_compiler_fields
+ command = tackit($cfg['compiler']['path'])
+ if $cfg['compiler']['defines']['items'].nil?
+ defines = ''
+ else
+ defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
+ end
+ options = squash('', $cfg['compiler']['options'])
+ includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
+ includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
+ return {:command => command, :defines => defines, :options => options, :includes => includes}
+ end
+
+ def compile(file, defines=[])
+ compiler = build_compiler_fields
+ cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " +
+ "#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
+ obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
+ execute(cmd_str + obj_file)
+ return obj_file
+ end
+
+ def build_linker_fields
+ command = tackit($cfg['linker']['path'])
+ if $cfg['linker']['options'].nil?
+ options = ''
+ else
+ options = squash('', $cfg['linker']['options'])
+ end
+ if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?)
+ includes = ''
+ else
+ includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
+ end
+ includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
+ return {:command => command, :options => options, :includes => includes}
+ end
+
+ def link_it(exe_name, obj_list)
+ linker = build_linker_fields
+ cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
+ (obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).join +
+ $cfg['linker']['bin_files']['prefix'] + ' ' +
+ $cfg['linker']['bin_files']['destination'] +
+ exe_name + $cfg['linker']['bin_files']['extension']
+ execute(cmd_str)
+ end
+
+ def build_simulator_fields
+ return nil if $cfg['simulator'].nil?
+ if $cfg['simulator']['path'].nil?
+ command = ''
+ else
+ command = (tackit($cfg['simulator']['path']) + ' ')
+ end
+ if $cfg['simulator']['pre_support'].nil?
+ pre_support = ''
+ else
+ pre_support = squash('', $cfg['simulator']['pre_support'])
+ end
+ if $cfg['simulator']['post_support'].nil?
+ post_support = ''
+ else
+ post_support = squash('', $cfg['simulator']['post_support'])
+ end
+ return {:command => command, :pre_support => pre_support, :post_support => post_support}
+ end
+
+ def execute(command_string, verbose=true)
+ report command_string
+ output = `#{command_string}`.chomp
+ report(output) if (verbose && !output.nil? && (output.length > 0))
+ if $?.exitstatus != 0
+ raise "Command failed. (Returned #{$?.exitstatus})"
+ end
+ return output
+ end
+
+ def report_summary
+ summary = UnityTestSummary.new
+ summary.set_root_path(UNITY_ROOT)
+ results_glob = "#{$cfg['compiler']['build_path']}*.test*"
+ results_glob.gsub!(/\\/, '/')
+ results = Dir[results_glob]
+ summary.set_targets(results)
+ report summary.run
+ end
+
+ def run_tests(test_files)
+ report 'Running Unity system tests...'
+
+ # Tack on TEST define for compiling unit tests
+ load_configuration($cfg_file)
+ test_defines = ['TEST']
+ $cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
+ $cfg['compiler']['defines']['items'] << 'TEST'
+
+ include_dirs = get_local_include_dirs
+
+ # Build and execute each unit test
+ test_files.each do |test|
+ obj_list = []
+
+ # Detect dependencies and build required modules
+ extract_headers(test).each do |header|
+ # Compile corresponding source file if it exists
+ src_file = find_source_file(header, include_dirs)
+ if !src_file.nil?
+ obj_list << compile(src_file, test_defines)
+ end
+ end
+
+ # Build the test runner (generate if configured to do so)
+ test_base = File.basename(test, C_EXTENSION)
+
+ runner_name = test_base + '_Runner.c'
+ runner_path = ''
+
+ if $cfg['compiler']['runner_path'].nil?
+ runner_path = $cfg['compiler']['build_path'] + runner_name
+ else
+ runner_path = $cfg['compiler']['runner_path'] + runner_name
+ end
+
+ options = $cfg[:unity]
+ options[:use_param_tests] = (test =~ /parameterized/) ? true : false
+ UnityTestRunnerGenerator.new(options).run(test, runner_path)
+ obj_list << compile(runner_path, test_defines)
+
+ # Build the test module
+ obj_list << compile(test, test_defines)
+
+ # Link the test executable
+ link_it(test_base, obj_list)
+
+ # Execute unit test and generate results file
+ simulator = build_simulator_fields
+ executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
+ if simulator.nil?
+ cmd_str = executable
+ else
+ cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
+ end
+ output = execute(cmd_str)
+ test_results = $cfg['compiler']['build_path'] + test_base
+ if output.match(/OK$/m).nil?
+ test_results += '.testfail'
+ else
+ test_results += '.testpass'
+ end
+ File.open(test_results, 'w') { |f| f.print output }
+
+ end
+ end
+end
diff --git a/lab_6/unity/test/targets/clang_strict.yml b/lab_6/unity/test/targets/clang_strict.yml new file mode 100644 index 0000000..3e2bdc2 --- /dev/null +++ b/lab_6/unity/test/targets/clang_strict.yml @@ -0,0 +1,83 @@ +---
+compiler:
+ path: clang
+ source_path: '../src/'
+ unit_tests_path: &unit_tests_path 'tests/'
+ build_path: &build_path 'build/'
+ options:
+ - '-c'
+ - '-Wall'
+ - '-Wextra'
+ - '-Werror'
+ - '-Wcast-qual'
+ - '-Wconversion'
+ - '-Wdisabled-optimization'
+ - '-Wformat=2'
+ - '-Winit-self'
+ - '-Winline'
+ - '-Winvalid-pch'
+ - '-Wmissing-declarations'
+ - '-Wmissing-include-dirs'
+ - '-Wmissing-prototypes'
+ - '-Wnonnull'
+ - '-Wpacked'
+ - '-Wpointer-arith'
+ - '-Wredundant-decls'
+ - '-Wswitch-default'
+ - '-Wstrict-aliasing'
+ - '-Wstrict-overflow=5'
+ - '-Wuninitialized'
+ - '-Wunused'
+ - '-Wunreachable-code'
+ - '-Wreturn-type'
+ - '-Wshadow'
+ - '-Wundef'
+ - '-Wwrite-strings'
+ - '-Wno-missing-declarations'
+ - '-Wno-missing-prototypes'
+ - '-Wno-nested-externs'
+ - '-Wno-redundant-decls'
+ - '-Wno-unused-parameter'
+ - '-Wno-variadic-macros'
+ - '-Wbad-function-cast'
+ - '-fms-extensions'
+ - '-fno-omit-frame-pointer'
+ - '-ffloat-store'
+ - '-fno-common'
+ - '-fstrict-aliasing'
+ - '-std=gnu99'
+ - '-pedantic'
+ - '-O0'
+ includes:
+ prefix: '-I'
+ items:
+ - 'src/'
+ - '../src/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_INCLUDE_DOUBLE
+ - UNITY_SUPPORT_TEST_CASES
+ - UNITY_SUPPORT_64
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: gcc
+ options:
+ - -lm
+ - '-m64'
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.exe'
+ destination: *build_path
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/gcc_32.yml b/lab_6/unity/test/targets/gcc_32.yml new file mode 100644 index 0000000..dbed355 --- /dev/null +++ b/lab_6/unity/test/targets/gcc_32.yml @@ -0,0 +1,49 @@ +compiler:
+ path: gcc
+ source_path: '../src/'
+ unit_tests_path: &unit_tests_path 'tests/'
+ build_path: &build_path 'build/'
+ options:
+ - '-c'
+ - '-m32'
+ - '-Wall'
+ - '-Wno-address'
+ - '-std=c99'
+ - '-pedantic'
+ includes:
+ prefix: '-I'
+ items:
+ - 'src/'
+ - '../src/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_EXCLUDE_STDINT_H
+ - UNITY_EXCLUDE_LIMITS_H
+ - UNITY_EXCLUDE_SIZEOF
+ - UNITY_INCLUDE_DOUBLE
+ - UNITY_SUPPORT_TEST_CASES
+ - UNITY_INT_WIDTH=32
+ - UNITY_LONG_WIDTH=32
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: gcc
+ options:
+ - -lm
+ - '-m32'
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.exe'
+ destination: *build_path
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/gcc_64.yml b/lab_6/unity/test/targets/gcc_64.yml new file mode 100644 index 0000000..8f60340 --- /dev/null +++ b/lab_6/unity/test/targets/gcc_64.yml @@ -0,0 +1,50 @@ +compiler:
+ path: gcc
+ source_path: '../src/'
+ unit_tests_path: &unit_tests_path 'tests/'
+ build_path: &build_path 'build/'
+ options:
+ - '-c'
+ - '-m64'
+ - '-Wall'
+ - '-Wno-address'
+ - '-std=c99'
+ - '-pedantic'
+ includes:
+ prefix: '-I'
+ items:
+ - 'src/'
+ - '../src/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_EXCLUDE_STDINT_H
+ - UNITY_EXCLUDE_LIMITS_H
+ - UNITY_EXCLUDE_SIZEOF
+ - UNITY_INCLUDE_DOUBLE
+ - UNITY_SUPPORT_TEST_CASES
+ - UNITY_SUPPORT_64
+ - UNITY_INT_WIDTH=32
+ - UNITY_LONG_WIDTH=64
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: gcc
+ options:
+ - -lm
+ - '-m64'
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.exe'
+ destination: *build_path
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/gcc_auto_limits.yml b/lab_6/unity/test/targets/gcc_auto_limits.yml new file mode 100644 index 0000000..72ed555 --- /dev/null +++ b/lab_6/unity/test/targets/gcc_auto_limits.yml @@ -0,0 +1,46 @@ +compiler:
+ path: gcc
+ source_path: '../src/'
+ unit_tests_path: &unit_tests_path 'tests/'
+ build_path: &build_path 'build/'
+ options:
+ - '-c'
+ - '-m64'
+ - '-Wall'
+ - '-Wno-address'
+ - '-std=c99'
+ - '-pedantic'
+ includes:
+ prefix: '-I'
+ items:
+ - 'src/'
+ - '../src/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_EXCLUDE_STDINT_H
+ - UNITY_INCLUDE_DOUBLE
+ - UNITY_SUPPORT_TEST_CASES
+ - UNITY_SUPPORT_64
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: gcc
+ options:
+ - -lm
+ - '-m64'
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.exe'
+ destination: *build_path
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/gcc_auto_sizeof.yml b/lab_6/unity/test/targets/gcc_auto_sizeof.yml new file mode 100644 index 0000000..b7076ea --- /dev/null +++ b/lab_6/unity/test/targets/gcc_auto_sizeof.yml @@ -0,0 +1,47 @@ +compiler:
+ path: gcc
+ source_path: '../src/'
+ unit_tests_path: &unit_tests_path 'tests/'
+ build_path: &build_path 'build/'
+ options:
+ - '-c'
+ - '-m64'
+ - '-Wall'
+ - '-Wno-address'
+ - '-std=c99'
+ - '-pedantic'
+ includes:
+ prefix: '-I'
+ items:
+ - 'src/'
+ - '../src/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_EXCLUDE_STDINT_H
+ - UNITY_EXCLUDE_LIMTIS_H
+ - UNITY_INCLUDE_DOUBLE
+ - UNITY_SUPPORT_TEST_CASES
+ - UNITY_SUPPORT_64
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: gcc
+ options:
+ - -lm
+ - '-m64'
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.exe'
+ destination: *build_path
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/gcc_auto_stdint.yml b/lab_6/unity/test/targets/gcc_auto_stdint.yml new file mode 100644 index 0000000..4e642c1 --- /dev/null +++ b/lab_6/unity/test/targets/gcc_auto_stdint.yml @@ -0,0 +1,61 @@ +compiler:
+ path: gcc
+ source_path: '../src/'
+ unit_tests_path: &unit_tests_path 'tests/'
+ build_path: &build_path 'build/'
+ options:
+ - '-c'
+ - '-m64'
+ - '-Wall'
+ - '-Wno-address'
+ - '-std=c99'
+ - '-pedantic'
+ - '-Wextra'
+ - '-Werror'
+ - '-Wpointer-arith'
+ - '-Wcast-align'
+ - '-Wwrite-strings'
+ - '-Wswitch-default'
+ - '-Wunreachable-code'
+ - '-Winit-self'
+ - '-Wlogical-op'
+ - '-Wmissing-field-initializers'
+ - '-Wno-unknown-pragmas'
+ - '-Wjump-misses-init'
+ - '-Wstrict-prototypes'
+ - '-Wundef'
+ - '-Wunsafe-loop-optimizations'
+ - '-Wold-style-definition'
+ includes:
+ prefix: '-I'
+ items:
+ - 'src/'
+ - '../src/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_INCLUDE_DOUBLE
+ - UNITY_SUPPORT_TEST_CASES
+ - UNITY_SUPPORT_64
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: gcc
+ options:
+ - -lm
+ - '-m64'
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.exe'
+ destination: *build_path
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/hitech_picc18.yml b/lab_6/unity/test/targets/hitech_picc18.yml new file mode 100644 index 0000000..1e42989 --- /dev/null +++ b/lab_6/unity/test/targets/hitech_picc18.yml @@ -0,0 +1,101 @@ +# rumor has it that this yaml file works for the standard edition of the
+# hitech PICC18 compiler, but not the pro version.
+#
+compiler:
+ path: cd build && picc18
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --chip=18F87J10
+ - --ide=hitide
+ - --q #quiet please
+ - --asmlist
+ - --codeoffset=0
+ - --emi=wordwrite # External memory interface protocol
+ - --warn=0 # allow all normal warning messages
+ - --errors=10 # Number of errors before aborting compile
+ - --char=unsigned
+ - -Bl # Large memory model
+ - -G # generate symbol file
+ - --cp=16 # 16-bit pointers
+ - --double=24
+ - -N255 # 255-char symbol names
+ - --opt=none # Do not use any compiler optimziations
+ - -c # compile only
+ - -M
+ includes:
+ prefix: '-I'
+ items:
+ - 'c:/Projects/NexGen/Prototypes/CMockTest/src/'
+ - 'c:/Projects/NexGen/Prototypes/CMockTest/mocks/'
+ - 'c:/CMock/src/'
+ - 'c:/CMock/examples/src/'
+ - 'c:/CMock/vendor/unity/src/'
+ - 'c:/CMock/vendor/unity/examples/helper/'
+ - *unit_tests_path
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_INT_WIDTH=16
+ - UNITY_POINTER_WIDTH=16
+ - CMOCK_MEM_STATIC
+ - CMOCK_MEM_SIZE=3000
+ - UNITY_SUPPORT_TEST_CASES
+ - _PICC18
+ object_files:
+ # prefix: '-O' # Hi-Tech doesn't want a prefix. They key off of filename .extensions, instead
+ extension: '.obj'
+ destination: *build_path
+
+linker:
+ path: cd build && picc18
+ options:
+ - --chip=18F87J10
+ - --ide=hitide
+ - --cp=24 # 24-bit pointers. Is this needed for linker??
+ - --double=24 # Is this needed for linker??
+ - -Lw # Scan the pic87*w.lib in the lib/ of the compiler installation directory
+ - --summary=mem,file # info listing
+ - --summary=+psect
+ - --summary=+hex
+ - --output=+intel
+ - --output=+mcof
+ - --runtime=+init # Directs startup code to copy idata, ibigdata and ifardata psects from ROM to RAM.
+ - --runtime=+clear # Directs startup code to clear bss, bigbss, rbss and farbss psects
+ - --runtime=+clib # link in the c-runtime
+ - --runtime=+keep # Keep the generated startup src after its obj is linked
+ - -G # Generate src-level symbol file
+ - -MIWasTheLastToBuild.map
+ - --warn=0 # allow all normal warning messages
+ - -Bl # Large memory model (probably not needed for linking)
+ includes:
+ prefix: '-I'
+ object_files:
+ path: *build_path
+ extension: '.obj'
+ bin_files:
+ prefix: '-O'
+ extension: '.hex'
+ destination: *build_path
+
+simulator:
+ path:
+ pre_support:
+ - 'java -client -jar ' # note space
+ - ['C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\', 'simpic18.jar']
+ - 18F87J10
+ post_support:
+
+:cmock:
+ :plugins: []
+ :includes:
+ - Types.h
+ :suite_teardown: |
+ if (num_failures)
+ _FAILED_TEST();
+ else
+ _PASSED_TESTS();
+ return 0;
+
+colour: true
diff --git a/lab_6/unity/test/targets/iar_arm_v4.yml b/lab_6/unity/test/targets/iar_arm_v4.yml new file mode 100644 index 0000000..ce847b9 --- /dev/null +++ b/lab_6/unity/test/targets/iar_arm_v4.yml @@ -0,0 +1,89 @@ +tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\'
+compiler:
+ path: [*tools_root, 'arm\bin\iccarm.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --dlib_config
+ - [*tools_root, 'arm\lib\dl4tptinl8n.h']
+ - -z3
+ - --no_cse
+ - --no_unroll
+ - --no_inline
+ - --no_code_motion
+ - --no_tbaa
+ - --no_clustering
+ - --no_scheduling
+ - --debug
+ - --cpu_mode thumb
+ - --endian little
+ - --cpu ARM7TDMI
+ - --stack_align 4
+ - --interwork
+ - -e
+ - --silent
+ - --warnings_are_errors
+ - --fpu None
+ - --diag_suppress Pa050
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'arm\inc\']
+ - 'src\'
+ - '..\src\'
+ - *unit_tests_path
+ - 'vendor\unity\src\'
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_SUPPORT_64
+ - 'UNITY_SUPPORT_TEST_CASES'
+ object_files:
+ prefix: '-o'
+ extension: '.r79'
+ destination: *build_path
+linker:
+ path: [*tools_root, 'common\bin\xlink.exe']
+ options:
+ - -rt
+ - [*tools_root, 'arm\lib\dl4tptinl8n.r79']
+ - -D_L_EXTMEM_START=0
+ - -D_L_EXTMEM_SIZE=0
+ - -D_L_HEAP_SIZE=120
+ - -D_L_STACK_SIZE=32
+ - -e_small_write=_formatted_write
+ - -s
+ - __program_start
+ - -f
+ - [*tools_root, '\arm\config\lnkarm.xcl']
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'arm\config\']
+ - [*tools_root, 'arm\lib\']
+ object_files:
+ path: *build_path
+ extension: '.r79'
+ bin_files:
+ prefix: '-o'
+ extension: '.d79'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ - --silent
+ - [*tools_root, 'arm\bin\armproc.dll']
+ - [*tools_root, 'arm\bin\armsim.dll']
+ post_support:
+ - --plugin
+ - [*tools_root, 'arm\bin\armbat.dll']
+ - --backend
+ - -B
+ - -p
+ - [*tools_root, 'arm\config\ioat91sam7X256.ddf']
+ - -d
+ - sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/iar_arm_v5.yml b/lab_6/unity/test/targets/iar_arm_v5.yml new file mode 100644 index 0000000..22daad4 --- /dev/null +++ b/lab_6/unity/test/targets/iar_arm_v5.yml @@ -0,0 +1,79 @@ +tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
+compiler:
+ path: [*tools_root, 'arm\bin\iccarm.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --dlib_config
+ - [*tools_root, 'arm\inc\DLib_Config_Normal.h']
+ - --no_cse
+ - --no_unroll
+ - --no_inline
+ - --no_code_motion
+ - --no_tbaa
+ - --no_clustering
+ - --no_scheduling
+ - --debug
+ - --cpu_mode thumb
+ - --endian=little
+ - --cpu=ARM7TDMI
+ - --interwork
+ - --warnings_are_errors
+ - --fpu=None
+ - --diag_suppress=Pa050
+ - --diag_suppress=Pe111
+ - -e
+ - -On
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'arm\inc\']
+ - 'src\'
+ - '..\src\'
+ - *unit_tests_path
+ - 'vendor\unity\src\'
+ - 'iar\iar_v5\incIAR\'
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_SUPPORT_64
+ - 'UNITY_SUPPORT_TEST_CASES'
+ object_files:
+ prefix: '-o'
+ extension: '.r79'
+ destination: *build_path
+linker:
+ path: [*tools_root, 'arm\bin\ilinkarm.exe']
+ options:
+ - --redirect _Printf=_PrintfLarge
+ - --redirect _Scanf=_ScanfSmall
+ - --semihosting
+ - --entry __iar_program_start
+ - --config
+ - [*tools_root, 'arm\config\generic.icf']
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.out'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ - --silent
+ - [*tools_root, 'arm\bin\armproc.dll']
+ - [*tools_root, 'arm\bin\armsim.dll']
+ post_support:
+ - --plugin
+ - [*tools_root, 'arm\bin\armbat.dll']
+ - --backend
+ - -B
+ - -p
+ - [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
+ - -d
+ - sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/iar_arm_v5_3.yml b/lab_6/unity/test/targets/iar_arm_v5_3.yml new file mode 100644 index 0000000..22daad4 --- /dev/null +++ b/lab_6/unity/test/targets/iar_arm_v5_3.yml @@ -0,0 +1,79 @@ +tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
+compiler:
+ path: [*tools_root, 'arm\bin\iccarm.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --dlib_config
+ - [*tools_root, 'arm\inc\DLib_Config_Normal.h']
+ - --no_cse
+ - --no_unroll
+ - --no_inline
+ - --no_code_motion
+ - --no_tbaa
+ - --no_clustering
+ - --no_scheduling
+ - --debug
+ - --cpu_mode thumb
+ - --endian=little
+ - --cpu=ARM7TDMI
+ - --interwork
+ - --warnings_are_errors
+ - --fpu=None
+ - --diag_suppress=Pa050
+ - --diag_suppress=Pe111
+ - -e
+ - -On
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'arm\inc\']
+ - 'src\'
+ - '..\src\'
+ - *unit_tests_path
+ - 'vendor\unity\src\'
+ - 'iar\iar_v5\incIAR\'
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_SUPPORT_64
+ - 'UNITY_SUPPORT_TEST_CASES'
+ object_files:
+ prefix: '-o'
+ extension: '.r79'
+ destination: *build_path
+linker:
+ path: [*tools_root, 'arm\bin\ilinkarm.exe']
+ options:
+ - --redirect _Printf=_PrintfLarge
+ - --redirect _Scanf=_ScanfSmall
+ - --semihosting
+ - --entry __iar_program_start
+ - --config
+ - [*tools_root, 'arm\config\generic.icf']
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.out'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ - --silent
+ - [*tools_root, 'arm\bin\armproc.dll']
+ - [*tools_root, 'arm\bin\armsim.dll']
+ post_support:
+ - --plugin
+ - [*tools_root, 'arm\bin\armbat.dll']
+ - --backend
+ - -B
+ - -p
+ - [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
+ - -d
+ - sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml b/lab_6/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml new file mode 100644 index 0000000..91c184d --- /dev/null +++ b/lab_6/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml @@ -0,0 +1,93 @@ +#Default tool path for IAR 5.4 on Windows XP 64bit
+tools_root: &tools_root 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\'
+compiler:
+ path: [*tools_root, 'arm\bin\iccarm.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --diag_suppress=Pa050
+ #- --diag_suppress=Pe111
+ - --debug
+ - --endian=little
+ - --cpu=Cortex-M3
+ - --no_path_in_file_macros
+ - -e
+ - --fpu=None
+ - --dlib_config
+ - [*tools_root, 'arm\inc\DLib_Config_Normal.h']
+ #- --preinclude --preinclude C:\Vss\T2 Working\common\system.h
+ - --interwork
+ - --warnings_are_errors
+# - Ohz
+ - -Oh
+# - --no_cse
+# - --no_unroll
+# - --no_inline
+# - --no_code_motion
+# - --no_tbaa
+# - --no_clustering
+# - --no_scheduling
+
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'arm\inc\']
+ - 'src\'
+ - '..\src\'
+ - *unit_tests_path
+ - 'vendor\unity\src\'
+ - 'iar\iar_v5\incIAR\'
+ defines:
+ prefix: '-D'
+ items:
+ - ewarm
+ - PART_LM3S9B92
+ - TARGET_IS_TEMPEST_RB1
+ - USE_ROM_DRIVERS
+ - UART_BUFFERED
+ - UNITY_SUPPORT_64
+ object_files:
+ prefix: '-o'
+ extension: '.r79'
+ destination: *build_path
+linker:
+ path: [*tools_root, 'arm\bin\ilinkarm.exe']
+ options:
+ - --redirect _Printf=_PrintfLarge
+ - --redirect _Scanf=_ScanfSmall
+ - --semihosting
+ - --entry __iar_program_start
+ - --config
+ - [*tools_root, 'arm\config\generic.icf']
+# - ['C:\Temp\lm3s9b92.icf']
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.out'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ #- --silent
+ - [*tools_root, 'arm\bin\armproc.dll']
+ - [*tools_root, 'arm\bin\armsim2.dll']
+ post_support:
+ - --plugin
+ - [*tools_root, 'arm\bin\armbat.dll']
+ - --backend
+ - -B
+ - --endian=little
+ - --cpu=Cortex-M3
+ - --fpu=None
+ - -p
+ - [*tools_root, 'arm\config\debugger\TexasInstruments\iolm3sxxxx.ddf']
+ - --semihosting
+ - --device=LM3SxBxx
+ #- -d
+ #- sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/iar_cortexm3_v5.yml b/lab_6/unity/test/targets/iar_cortexm3_v5.yml new file mode 100644 index 0000000..30d7178 --- /dev/null +++ b/lab_6/unity/test/targets/iar_cortexm3_v5.yml @@ -0,0 +1,83 @@ +# unit testing under iar compiler / simulator for STM32 Cortex-M3
+
+tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.4\'
+compiler:
+ path: [*tools_root, 'arm\bin\iccarm.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --dlib_config
+ - [*tools_root, 'arm\inc\DLib_Config_Normal.h']
+ - --no_cse
+ - --no_unroll
+ - --no_inline
+ - --no_code_motion
+ - --no_tbaa
+ - --no_clustering
+ - --no_scheduling
+ - --debug
+ - --cpu_mode thumb
+ - --endian=little
+ - --cpu=Cortex-M3
+ - --interwork
+ - --warnings_are_errors
+ - --fpu=None
+ - --diag_suppress=Pa050
+ - --diag_suppress=Pe111
+ - -e
+ - -On
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'arm\inc\']
+ - 'src\'
+ - '..\src\'
+ - *unit_tests_path
+ - 'vendor\unity\src\'
+ - 'iar\iar_v5\incIAR\'
+ defines:
+ prefix: '-D'
+ items:
+ - 'IAR'
+ - 'UNITY_SUPPORT_64'
+ - 'UNITY_SUPPORT_TEST_CASES'
+ object_files:
+ prefix: '-o'
+ extension: '.r79'
+ destination: *build_path
+linker:
+ path: [*tools_root, 'arm\bin\ilinkarm.exe']
+ options:
+ - --redirect _Printf=_PrintfLarge
+ - --redirect _Scanf=_ScanfSmall
+ - --semihosting
+ - --entry __iar_program_start
+ - --config
+ - [*tools_root, 'arm\config\generic_cortex.icf']
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.out'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ - --silent
+ - [*tools_root, 'arm\bin\armproc.dll']
+ - [*tools_root, 'arm\bin\armsim.dll']
+ post_support:
+ - --plugin
+ - [*tools_root, 'arm\bin\armbat.dll']
+ - --backend
+ - -B
+ - -p
+ - [*tools_root, 'arm\config\debugger\ST\iostm32f107xx.ddf']
+ - --cpu=Cortex-M3
+ - -d
+ - sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/iar_msp430.yml b/lab_6/unity/test/targets/iar_msp430.yml new file mode 100644 index 0000000..a36d27f --- /dev/null +++ b/lab_6/unity/test/targets/iar_msp430.yml @@ -0,0 +1,94 @@ +tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\'
+core_root: &core_root [*tools_root, '430\']
+core_bin: &core_bin [*core_root, 'bin\']
+core_config: &core_config [*core_root, 'config\']
+core_lib: &core_lib [*core_root, 'lib\']
+core_inc: &core_inc [*core_root, 'inc\']
+core_config: &core_config [*core_root, 'config\']
+
+compiler:
+ path: [*core_bin, 'icc430.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - --dlib_config
+ - [*core_lib, 'dlib\dl430fn.h']
+ - --no_cse
+ - --no_unroll
+ - --no_inline
+ - --no_code_motion
+ - --no_tbaa
+ - --debug
+ - -e
+ - -Ol
+ - --multiplier=16
+ - --double=32
+ - --diag_suppress Pa050
+ - --diag_suppress Pe111
+ includes:
+ prefix: '-I'
+ items:
+ - *core_inc
+ - [*core_inc, 'dlib']
+ - [*core_lib, 'dlib']
+ - 'src\'
+ - '../src/'
+ - *unit_tests_path
+ - 'vendor\unity\src'
+ defines:
+ prefix: '-D'
+ items:
+ - '__MSP430F149__'
+ - 'INT_WIDTH=16'
+ - 'UNITY_EXCLUDE_FLOAT'
+ - 'UNITY_SUPPORT_TEST_CASES'
+ object_files:
+ prefix: '-o'
+ extension: '.r43'
+ destination: *build_path
+linker:
+ path: [*core_bin, 'xlink.exe']
+ options:
+ - -rt
+ - [*core_lib, 'dlib\dl430fn.r43']
+ - -e_PrintfTiny=_Printf
+ - -e_ScanfSmall=_Scanf
+ - -s __program_start
+ - -D_STACK_SIZE=50
+ - -D_DATA16_HEAP_SIZE=50
+ - -D_DATA20_HEAP_SIZE=50
+ - -f
+ - [*core_config, 'lnk430f5438.xcl']
+ - -f
+ - [*core_config, 'multiplier.xcl']
+ includes:
+ prefix: '-I'
+ items:
+ - *core_config
+ - *core_lib
+ - [*core_lib, 'dlib']
+ object_files:
+ path: *build_path
+ extension: '.r79'
+ bin_files:
+ prefix: '-o'
+ extension: '.d79'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ - --silent
+ - [*core_bin, '430proc.dll']
+ - [*core_bin, '430sim.dll']
+ post_support:
+ - --plugin
+ - [*core_bin, '430bat.dll']
+ - --backend -B
+ - --cpu MSP430F5438
+ - -p
+ - [*core_config, 'MSP430F5438.ddf']
+ - -d sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/targets/iar_sh2a_v6.yml b/lab_6/unity/test/targets/iar_sh2a_v6.yml new file mode 100644 index 0000000..cb264f2 --- /dev/null +++ b/lab_6/unity/test/targets/iar_sh2a_v6.yml @@ -0,0 +1,85 @@ +tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 6.0\'
+compiler:
+ path: [*tools_root, 'sh\bin\iccsh.exe']
+ source_path: '..\src\'
+ unit_tests_path: &unit_tests_path 'tests\'
+ build_path: &build_path 'build\'
+ options:
+ - -e
+ - --char_is_signed
+ - -Ol
+ - --no_cse
+ - --no_unroll
+ - --no_inline
+ - --no_code_motion
+ - --no_tbaa
+ - --no_scheduling
+ - --no_clustering
+ - --debug
+ - --dlib_config
+ - [*tools_root, 'sh\inc\DLib_Product.h']
+ - --double=32
+ - --code_model=huge
+ - --data_model=huge
+ - --core=sh2afpu
+ - --warnings_affect_exit_code
+ - --warnings_are_errors
+ - --mfc
+ - --use_unix_directory_separators
+ - --diag_suppress=Pe161
+ includes:
+ prefix: '-I'
+ items:
+ - [*tools_root, 'sh\inc\']
+ - [*tools_root, 'sh\inc\c']
+ - 'src\'
+ - '..\src\'
+ - *unit_tests_path
+ - 'vendor\unity\src\'
+ defines:
+ prefix: '-D'
+ items:
+ - UNITY_SUPPORT_64
+ - 'UNITY_SUPPORT_TEST_CASES'
+ object_files:
+ prefix: '-o'
+ extension: '.o'
+ destination: *build_path
+linker:
+ path: [*tools_root, 'sh\bin\ilinksh.exe']
+ options:
+ - --redirect __Printf=__PrintfSmall
+ - --redirect __Scanf=__ScanfSmall
+ - --config
+ - [*tools_root, 'sh\config\generic.icf']
+ - --config_def _CSTACK_SIZE=0x800
+ - --config_def _HEAP_SIZE=0x800
+ - --config_def _INT_TABLE=0x10
+ - --entry __iar_program_start
+ - --debug_lib
+ object_files:
+ path: *build_path
+ extension: '.o'
+ bin_files:
+ prefix: '-o'
+ extension: '.out'
+ destination: *build_path
+simulator:
+ path: [*tools_root, 'common\bin\CSpyBat.exe']
+ pre_support:
+ - --silent
+ - [*tools_root, 'sh\bin\shproc.dll']
+ - [*tools_root, 'sh\bin\shsim.dll']
+ post_support:
+ - --plugin
+ - [*tools_root, 'sh\bin\shbat.dll']
+ - --backend
+ - -B
+ - --core sh2afpu
+ - -p
+ - [*tools_root, 'sh\config\debugger\io7264.ddf']
+ - -d
+ - sim
+colour: true
+:unity:
+ :plugins: []
diff --git a/lab_6/unity/test/testdata/mocksample.c b/lab_6/unity/test/testdata/mocksample.c new file mode 100644 index 0000000..847d87f --- /dev/null +++ b/lab_6/unity/test/testdata/mocksample.c @@ -0,0 +1,51 @@ +// This is just a sample test file to be used to test the generator script
+#ifndef TEST_SAMPLE_H
+#define TEST_SAMPLE_H
+
+#include <setjmp.h>
+#include "unity.h"
+#include "funky.h"
+#include "Mockstanky.h"
+
+void setUp(void)
+{
+ CustomSetupStuff();
+}
+
+void tearDown(void)
+{
+ CustomTeardownStuff
+}
+
+//Yup, nice comment
+void test_TheFirstThingToTest(void)
+{
+ TEST_ASSERT(1);
+
+ TEST_ASSERT_TRUE(1);
+}
+
+/*
+void test_ShouldBeIgnored(void)
+{
+ DoesStuff();
+}
+*/
+
+//void test_ShouldAlsoNotBeTested(void)
+//{
+// Call_An_Expect();
+//
+// CallAFunction();
+// test_CallAFunctionThatLooksLikeATest();
+//}
+
+void test_TheSecondThingToTest(void)
+{
+ Call_An_Expect();
+
+ CallAFunction();
+ test_CallAFunctionThatLooksLikeATest();
+}
+
+#endif //TEST_SAMPLE_H
diff --git a/lab_6/unity/test/testdata/sample.yml b/lab_6/unity/test/testdata/sample.yml new file mode 100644 index 0000000..52ec96b --- /dev/null +++ b/lab_6/unity/test/testdata/sample.yml @@ -0,0 +1,9 @@ +:unity:
+ :includes:
+ - two.h
+ - three.h
+ - <four.h>
+ :plugins:
+ - :cexception
+ :suite_setup: |
+ a_yaml_setup();
\ No newline at end of file diff --git a/lab_6/unity/test/testdata/testsample.c b/lab_6/unity/test/testdata/testsample.c new file mode 100644 index 0000000..e5a2b18 --- /dev/null +++ b/lab_6/unity/test/testdata/testsample.c @@ -0,0 +1,51 @@ +// This is just a sample test file to be used to test the generator script
+#ifndef TEST_SAMPLE_H
+#define TEST_SAMPLE_H
+
+#include <setjmp.h>
+#include "unity.h"
+#include "funky.h"
+#include "stanky.h"
+
+void setUp(void)
+{
+ CustomSetupStuff();
+}
+
+void tearDown(void)
+{
+ CustomTeardownStuff
+}
+
+//Yup, nice comment
+void test_TheFirstThingToTest(void)
+{
+ TEST_ASSERT(1);
+
+ TEST_ASSERT_TRUE(1);
+}
+
+/*
+void test_ShouldBeIgnored(void)
+{
+ DoesStuff();
+}
+*/
+
+//void test_ShouldAlsoNotBeTested(void)
+//{
+// Call_An_Expect();
+//
+// CallAFunction();
+// test_CallAFunctionThatLooksLikeATest();
+//}
+
+void test_TheSecondThingToTest(void)
+{
+ Call_An_Expect();
+
+ CallAFunction();
+ test_CallAFunctionThatLooksLikeATest();
+}
+
+#endif //TEST_SAMPLE_H
diff --git a/lab_6/unity/test/tests/Testfoo.c b/lab_6/unity/test/tests/Testfoo.c new file mode 100644 index 0000000..72e0c1a --- /dev/null +++ b/lab_6/unity/test/tests/Testfoo.c @@ -0,0 +1,84 @@ +#include "unity.h"
+#include "foo.h"
+
+void setUp(void)
+{
+}
+
+void tearDown(void)
+{
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_TRUE.
+void testTEST_ASSERT_TRUE (void)
+{
+ TEST_ASSERT_TRUE (1 == 1);
+ //TEST_ASSERT_TRUE (1 == 2); //failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_FALSE.
+void testTEST_ASSERT_FALSE (void)
+{
+ TEST_ASSERT_FALSE (1 == 2);
+ //TEST_ASSERT_FALSE (1 == 1); //failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_EQUAL_INT8.
+// Try it with negative decimal numbers, positive decimal numbers, and hexadecimal numbers.
+void testTEST_ASSERT_EQUAL_INT8 (void)
+{
+ TEST_ASSERT_EQUAL_INT8( 1, 1);
+ //TEST_ASSERT_EQUAL_INT8(-1, 1); //failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_EQUAL_UINT8.
+// Try it with negative decimal numbers, positive decimal numbers, and hexadecimal numbers.
+void testTEST_ASSERT_EQUAL_UINT8 (void)
+{
+ TEST_ASSERT_EQUAL_UINT8(1, 1);
+ //TEST_ASSERT_EQUAL_UINT8(1, -1); //failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_EQUAL_HEX8.
+// Try it with negative decimal numbers, positive decimal numbers, and hexadecimal numbers.
+void testTEST_ASSERT_EQUAL_HEX8 (void)
+{
+ TEST_ASSERT_EQUAL_HEX8( 0xff, 0xff );
+ //TEST_ASSERT_EQUAL_HEX8( 0x00, 0xff ); //failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_UINT_WITHIN.
+void testTEST_ASSERT_UINT_WITHIN (void)
+{
+ TEST_ASSERT_UINT_WITHIN(50, 75, 50);
+ //TEST_ASSERT_UINT_WITHIN(25, 75, 25);//failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_BITS.
+void testTEST_ASSERT_BITS (void)
+{
+ TEST_ASSERT_BITS(0xa5, 0xe7, 0xa5 );
+ //TEST_ASSERT_BITS(0xa5, 0xa4, 0xe7 );//failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_BITS_HIGH.
+void testTEST_ASSERT_BITS_HIGH (void)
+{
+ TEST_ASSERT_BITS_HIGH(0xa5, 0xe7);
+ //TEST_ASSERT_BITS_HIGH(0xe7, 0xa5);//failing
+}
+
+// Create one passing and one failing assertion using TEST_ASSERT_BIT_HIGH.
+void testTEST_ASSERT_BIT_HIGH (void)
+{
+ TEST_ASSERT_BIT_HIGH(2, 4);
+ //TEST_ASSERT_BIT_HIGH(3, 4);//failing
+}
+
+// Exhaustively test all 256 input values for the squareNumber function located in lab6\unity\src\foo.c.
+// squareNumber takes an 8-bit unsigned integer as input, squares it, and then returns the squared value as a 16-bit
+// unsigned integer.
+void testsquareNumber (void)
+{
+
+}
\ No newline at end of file diff --git a/lab_6/unity/test/tests/test_generate_test_runner.rb b/lab_6/unity/test/tests/test_generate_test_runner.rb new file mode 100644 index 0000000..1f60f98 --- /dev/null +++ b/lab_6/unity/test/tests/test_generate_test_runner.rb @@ -0,0 +1,88 @@ +# ==========================================
+# CMock Project - Automatic Mock Generation for C
+# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
+# [Released under MIT License. Please refer to license.txt for details]
+# ==========================================
+
+require '../auto/generate_test_runner.rb'
+
+TEST_FILE = 'testdata/testsample.c'
+TEST_MOCK = 'testdata/mocksample.c'
+OUT_FILE = 'build/testsample_'
+EXP_FILE = 'expectdata/testsample_'
+
+$generate_test_runner_failures = 0
+
+def verify_output_equal(subtest)
+ expected = File.read(EXP_FILE + subtest + '.c').gsub(/\r\n/,"\n")
+ actual = File.read(OUT_FILE + subtest + '.c').gsub(/\r\n/,"\n")
+ if (expected != actual)
+ report(" #{subtest}:FAIL")
+ $generate_test_runner_failures += 1
+ else
+ report(" #{subtest}:PASS")
+ end
+end
+
+should "GenerateARunnerByCreatingRunnerWithOptions" do
+ sets = { 'def' => nil,
+ 'new1' => { :plugins => [:cexception], :includes => ['one.h', 'two.h'], :enforce_strict_ordering => true },
+ 'new2' => { :plugins => [:ignore], :suite_setup => "a_custom_setup();", :suite_teardown => "a_custom_teardown();" }
+ }
+
+ sets.each_pair do |subtest, options|
+ UnityTestRunnerGenerator.new(options).run(TEST_FILE, OUT_FILE + subtest + '.c')
+ verify_output_equal(subtest)
+ UnityTestRunnerGenerator.new(options).run(TEST_MOCK, OUT_FILE + 'mock_' + subtest + '.c')
+ verify_output_equal('mock_' + subtest)
+ end
+end
+
+should "GenerateARunnerByRunningRunnerWithOptions" do
+ sets = { 'run1' => { :plugins => [:cexception], :includes => ['one.h', 'two.h'], :enforce_strict_ordering => true },
+ 'run2' => { :plugins => [:ignore], :suite_setup => "a_custom_setup();", :suite_teardown => "a_custom_teardown();" }
+ }
+
+ sets.each_pair do |subtest, options|
+ UnityTestRunnerGenerator.new.run(TEST_FILE, OUT_FILE + subtest + '.c', options)
+ verify_output_equal(subtest)
+ UnityTestRunnerGenerator.new.run(TEST_MOCK, OUT_FILE + 'mock_' + subtest + '.c', options)
+ verify_output_equal('mock_' + subtest)
+ end
+end
+
+should "GenerateARunnerByPullingYamlOptions" do
+ subtest = 'yaml'
+ cmdstr = "ruby ../auto/generate_test_runner.rb testdata/sample.yml \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
+ `#{cmdstr}`
+ verify_output_equal(subtest)
+
+ cmdstr = "ruby ../auto/generate_test_runner.rb testdata/sample.yml \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
+ `#{cmdstr}`
+ verify_output_equal('mock_' + subtest)
+end
+
+should "GenerateARunnerByPullingCommandlineOptions" do
+ subtest = 'cmd'
+ cmdstr = "ruby ../auto/generate_test_runner.rb -cexception \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
+ `#{cmdstr}`
+ verify_output_equal(subtest)
+
+ cmdstr = "ruby ../auto/generate_test_runner.rb -cexception \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
+ `#{cmdstr}`
+ verify_output_equal('mock_' + subtest)
+end
+
+should "GenerateARunnerThatUsesParameterizedTests" do
+ sets = { 'param' => { :plugins => [:ignore], :use_param_tests => true }
+ }
+
+ sets.each_pair do |subtest, options|
+ UnityTestRunnerGenerator.new(options).run(TEST_FILE, OUT_FILE + subtest + '.c')
+ verify_output_equal(subtest)
+ UnityTestRunnerGenerator.new(options).run(TEST_MOCK, OUT_FILE + 'mock_' + subtest + '.c')
+ verify_output_equal('mock_' + subtest)
+ end
+end
+
+raise "There were #{$generate_test_runner_failures.to_s} failures while testing generate_test_runner.rb" if ($generate_test_runner_failures > 0)
|