mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
Merge branch 'master' into issue-#346-documentation-improvement
This commit is contained in:
@@ -10,7 +10,7 @@ matrix:
|
|||||||
compiler: gcc
|
compiler: gcc
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.1 && rvm use 2.1 && ruby -v; fi
|
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.3 && rvm use 2.3 && ruby -v; fi
|
||||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi
|
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi
|
||||||
install:
|
install:
|
||||||
- gem install rspec
|
- gem install rspec
|
||||||
|
|||||||
70
CMakeLists.txt
Normal file
70
CMakeLists.txt
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#####################################################
|
||||||
|
# FILE NAME CMakeLists.txt #
|
||||||
|
# #
|
||||||
|
# WRITTEN BY Michael Brockus. #
|
||||||
|
# #
|
||||||
|
# PURPOSE contains CMake statements. #
|
||||||
|
# #
|
||||||
|
#####################################################
|
||||||
|
cmake_minimum_required(VERSION 3.13.2.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake: Declare project
|
||||||
|
#
|
||||||
|
project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake: Creation of library
|
||||||
|
#
|
||||||
|
add_library("unity" STATIC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake: Adding source to target
|
||||||
|
#
|
||||||
|
target_sources("unity" PRIVATE "src/unity.c")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake: Including directories to target
|
||||||
|
#
|
||||||
|
target_include_directories("unity"
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
|
||||||
|
"$<INSTALL_INTERFACE:src>"
|
||||||
|
|
||||||
|
PRIVATE "src"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake: Give target an alias
|
||||||
|
#
|
||||||
|
add_library("unity::framework" ALIAS "unity")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# CMake: export project
|
||||||
|
#
|
||||||
|
install(TARGETS "unity" EXPORT "unityConfig"
|
||||||
|
ARCHIVE DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
LIBRARY DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
RUNTIME DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}"
|
||||||
|
|
||||||
|
INCLUDES DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY src/ DESTINATION src)
|
||||||
|
|
||||||
|
install(EXPORT unityConfig DESTINATION share/unityConfig/cmake)
|
||||||
|
|
||||||
|
# This makes the project importable from the build directory
|
||||||
|
export(TARGETS unity FILE unityConfig.cmake)
|
||||||
16
README.md
16
README.md
@@ -2,7 +2,7 @@ Unity Test API
|
|||||||
==============
|
==============
|
||||||
|
|
||||||
[](https://travis-ci.org/ThrowTheSwitch/Unity)
|
[](https://travis-ci.org/ThrowTheSwitch/Unity)
|
||||||
__Copyright (c) 2007 - 2017 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
|
__Copyright (c) 2007 - 2019 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
|
||||||
|
|
||||||
Getting Started
|
Getting Started
|
||||||
===============
|
===============
|
||||||
@@ -35,7 +35,7 @@ Another way of calling `TEST_ASSERT_FALSE`
|
|||||||
TEST_FAIL()
|
TEST_FAIL()
|
||||||
TEST_FAIL_MESSAGE(message)
|
TEST_FAIL_MESSAGE(message)
|
||||||
|
|
||||||
This test is automatically marked as a failure. The message is output stating why.
|
This test is automatically marked as a failure. The message is output stating why.
|
||||||
|
|
||||||
Numerical Assertions: Integers
|
Numerical Assertions: Integers
|
||||||
------------------------------
|
------------------------------
|
||||||
@@ -47,7 +47,7 @@ Numerical Assertions: Integers
|
|||||||
TEST_ASSERT_EQUAL_INT64(expected, actual)
|
TEST_ASSERT_EQUAL_INT64(expected, actual)
|
||||||
|
|
||||||
Compare two integers for equality and display errors as signed integers. A cast will be performed
|
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,
|
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:
|
like when comparing arrays, you can use a specific version:
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_UINT(expected, actual)
|
TEST_ASSERT_EQUAL_UINT(expected, actual)
|
||||||
@@ -56,7 +56,7 @@ like when comparing arrays, you can use a specific version:
|
|||||||
TEST_ASSERT_EQUAL_UINT32(expected, actual)
|
TEST_ASSERT_EQUAL_UINT32(expected, actual)
|
||||||
TEST_ASSERT_EQUAL_UINT64(expected, actual)
|
TEST_ASSERT_EQUAL_UINT64(expected, actual)
|
||||||
|
|
||||||
Compare two integers for equality and display errors as unsigned integers. Like INT, there are
|
Compare two integers for equality and display errors as unsigned integers. Like INT, there are
|
||||||
variants for different sizes also.
|
variants for different sizes also.
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_HEX(expected, actual)
|
TEST_ASSERT_EQUAL_HEX(expected, actual)
|
||||||
@@ -65,7 +65,7 @@ variants for different sizes also.
|
|||||||
TEST_ASSERT_EQUAL_HEX32(expected, actual)
|
TEST_ASSERT_EQUAL_HEX32(expected, actual)
|
||||||
TEST_ASSERT_EQUAL_HEX64(expected, actual)
|
TEST_ASSERT_EQUAL_HEX64(expected, actual)
|
||||||
|
|
||||||
Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
|
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`
|
you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16`
|
||||||
will show 4 nibbles).
|
will show 4 nibbles).
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ Another way of calling TEST_ASSERT_EQUAL_INT
|
|||||||
|
|
||||||
TEST_ASSERT_INT_WITHIN(delta, expected, actual)
|
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
|
Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
|
||||||
size specific variants.
|
size specific variants.
|
||||||
|
|
||||||
|
|
||||||
@@ -159,12 +159,12 @@ Compare two null-terminate strings. Fail if any character is different or if th
|
|||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message)
|
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message)
|
||||||
|
|
||||||
Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure.
|
Compare two strings. Fail if any character is different, stop comparing after len characters. Output a custom message on failure.
|
||||||
|
|
||||||
Pointer Assertions
|
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.
|
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)
|
TEST_ASSERT_NULL(pointer)
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ColourCommandLine
|
|||||||
return unless RUBY_PLATFORM =~ /(win|w)32$/
|
return unless RUBY_PLATFORM =~ /(win|w)32$/
|
||||||
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
|
get_std_handle = Win32API.new('kernel32', 'GetStdHandle', ['L'], 'L')
|
||||||
@set_console_txt_attrb =
|
@set_console_txt_attrb =
|
||||||
Win32API.new('kernel32', 'SetConsoleTextAttribute', %w(L N), 'I')
|
Win32API.new('kernel32', 'SetConsoleTextAttribute', %w[L N], 'I')
|
||||||
@hout = get_std_handle.call(-11)
|
@hout = get_std_handle.call(-11)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ class ColourCommandLine
|
|||||||
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
|
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # ColourCommandLine
|
end
|
||||||
|
|
||||||
def colour_puts(role, str)
|
def colour_puts(role, str)
|
||||||
ColourCommandLine.new.out_c(:puts, role, str)
|
ColourCommandLine.new.out_c(:puts, role, str)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
require "#{File.expand_path(File.dirname(__FILE__))}/colour_prompt"
|
require_relative 'colour_prompt'
|
||||||
|
|
||||||
$colour_output = true
|
$colour_output = true
|
||||||
|
|
||||||
|
|||||||
@@ -35,18 +35,16 @@ TEMPLATE_SRC ||= '%2$s#include "%1$s.h"
|
|||||||
'.freeze
|
'.freeze
|
||||||
|
|
||||||
# TEMPLATE_INC
|
# TEMPLATE_INC
|
||||||
TEMPLATE_INC ||= '#ifndef _%3$s_H
|
TEMPLATE_INC ||= '#ifndef %3$s_H
|
||||||
#define _%3$s_H
|
#define %3$s_H
|
||||||
%2$s
|
%2$s
|
||||||
|
|
||||||
#endif // _%3$s_H
|
#endif // %3$s_H
|
||||||
'.freeze
|
'.freeze
|
||||||
|
|
||||||
class UnityModuleGenerator
|
class UnityModuleGenerator
|
||||||
############################
|
############################
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
here = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
|
|
||||||
@options = UnityModuleGenerator.default_options
|
@options = UnityModuleGenerator.default_options
|
||||||
case options
|
case options
|
||||||
when NilClass then @options
|
when NilClass then @options
|
||||||
@@ -56,9 +54,9 @@ class UnityModuleGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Create default file paths if none were provided
|
# Create default file paths if none were provided
|
||||||
@options[:path_src] = here + '../src/' if @options[:path_src].nil?
|
@options[:path_src] = "#{__dir__}/../src/" if @options[:path_src].nil?
|
||||||
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
|
@options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
|
||||||
@options[:path_tst] = here + '../test/' if @options[:path_tst].nil?
|
@options[:path_tst] = "#{__dir__}/../test/" if @options[:path_tst].nil?
|
||||||
@options[:path_src] += '/' unless @options[:path_src][-1] == 47
|
@options[:path_src] += '/' unless @options[:path_src][-1] == 47
|
||||||
@options[:path_inc] += '/' unless @options[:path_inc][-1] == 47
|
@options[:path_inc] += '/' unless @options[:path_inc][-1] == 47
|
||||||
@options[:path_tst] += '/' unless @options[:path_tst][-1] == 47
|
@options[:path_tst] += '/' unless @options[:path_tst][-1] == 47
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), 'colour_prompt'))
|
|
||||||
|
|
||||||
class UnityTestRunnerGenerator
|
class UnityTestRunnerGenerator
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
@options = UnityTestRunnerGenerator.default_options
|
@options = UnityTestRunnerGenerator.default_options
|
||||||
@@ -15,7 +13,7 @@ class UnityTestRunnerGenerator
|
|||||||
when Hash then @options.merge!(options)
|
when Hash then @options.merge!(options)
|
||||||
else raise 'If you specify arguments, it should be a filename or a hash of options'
|
else raise 'If you specify arguments, it should be a filename or a hash of options'
|
||||||
end
|
end
|
||||||
require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer"
|
require_relative 'type_sanitizer'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.default_options
|
def self.default_options
|
||||||
@@ -29,6 +27,7 @@ class UnityTestRunnerGenerator
|
|||||||
mock_suffix: '',
|
mock_suffix: '',
|
||||||
setup_name: 'setUp',
|
setup_name: 'setUp',
|
||||||
teardown_name: 'tearDown',
|
teardown_name: 'tearDown',
|
||||||
|
test_reset_name: 'resetTest',
|
||||||
main_name: 'main', # set to :auto to automatically generate each time
|
main_name: 'main', # set to :auto to automatically generate each time
|
||||||
main_export_decl: '',
|
main_export_decl: '',
|
||||||
cmdline_args: false,
|
cmdline_args: false,
|
||||||
@@ -92,16 +91,29 @@ class UnityTestRunnerGenerator
|
|||||||
def find_tests(source)
|
def find_tests(source)
|
||||||
tests_and_line_numbers = []
|
tests_and_line_numbers = []
|
||||||
|
|
||||||
|
# contains characters which will be substituted from within strings, doing
|
||||||
|
# this prevents these characters from interferring with scrubbers
|
||||||
|
# @ is not a valid C character, so there should be no clashes with files genuinely containing these markers
|
||||||
|
substring_subs = { '{' => '@co@', '}' => '@cc@', ';' => '@ss@', '/' => '@fs@' }
|
||||||
|
substring_re = Regexp.union(substring_subs.keys)
|
||||||
|
substring_unsubs = substring_subs.invert # the inverse map will be used to fix the strings afterwords
|
||||||
|
substring_unsubs['@quote@'] = '\\"'
|
||||||
|
substring_unsubs['@apos@'] = '\\\''
|
||||||
|
substring_unre = Regexp.union(substring_unsubs.keys)
|
||||||
source_scrubbed = source.clone
|
source_scrubbed = source.clone
|
||||||
source_scrubbed = source_scrubbed.gsub(/"[^"\n]*"/, '') # remove things in strings
|
source_scrubbed = source_scrubbed.gsub(/\\"/, '@quote@') # hide escaped quotes to allow capture of the full string/char
|
||||||
|
source_scrubbed = source_scrubbed.gsub(/\\'/, '@apos@') # hide escaped apostrophes to allow capture of the full string/char
|
||||||
|
source_scrubbed = source_scrubbed.gsub(/("[^"\n]*")|('[^'\n]*')/) { |s| s.gsub(substring_re, substring_subs) } # temporarily hide problematic
|
||||||
|
# characters within strings
|
||||||
source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments
|
source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments
|
||||||
source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
|
source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
|
||||||
lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
||||||
| (;|\{|\}) /x) # Match ;, {, and } as end of lines
|
| (;|\{|\}) /x) # Match ;, {, and } as end of lines
|
||||||
|
.map { |line| line.gsub(substring_unre, substring_unsubs) } # unhide the problematic characters previously removed
|
||||||
|
|
||||||
lines.each_with_index do |line, _index|
|
lines.each_with_index do |line, _index|
|
||||||
# find tests
|
# find tests
|
||||||
next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/
|
next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m
|
||||||
arguments = Regexp.last_match(1)
|
arguments = Regexp.last_match(1)
|
||||||
name = Regexp.last_match(2)
|
name = Regexp.last_match(2)
|
||||||
call = Regexp.last_match(3)
|
call = Regexp.last_match(3)
|
||||||
@@ -165,10 +177,10 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts('#include "cmock.h"') unless mocks.empty?
|
output.puts('#include "cmock.h"') unless mocks.empty?
|
||||||
output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H')
|
output.puts('#ifndef UNITY_EXCLUDE_SETJMP_H')
|
||||||
output.puts('#include <setjmp.h>')
|
output.puts('#include <setjmp.h>')
|
||||||
output.puts("#endif")
|
output.puts('#endif')
|
||||||
output.puts('#include <stdio.h>')
|
output.puts('#include <stdio.h>')
|
||||||
if @options[:defines] && !@options[:defines].empty?
|
if @options[:defines] && !@options[:defines].empty?
|
||||||
@options[:defines].each { |d| output.puts("#define #{d}") }
|
@options[:defines].each { |d| output.puts("#ifndef #{d}\n#define #{d}\n#endif /* #{d} */") }
|
||||||
end
|
end
|
||||||
if @options[:header_file] && !@options[:header_file].empty?
|
if @options[:header_file] && !@options[:header_file].empty?
|
||||||
output.puts("#include \"#{File.basename(@options[:header_file])}\"")
|
output.puts("#include \"#{File.basename(@options[:header_file])}\"")
|
||||||
@@ -288,6 +300,7 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts(' Unity.CurrentTestLineNumber = TestLineNum; \\')
|
output.puts(' Unity.CurrentTestLineNumber = TestLineNum; \\')
|
||||||
output.puts(' if (UnityTestMatches()) { \\') if @options[:cmdline_args]
|
output.puts(' if (UnityTestMatches()) { \\') if @options[:cmdline_args]
|
||||||
output.puts(' Unity.NumberOfTests++; \\')
|
output.puts(' Unity.NumberOfTests++; \\')
|
||||||
|
output.puts(' UNITY_EXEC_TIME_START(); \\')
|
||||||
output.puts(' CMock_Init(); \\') unless used_mocks.empty?
|
output.puts(' CMock_Init(); \\') unless used_mocks.empty?
|
||||||
output.puts(' UNITY_CLR_DETAILS(); \\') unless used_mocks.empty?
|
output.puts(' UNITY_CLR_DETAILS(); \\') unless used_mocks.empty?
|
||||||
output.puts(' if (TEST_PROTECT()) \\')
|
output.puts(' if (TEST_PROTECT()) \\')
|
||||||
@@ -304,6 +317,7 @@ class UnityTestRunnerGenerator
|
|||||||
output.puts(' CMock_Verify(); \\') unless used_mocks.empty?
|
output.puts(' CMock_Verify(); \\') unless used_mocks.empty?
|
||||||
output.puts(' } \\')
|
output.puts(' } \\')
|
||||||
output.puts(' CMock_Destroy(); \\') unless used_mocks.empty?
|
output.puts(' CMock_Destroy(); \\') unless used_mocks.empty?
|
||||||
|
output.puts(' UNITY_EXEC_TIME_STOP(); \\')
|
||||||
output.puts(' UnityConcludeTest(); \\')
|
output.puts(' UnityConcludeTest(); \\')
|
||||||
output.puts(' } \\') if @options[:cmdline_args]
|
output.puts(' } \\') if @options[:cmdline_args]
|
||||||
output.puts("}\n")
|
output.puts("}\n")
|
||||||
@@ -311,8 +325,8 @@ class UnityTestRunnerGenerator
|
|||||||
|
|
||||||
def create_reset(output, used_mocks)
|
def create_reset(output, used_mocks)
|
||||||
output.puts("\n/*=======Test Reset Option=====*/")
|
output.puts("\n/*=======Test Reset Option=====*/")
|
||||||
output.puts('void resetTest(void);')
|
output.puts("void #{@options[:test_reset_name]}(void);")
|
||||||
output.puts('void resetTest(void)')
|
output.puts("void #{@options[:test_reset_name]}(void)")
|
||||||
output.puts('{')
|
output.puts('{')
|
||||||
output.puts(' CMock_Verify();') unless used_mocks.empty?
|
output.puts(' CMock_Verify();') unless used_mocks.empty?
|
||||||
output.puts(' CMock_Destroy();') unless used_mocks.empty?
|
output.puts(' CMock_Destroy();') unless used_mocks.empty?
|
||||||
@@ -379,7 +393,7 @@ class UnityTestRunnerGenerator
|
|||||||
end
|
end
|
||||||
output.puts
|
output.puts
|
||||||
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
|
output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
|
||||||
output.puts(" return suite_teardown(UnityEnd());")
|
output.puts(' return suite_teardown(UnityEnd());')
|
||||||
output.puts('}')
|
output.puts('}')
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -446,6 +460,7 @@ if $0 == __FILE__
|
|||||||
' --teardown_name="" - redefine tearDown func name to something else',
|
' --teardown_name="" - redefine tearDown func name to something else',
|
||||||
' --main_name="" - redefine main func name to something else',
|
' --main_name="" - redefine main func name to something else',
|
||||||
' --test_prefix="" - redefine test prefix from default test|spec|should',
|
' --test_prefix="" - redefine test prefix from default test|spec|should',
|
||||||
|
' --test_reset_name="" - redefine resetTest func name to something else',
|
||||||
' --suite_setup="" - code to execute for setup of entire suite',
|
' --suite_setup="" - code to execute for setup of entire suite',
|
||||||
' --suite_teardown="" - code to execute for teardown of entire suite',
|
' --suite_teardown="" - code to execute for teardown of entire suite',
|
||||||
' --use_param_tests=1 - enable parameterized tests (disabled by default)',
|
' --use_param_tests=1 - enable parameterized tests (disabled by default)',
|
||||||
@@ -457,4 +472,4 @@ if $0 == __FILE__
|
|||||||
ARGV[1] = ARGV[0].gsub('.c', '_Runner.c') unless ARGV[1]
|
ARGV[1] = ARGV[0].gsub('.c', '_Runner.c') unless ARGV[1]
|
||||||
|
|
||||||
UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1])
|
UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1])
|
||||||
end
|
end
|
||||||
@@ -210,7 +210,7 @@ class ParseOutput
|
|||||||
|
|
||||||
# Adjusts the os specific members according to the current path style
|
# Adjusts the os specific members according to the current path style
|
||||||
# (Windows or Unix based)
|
# (Windows or Unix based)
|
||||||
def set_os_specifics(line)
|
def detect_os_specifics(line)
|
||||||
if line.include? '\\'
|
if line.include? '\\'
|
||||||
# Windows X:\Y\Z
|
# Windows X:\Y\Z
|
||||||
@class_name_idx = 1
|
@class_name_idx = 1
|
||||||
@@ -254,43 +254,42 @@ class ParseOutput
|
|||||||
# TEST(<test_group, <test_file>) PASS
|
# TEST(<test_group, <test_file>) PASS
|
||||||
#
|
#
|
||||||
# Note: Where path is different on Unix vs Windows devices (Windows leads with a drive letter)!
|
# Note: Where path is different on Unix vs Windows devices (Windows leads with a drive letter)!
|
||||||
set_os_specifics(line)
|
detect_os_specifics(line)
|
||||||
line_array = line.split(':')
|
line_array = line.split(':')
|
||||||
|
|
||||||
# If we were able to split the line then we can look to see if any of our target words
|
# 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.
|
# were found. Case is important.
|
||||||
if (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
next unless (line_array.size >= 4) || (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
||||||
|
|
||||||
# check if the output is fixture output (with verbose flag "-v")
|
# check if the output is fixture output (with verbose flag "-v")
|
||||||
if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
if (line.start_with? 'TEST(') || (line.start_with? 'IGNORE_TEST(')
|
||||||
line_array = prepare_fixture_line(line)
|
line_array = prepare_fixture_line(line)
|
||||||
if line.include? ' PASS'
|
if line.include? ' PASS'
|
||||||
test_passed_unity_fixture(line_array)
|
test_passed_unity_fixture(line_array)
|
||||||
@test_passed += 1
|
|
||||||
elsif line.include? 'FAIL'
|
|
||||||
test_failed_unity_fixture(line_array)
|
|
||||||
@test_failed += 1
|
|
||||||
elsif line.include? 'IGNORE'
|
|
||||||
test_ignored_unity_fixture(line_array)
|
|
||||||
@test_ignored += 1
|
|
||||||
end
|
|
||||||
# normal output / fixture output (without verbose "-v")
|
|
||||||
elsif line.include? ':PASS'
|
|
||||||
test_passed(line_array)
|
|
||||||
@test_passed += 1
|
@test_passed += 1
|
||||||
elsif line.include? ':FAIL'
|
elsif line.include? 'FAIL'
|
||||||
test_failed(line_array)
|
test_failed_unity_fixture(line_array)
|
||||||
@test_failed += 1
|
@test_failed += 1
|
||||||
elsif line.include? ':IGNORE:'
|
elsif line.include? 'IGNORE'
|
||||||
test_ignored(line_array)
|
test_ignored_unity_fixture(line_array)
|
||||||
@test_ignored += 1
|
|
||||||
elsif line.include? ':IGNORE'
|
|
||||||
line_array.push('No reason given')
|
|
||||||
test_ignored(line_array)
|
|
||||||
@test_ignored += 1
|
@test_ignored += 1
|
||||||
end
|
end
|
||||||
@total_tests = @test_passed + @test_failed + @test_ignored
|
# normal output / fixture output (without verbose "-v")
|
||||||
|
elsif line.include? ':PASS'
|
||||||
|
test_passed(line_array)
|
||||||
|
@test_passed += 1
|
||||||
|
elsif line.include? ':FAIL'
|
||||||
|
test_failed(line_array)
|
||||||
|
@test_failed += 1
|
||||||
|
elsif line.include? ':IGNORE:'
|
||||||
|
test_ignored(line_array)
|
||||||
|
@test_ignored += 1
|
||||||
|
elsif line.include? ':IGNORE'
|
||||||
|
line_array.push('No reason given')
|
||||||
|
test_ignored(line_array)
|
||||||
|
@test_ignored += 1
|
||||||
end
|
end
|
||||||
|
@total_tests = @test_passed + @test_failed + @test_ignored
|
||||||
end
|
end
|
||||||
puts ''
|
puts ''
|
||||||
puts '=================== SUMMARY ====================='
|
puts '=================== SUMMARY ====================='
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class ArgvParser
|
|||||||
|
|
||||||
opts.parse!(args)
|
opts.parse!(args)
|
||||||
options
|
options
|
||||||
end # parse()
|
end
|
||||||
end # class OptparseExample
|
end
|
||||||
|
|
||||||
class UnityToJUnit
|
class UnityToJUnit
|
||||||
include FileUtils::Verbose
|
include FileUtils::Verbose
|
||||||
@@ -155,10 +155,6 @@ class UnityToJUnit
|
|||||||
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||||
end
|
end
|
||||||
|
|
||||||
def here
|
|
||||||
File.expand_path(File.dirname(__FILE__))
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def results_structure
|
def results_structure
|
||||||
@@ -221,9 +217,9 @@ class UnityToJUnit
|
|||||||
def write_suites_footer(stream)
|
def write_suites_footer(stream)
|
||||||
stream.puts '</testsuites>'
|
stream.puts '</testsuites>'
|
||||||
end
|
end
|
||||||
end # UnityToJUnit
|
end
|
||||||
|
|
||||||
if __FILE__ == $0
|
if $0 == __FILE__
|
||||||
# parse out the command options
|
# parse out the command options
|
||||||
options = ArgvParser.parse(ARGV)
|
options = ArgvParser.parse(ARGV)
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ module RakefileHelpers
|
|||||||
def initialize(all_files = false)
|
def initialize(all_files = false)
|
||||||
@all_files = all_files
|
@all_files = all_files
|
||||||
|
|
||||||
return false unless @all_files
|
return unless @all_files
|
||||||
return false unless File.exist?('test_file_filter.yml')
|
return unless File.exist?('test_file_filter.yml')
|
||||||
|
|
||||||
filters = YAML.load_file('test_file_filter.yml')
|
filters = YAML.load_file('test_file_filter.yml')
|
||||||
@all_files = filters[:all_files]
|
@all_files = filters[:all_files]
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ if __name__ == '__main__':
|
|||||||
targets_dir = sys.argv[1]
|
targets_dir = sys.argv[1]
|
||||||
else:
|
else:
|
||||||
targets_dir = './'
|
targets_dir = './'
|
||||||
targets = list(map(lambda x: x.replace('\\', '/'), glob(targets_dir + '*.test*')))
|
targets = list(map(lambda x: x.replace('\\', '/'), glob(targets_dir + '**/*.test*', recursive=True)))
|
||||||
if len(targets) == 0:
|
if len(targets) == 0:
|
||||||
raise Exception("No *.testpass or *.testfail files found in '%s'" % targets_dir)
|
raise Exception("No *.testpass or *.testfail files found in '%s'" % targets_dir)
|
||||||
uts.set_targets(targets)
|
uts.set_targets(targets)
|
||||||
|
|||||||
@@ -101,10 +101,6 @@ class UnityTestSummary
|
|||||||
raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
|
raise "Couldn't parse test results: #{summary}" unless summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
|
||||||
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
[Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i]
|
||||||
end
|
end
|
||||||
|
|
||||||
def here
|
|
||||||
File.expand_path(File.dirname(__FILE__))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
|
|||||||
@@ -391,7 +391,6 @@ of 7 - 13.
|
|||||||
|
|
||||||
##### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)`
|
##### `TEST_ASSERT_HEX64_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
|
||||||
### Structs and Strings
|
### Structs and Strings
|
||||||
|
|
||||||
##### `TEST_ASSERT_EQUAL_PTR (expected, actual)`
|
##### `TEST_ASSERT_EQUAL_PTR (expected, actual)`
|
||||||
@@ -466,6 +465,42 @@ match. Failure messages specify the array index of the failed comparison.
|
|||||||
|
|
||||||
`len` is the memory in bytes to be compared at each array element.
|
`len` is the memory in bytes to be compared at each array element.
|
||||||
|
|
||||||
|
### Integer Array Ranges (of all sizes)
|
||||||
|
|
||||||
|
These assertions verify that the `expected` array parameter is within +/- `delta`
|
||||||
|
(inclusive) of the `actual` array parameter. For example, if the expected value is
|
||||||
|
\[10, 12\] and the delta is 3 then the assertion will fail for any value
|
||||||
|
outside the range of \[7 - 13, 9 - 15\].
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_INT_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_INT8_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_INT16_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_INT32_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_INT64_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_UINT_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_UINT8_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_UINT16_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_UINT32_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_UINT64_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_HEX_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_HEX8_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_HEX16_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_HEX32_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
|
##### `TEST_ASSERT_HEX64_ARRAY_WITHIN (delta, expected, actual)`
|
||||||
|
|
||||||
### Each Equal (Arrays to Single Value)
|
### Each Equal (Arrays to Single Value)
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ That way, Unity will know to skip the inclusion of this file and you won't
|
|||||||
be left with a compiler error.
|
be left with a compiler error.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_EXCLUDE_STDINT_H
|
```C
|
||||||
|
#define UNITY_EXCLUDE_STDINT_H
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_EXCLUDE_LIMITS_H`
|
##### `UNITY_EXCLUDE_LIMITS_H`
|
||||||
@@ -76,8 +78,9 @@ that don't support `stdint.h` could include `limits.h` instead. If you don't
|
|||||||
want Unity to check this file either, define this to make it skip the inclusion.
|
want Unity to check this file either, define this to make it skip the inclusion.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_EXCLUDE_LIMITS_H
|
```C
|
||||||
|
#define UNITY_EXCLUDE_LIMITS_H
|
||||||
|
```
|
||||||
|
|
||||||
If you've disabled both of the automatic options above, you're going to have to
|
If you've disabled both of the automatic options above, you're going to have to
|
||||||
do the configuration yourself. Don't worry. Even this isn't too bad... there are
|
do the configuration yourself. Don't worry. Even this isn't too bad... there are
|
||||||
@@ -91,7 +94,9 @@ Define this to be the number of bits an `int` takes up on your system. The
|
|||||||
default, if not autodetected, is 32 bits.
|
default, if not autodetected, is 32 bits.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_INT_WIDTH 16
|
```C
|
||||||
|
#define UNITY_INT_WIDTH 16
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_LONG_WIDTH`
|
##### `UNITY_LONG_WIDTH`
|
||||||
@@ -103,7 +108,9 @@ of 64-bit support your system can handle. Does it need to specify a `long` or a
|
|||||||
ignored.
|
ignored.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_LONG_WIDTH 16
|
```C
|
||||||
|
#define UNITY_LONG_WIDTH 16
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_POINTER_WIDTH`
|
##### `UNITY_POINTER_WIDTH`
|
||||||
@@ -113,7 +120,9 @@ default, if not autodetected, is 32-bits. If you're getting ugly compiler
|
|||||||
warnings about casting from pointers, this is the one to look at.
|
warnings about casting from pointers, this is the one to look at.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_POINTER_WIDTH 64
|
```C
|
||||||
|
#define UNITY_POINTER_WIDTH 64
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_SUPPORT_64`
|
##### `UNITY_SUPPORT_64`
|
||||||
@@ -125,7 +134,9 @@ can be a significant size and speed impact to enabling 64-bit support on small
|
|||||||
targets, so don't define it if you don't need it.
|
targets, so don't define it if you don't need it.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_SUPPORT_64
|
```C
|
||||||
|
#define UNITY_SUPPORT_64
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Floating Point Types
|
### Floating Point Types
|
||||||
@@ -153,10 +164,11 @@ suits your needs. For features that are enabled, the following floating point
|
|||||||
options also become available.
|
options also become available.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
|
```C
|
||||||
//what manner of strange processor is this?
|
//what manner of strange processor is this?
|
||||||
#define UNITY_EXCLUDE_FLOAT
|
#define UNITY_EXCLUDE_FLOAT
|
||||||
#define UNITY_INCLUDE_DOUBLE
|
#define UNITY_INCLUDE_DOUBLE
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_EXCLUDE_FLOAT_PRINT`
|
##### `UNITY_EXCLUDE_FLOAT_PRINT`
|
||||||
@@ -172,7 +184,9 @@ can use this define to instead respond to a failed assertion with a message like
|
|||||||
point assertions, use these options to give more explicit failure messages.
|
point assertions, use these options to give more explicit failure messages.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_EXCLUDE_FLOAT_PRINT
|
```C
|
||||||
|
#define UNITY_EXCLUDE_FLOAT_PRINT
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_FLOAT_TYPE`
|
##### `UNITY_FLOAT_TYPE`
|
||||||
@@ -182,7 +196,9 @@ floats. If your compiler supports a specialty floating point type, you can
|
|||||||
always override this behavior by using this definition.
|
always override this behavior by using this definition.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_FLOAT_TYPE float16_t
|
```C
|
||||||
|
#define UNITY_FLOAT_TYPE float16_t
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_DOUBLE_TYPE`
|
##### `UNITY_DOUBLE_TYPE`
|
||||||
@@ -194,7 +210,9 @@ could enable gargantuan floating point types on your 64-bit processor instead of
|
|||||||
the standard `double`.
|
the standard `double`.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_DOUBLE_TYPE long double
|
```C
|
||||||
|
#define UNITY_DOUBLE_TYPE long double
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_FLOAT_PRECISION`
|
##### `UNITY_FLOAT_PRECISION`
|
||||||
@@ -213,7 +231,62 @@ For further details on how this works, see the appendix of the Unity Assertion
|
|||||||
Guide.
|
Guide.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_FLOAT_PRECISION 0.001f
|
```C
|
||||||
|
#define UNITY_FLOAT_PRECISION 0.001f
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous
|
||||||
|
|
||||||
|
##### `UNITY_EXCLUDE_STDDEF_H`
|
||||||
|
|
||||||
|
Unity uses the `NULL` macro, which defines the value of a null pointer constant,
|
||||||
|
defined in `stddef.h` by default. If you want to provide
|
||||||
|
your own macro for this, you should exclude the `stddef.h` header file by adding this
|
||||||
|
define to your configuration.
|
||||||
|
|
||||||
|
_Example:_
|
||||||
|
```C
|
||||||
|
#define UNITY_EXCLUDE_STDDEF_H
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### `UNITY_INCLUDE_PRINT_FORMATTED`
|
||||||
|
|
||||||
|
Unity provides a simple (and very basic) printf-like string output implementation,
|
||||||
|
which is able to print a string modified by the following format string modifiers:
|
||||||
|
|
||||||
|
- __%d__ - signed value (decimal)
|
||||||
|
- __%i__ - same as __%i__
|
||||||
|
- __%u__ - unsigned value (decimal)
|
||||||
|
- __%f__ - float/Double (if float support is activated)
|
||||||
|
- __%g__ - same as __%f__
|
||||||
|
- __%b__ - binary prefixed with "0b"
|
||||||
|
- __%x__ - hexadecimal (upper case) prefixed with "0x"
|
||||||
|
- __%X__ - same as __%x__
|
||||||
|
- __%p__ - pointer (same as __%x__ or __%X__)
|
||||||
|
- __%c__ - a single character
|
||||||
|
- __%s__ - a string (e.g. "string")
|
||||||
|
- __%%__ - The "%" symbol (escaped)
|
||||||
|
|
||||||
|
_Example:_
|
||||||
|
```C
|
||||||
|
#define UNITY_INCLUDE_PRINT_FORMATTED
|
||||||
|
|
||||||
|
int a = 0xfab1;
|
||||||
|
UnityPrintFormatted("Decimal %d\n", -7);
|
||||||
|
UnityPrintFormatted("Unsigned %u\n", 987);
|
||||||
|
UnityPrintFormatted("Float %f\n", 3.1415926535897932384);
|
||||||
|
UnityPrintFormatted("Binary %b\n", 0xA);
|
||||||
|
UnityPrintFormatted("Hex %X\n", 0xFAB);
|
||||||
|
UnityPrintFormatted("Pointer %p\n", &a);
|
||||||
|
UnityPrintFormatted("Character %c\n", 'F');
|
||||||
|
UnityPrintFormatted("String %s\n", "My string");
|
||||||
|
UnityPrintFormatted("Percent %%\n");
|
||||||
|
UnityPrintFormatted("Color Red \033[41mFAIL\033[00m\n");
|
||||||
|
UnityPrintFormatted("\n");
|
||||||
|
UnityPrintFormatted("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Toolset Customization
|
### Toolset Customization
|
||||||
@@ -248,12 +321,14 @@ _Example:_
|
|||||||
Say you are forced to run your test suite on an embedded processor with no
|
Say you are forced to run your test suite on an embedded processor with no
|
||||||
`stdout` option. You decide to route your test result output to a custom serial
|
`stdout` option. You decide to route your test result output to a custom serial
|
||||||
`RS232_putc()` function you wrote like thus:
|
`RS232_putc()` function you wrote like thus:
|
||||||
#include "RS232_header.h"
|
```C
|
||||||
...
|
#include "RS232_header.h"
|
||||||
#define UNITY_OUTPUT_CHAR(a) RS232_putc(a)
|
...
|
||||||
#define UNITY_OUTPUT_START() RS232_config(115200,1,8,0)
|
#define UNITY_OUTPUT_CHAR(a) RS232_putc(a)
|
||||||
#define UNITY_OUTPUT_FLUSH() RS232_flush()
|
#define UNITY_OUTPUT_START() RS232_config(115200,1,8,0)
|
||||||
#define UNITY_OUTPUT_COMPLETE() RS232_close()
|
#define UNITY_OUTPUT_FLUSH() RS232_flush()
|
||||||
|
#define UNITY_OUTPUT_COMPLETE() RS232_close()
|
||||||
|
```
|
||||||
|
|
||||||
_Note:_
|
_Note:_
|
||||||
`UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by
|
`UNITY_OUTPUT_FLUSH()` can be set to the standard out flush function simply by
|
||||||
@@ -282,10 +357,12 @@ empty). You can also force Unity to NOT use weak functions by defining
|
|||||||
UNITY_NO_WEAK. The most common options for this feature are:
|
UNITY_NO_WEAK. The most common options for this feature are:
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_WEAK_ATTRIBUTE weak
|
```C
|
||||||
#define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
|
#define UNITY_WEAK_ATTRIBUTE weak
|
||||||
#define UNITY_WEAK_PRAGMA
|
#define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
|
||||||
#define UNITY_NO_WEAK
|
#define UNITY_WEAK_PRAGMA
|
||||||
|
#define UNITY_NO_WEAK
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_PTR_ATTRIBUTE`
|
##### `UNITY_PTR_ATTRIBUTE`
|
||||||
@@ -295,9 +372,10 @@ Some compilers require a custom attribute to be assigned to pointers, like
|
|||||||
defining this option with the attribute you would like.
|
defining this option with the attribute you would like.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_PTR_ATTRIBUTE __attribute__((far))
|
```C
|
||||||
#define UNITY_PTR_ATTRIBUTE near
|
#define UNITY_PTR_ATTRIBUTE __attribute__((far))
|
||||||
|
#define UNITY_PTR_ATTRIBUTE near
|
||||||
|
```
|
||||||
|
|
||||||
##### `UNITY_PRINT_EOL`
|
##### `UNITY_PRINT_EOL`
|
||||||
|
|
||||||
@@ -306,8 +384,9 @@ to parse by the scripts, by Ceedling, etc, but it might not be ideal for YOUR
|
|||||||
system. Feel free to override this and to make it whatever you wish.
|
system. Feel free to override this and to make it whatever you wish.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') }
|
```C
|
||||||
|
#define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\r'); UNITY_OUTPUT_CHAR('\n') }
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_EXCLUDE_DETAILS`
|
##### `UNITY_EXCLUDE_DETAILS`
|
||||||
@@ -319,8 +398,9 @@ report which function or argument flagged an error. If you're not using CMock an
|
|||||||
you're not using these details for other things, then you can exclude them.
|
you're not using these details for other things, then you can exclude them.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_EXCLUDE_DETAILS
|
```C
|
||||||
|
#define UNITY_EXCLUDE_DETAILS
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
##### `UNITY_EXCLUDE_SETJMP`
|
##### `UNITY_EXCLUDE_SETJMP`
|
||||||
@@ -333,15 +413,18 @@ compiler doesn't support setjmp, you wouldn't have had the memory space for thos
|
|||||||
things anyway, though... so this option exists for those situations.
|
things anyway, though... so this option exists for those situations.
|
||||||
|
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_EXCLUDE_SETJMP
|
```C
|
||||||
|
#define UNITY_EXCLUDE_SETJMP
|
||||||
|
```
|
||||||
|
|
||||||
##### `UNITY_OUTPUT_COLOR`
|
##### `UNITY_OUTPUT_COLOR`
|
||||||
|
|
||||||
If you want to add color using ANSI escape codes you can use this define.
|
If you want to add color using ANSI escape codes you can use this define.
|
||||||
t
|
t
|
||||||
_Example:_
|
_Example:_
|
||||||
#define UNITY_OUTPUT_COLOR
|
```C
|
||||||
|
#define UNITY_OUTPUT_COLOR
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Getting Into The Guts
|
## Getting Into The Guts
|
||||||
@@ -368,13 +451,15 @@ output of your test results.
|
|||||||
|
|
||||||
A simple main function looks something like this:
|
A simple main function looks something like this:
|
||||||
|
|
||||||
int main(void) {
|
```C
|
||||||
UNITY_BEGIN();
|
int main(void) {
|
||||||
RUN_TEST(test_TheFirst);
|
UNITY_BEGIN();
|
||||||
RUN_TEST(test_TheSecond);
|
RUN_TEST(test_TheFirst);
|
||||||
RUN_TEST(test_TheThird);
|
RUN_TEST(test_TheSecond);
|
||||||
return UNITY_END();
|
RUN_TEST(test_TheThird);
|
||||||
}
|
return UNITY_END();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
You can see that our main function doesn't bother taking any arguments. For our
|
You can see that our main function doesn't bother taking any arguments. For our
|
||||||
most barebones case, we'll never have arguments because we just run all the
|
most barebones case, we'll never have arguments because we just run all the
|
||||||
@@ -397,15 +482,17 @@ case function. This includes catching failures, calling the test module's
|
|||||||
using CMock or test coverage, there will be additional stubs in use here. A
|
using CMock or test coverage, there will be additional stubs in use here. A
|
||||||
simple minimalist RUN_TEST macro looks something like this:
|
simple minimalist RUN_TEST macro looks something like this:
|
||||||
|
|
||||||
#define RUN_TEST(testfunc) \
|
```C
|
||||||
UNITY_NEW_TEST(#testfunc) \
|
#define RUN_TEST(testfunc) \
|
||||||
if (TEST_PROTECT()) { \
|
UNITY_NEW_TEST(#testfunc) \
|
||||||
setUp(); \
|
if (TEST_PROTECT()) { \
|
||||||
testfunc(); \
|
setUp(); \
|
||||||
} \
|
testfunc(); \
|
||||||
if (TEST_PROTECT() && (!TEST_IS_IGNORED)) \
|
} \
|
||||||
tearDown(); \
|
if (TEST_PROTECT() && (!TEST_IS_IGNORED)) \
|
||||||
UnityConcludeTest();
|
tearDown(); \
|
||||||
|
UnityConcludeTest();
|
||||||
|
```
|
||||||
|
|
||||||
So that's quite a macro, huh? It gives you a glimpse of what kind of stuff Unity
|
So that's quite a macro, huh? It gives you a glimpse of what kind of stuff Unity
|
||||||
has to deal with for every single test case. For each test case, we declare that
|
has to deal with for every single test case. For each test case, we declare that
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
int Counter = 0;
|
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. */
|
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.
|
/* 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
|
* 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
|
* NumbersToFind is indexed from 1. Unfortunately it's broken
|
||||||
* (and should therefore be caught by our tests) */
|
* (and should therefore be caught by our tests) */
|
||||||
int FindFunction_WhichIsBroken(int NumberToFind)
|
int FindFunction_WhichIsBroken(int NumberToFind)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i <= 8) /* Notice I should have been in braces */
|
while (i < 8) /* Notice I should have been in braces */
|
||||||
i++;
|
i++;
|
||||||
if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */
|
if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */
|
||||||
return i;
|
return i;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* sometimes you may want to get at local data in a module.
|
/* 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
|
* for example: If you plan to pass by reference, this could be useful
|
||||||
* however, it should often be avoided */
|
* however, it should often be avoided */
|
||||||
extern int Counter;
|
extern int Counter;
|
||||||
|
|
||||||
void setUp(void)
|
void setUp(void)
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWork
|
|||||||
{
|
{
|
||||||
/* All of these should pass */
|
/* All of these should pass */
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1));
|
||||||
@@ -31,9 +31,9 @@ void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWil
|
|||||||
{
|
{
|
||||||
/* You should see this line fail in your test summary */
|
/* You should see this line fail in your test summary */
|
||||||
TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34));
|
TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34));
|
||||||
|
|
||||||
/* Notice the rest of these didn't get a chance to run because the line above failed.
|
/* 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.
|
* Unit tests abort each test function on the first sign of trouble.
|
||||||
* Then NEXT test function runs as normal. */
|
* Then NEXT test function runs as normal. */
|
||||||
TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888));
|
TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888));
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(v
|
|||||||
{
|
{
|
||||||
/* This should be true because setUp set this up for us before this test */
|
/* This should be true because setUp set this up for us before this test */
|
||||||
TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable());
|
TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable());
|
||||||
|
|
||||||
/* This should be true because we can still change our answer */
|
/* This should be true because we can still change our answer */
|
||||||
Counter = 0x1234;
|
Counter = 0x1234;
|
||||||
TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable());
|
TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable());
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ TEST(ProductionCode, FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInLis
|
|||||||
{
|
{
|
||||||
//All of these should pass
|
//All of these should pass
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(2));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(999));
|
||||||
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1));
|
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(-1));
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/../..'
|
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
require HERE + 'rakefile_helper'
|
require_relative 'rakefile_helper'
|
||||||
|
|
||||||
TEMP_DIRS = [
|
TEMP_DIRS = [
|
||||||
File.join(HERE, 'build')
|
File.join(__dir__, 'build')
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
TEMP_DIRS.each do |dir|
|
TEMP_DIRS.each do |dir|
|
||||||
@@ -32,8 +29,8 @@ task :summary do
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'Build and test Unity'
|
desc 'Build and test Unity'
|
||||||
task all: %i(clean unit summary)
|
task all: %i[clean unit summary]
|
||||||
task default: %i(clobber all)
|
task default: %i[clobber all]
|
||||||
task ci: [:default]
|
task ci: [:default]
|
||||||
task cruise: [:default]
|
task cruise: [:default]
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require UNITY_ROOT + '/auto/unity_test_summary'
|
require_relative '../../auto/unity_test_summary'
|
||||||
require UNITY_ROOT + '/auto/generate_test_runner'
|
require_relative '../../auto/generate_test_runner'
|
||||||
require UNITY_ROOT + '/auto/colour_reporter'
|
require_relative '../../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
@@ -149,7 +149,7 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.root = HERE
|
summary.root = __dir__
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Copied from ~Unity/targets/gcc_32.yml
|
# Copied from ~Unity/targets/gcc_32.yml
|
||||||
unity_root: &unity_root '../..'
|
unity_root: &unity_root '../..'
|
||||||
|
unity_source: &unity_source '../../src/'
|
||||||
compiler:
|
compiler:
|
||||||
path: gcc
|
path: gcc
|
||||||
source_path: 'src/'
|
source_path: &source_path 'src/'
|
||||||
unit_tests_path: &unit_tests_path 'test/'
|
unit_tests_path: &unit_tests_path 'test/'
|
||||||
build_path: &build_path 'build/'
|
build_path: &build_path 'build/'
|
||||||
options:
|
options:
|
||||||
@@ -15,8 +16,8 @@ compiler:
|
|||||||
includes:
|
includes:
|
||||||
prefix: '-I'
|
prefix: '-I'
|
||||||
items:
|
items:
|
||||||
- 'src/'
|
- *source_path
|
||||||
- '../../src/'
|
- *unity_source
|
||||||
- *unit_tests_path
|
- *unit_tests_path
|
||||||
defines:
|
defines:
|
||||||
prefix: '-D'
|
prefix: '-D'
|
||||||
|
|||||||
@@ -176,6 +176,22 @@
|
|||||||
/* #define UNITY_DOUBLE_PRECISION 0.001f */
|
/* #define UNITY_DOUBLE_PRECISION 0.001f */
|
||||||
|
|
||||||
|
|
||||||
|
/* *************************** MISCELLANEOUS ***********************************
|
||||||
|
* Miscellaneous configuration options for Unity
|
||||||
|
**************************************************************************** */
|
||||||
|
|
||||||
|
/* Unity uses the stddef.h header included in the C standard library for the
|
||||||
|
* "NULL" macro. Define this in order to disable the include of stddef.h. If you
|
||||||
|
* do this, you have to make sure to provide your own "NULL" definition.
|
||||||
|
*/
|
||||||
|
/* #define UNITY_EXCLUDE_STDDEF_H */
|
||||||
|
|
||||||
|
/* Define this to enable the unity formatted print function:
|
||||||
|
* "UnityPrintFormatted"
|
||||||
|
*/
|
||||||
|
/* #define UNITY_INCLUDE_PRINT_FORMATTED */
|
||||||
|
|
||||||
|
|
||||||
/* *************************** TOOLSET CUSTOMIZATION ***************************
|
/* *************************** TOOLSET CUSTOMIZATION ***************************
|
||||||
* In addition to the options listed above, there are a number of other options
|
* In addition to the options listed above, there are a number of other options
|
||||||
* which will come in handy to customize Unity's behavior for your specific
|
* which will come in handy to customize Unity's behavior for your specific
|
||||||
|
|||||||
@@ -4,15 +4,13 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
HERE = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
require HERE + 'rakefile_helper'
|
require_relative 'rakefile_helper'
|
||||||
|
|
||||||
TEMP_DIRS = [
|
TEMP_DIRS = [
|
||||||
File.join(HERE, 'build')
|
File.join(__dir__, 'build')
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
TEMP_DIRS.each do |dir|
|
TEMP_DIRS.each do |dir|
|
||||||
@@ -33,10 +31,10 @@ task unit: [:prepare_for_tests] do
|
|||||||
end
|
end
|
||||||
|
|
||||||
desc 'Build and test Unity Framework'
|
desc 'Build and test Unity Framework'
|
||||||
task all: %i(clean unit)
|
task all: %i[clean unit]
|
||||||
task default: %i(clobber all)
|
task default: %i[clobber all]
|
||||||
task ci: %i(no_color default)
|
task ci: %i[no_color default]
|
||||||
task cruise: %i(no_color default)
|
task cruise: %i[no_color default]
|
||||||
|
|
||||||
desc 'Load configuration'
|
desc 'Load configuration'
|
||||||
task :config, :config_file do |_t, args|
|
task :config, :config_file do |_t, args|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require HERE + '../../auto/unity_test_summary'
|
require_relative '../../auto/unity_test_summary'
|
||||||
require HERE + '../../auto/generate_test_runner'
|
require_relative '../../auto/generate_test_runner'
|
||||||
require HERE + '../../auto/colour_reporter'
|
require_relative '../../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
@@ -16,7 +16,7 @@ module RakefileHelpers
|
|||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
return if $configured
|
return if $configured
|
||||||
|
|
||||||
$cfg_file = HERE + "../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
$cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
|
||||||
$cfg = YAML.load(File.read($cfg_file))
|
$cfg = YAML.load(File.read($cfg_file))
|
||||||
$colour_output = false unless $cfg['colour']
|
$colour_output = false unless $cfg['colour']
|
||||||
$configured = true if config_file != DEFAULT_CONFIG_FILE
|
$configured = true if config_file != DEFAULT_CONFIG_FILE
|
||||||
@@ -128,7 +128,7 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.root = HERE
|
summary.root = __dir__
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
@@ -145,9 +145,9 @@ module RakefileHelpers
|
|||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
|
|
||||||
# Get a list of all source files needed
|
# Get a list of all source files needed
|
||||||
src_files = Dir[HERE + 'src/*.c']
|
src_files = Dir["#{__dir__}/src/*.c"]
|
||||||
src_files += Dir[HERE + 'test/*.c']
|
src_files += Dir["#{__dir__}/test/*.c"]
|
||||||
src_files += Dir[HERE + 'test/main/*.c']
|
src_files += Dir["#{__dir__}/test/main/*.c"]
|
||||||
src_files << '../../src/unity.c'
|
src_files << '../../src/unity.c'
|
||||||
|
|
||||||
# Build object files
|
# Build object files
|
||||||
|
|||||||
@@ -419,7 +419,8 @@ void UnityConcludeFixtureTest(void)
|
|||||||
{
|
{
|
||||||
if (UnityFixture.Verbose)
|
if (UnityFixture.Verbose)
|
||||||
{
|
{
|
||||||
UnityPrint(" PASS");
|
UnityPrint(" ");
|
||||||
|
UnityPrint(UnityStrPass);
|
||||||
UNITY_EXEC_TIME_STOP();
|
UNITY_EXEC_TIME_STOP();
|
||||||
UNITY_PRINT_EXEC_TIME();
|
UNITY_PRINT_EXEC_TIME();
|
||||||
UNITY_PRINT_EOL();
|
UNITY_PRINT_EOL();
|
||||||
|
|||||||
627
src/unity.c
627
src/unity.c
File diff suppressed because it is too large
Load Diff
38
src/unity.h
38
src/unity.h
@@ -1,6 +1,6 @@
|
|||||||
/* ==========================================
|
/* ==========================================
|
||||||
Unity Project - A Test Framework for C
|
Unity Project - A Test Framework for C
|
||||||
Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
[Released under MIT License. Please refer to license.txt for details]
|
[Released under MIT License. Please refer to license.txt for details]
|
||||||
========================================== */
|
========================================== */
|
||||||
|
|
||||||
@@ -230,6 +230,24 @@ int suiteTearDown(int num_failures);
|
|||||||
#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_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)
|
#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Integer Array Ranges (of all sizes) */
|
||||||
|
#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
|
||||||
|
|
||||||
/* Structs and Strings */
|
/* Structs and Strings */
|
||||||
#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL)
|
#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_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL)
|
||||||
@@ -422,6 +440,24 @@ int suiteTearDown(int num_failures);
|
|||||||
#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_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))
|
#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Integer Array Ranges (of all sizes) */
|
||||||
|
#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
|
||||||
|
|
||||||
/* Structs and Strings */
|
/* 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_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_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* ==========================================
|
/* ==========================================
|
||||||
Unity Project - A Test Framework for C
|
Unity Project - A Test Framework for C
|
||||||
Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
[Released under MIT License. Please refer to license.txt for details]
|
[Released under MIT License. Please refer to license.txt for details]
|
||||||
========================================== */
|
========================================== */
|
||||||
|
|
||||||
@@ -19,6 +19,14 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef UNITY_EXCLUDE_STDDEF_H
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
|
||||||
|
#include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Unity Attempts to Auto-Detect Integer Types
|
/* Unity Attempts to Auto-Detect Integer Types
|
||||||
* Attempt 1: UINT_MAX, ULONG_MAX in <limits.h>, or default to 32 bits
|
* Attempt 1: UINT_MAX, ULONG_MAX in <limits.h>, or default to 32 bits
|
||||||
* Attempt 2: UINTPTR_MAX in <stdint.h>, or default to same size as long
|
* Attempt 2: UINTPTR_MAX in <stdint.h>, or default to same size as long
|
||||||
@@ -32,10 +40,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UNITY_EXCLUDE_TIME_H
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
/*-------------------------------------------------------
|
||||||
* Guess Widths If Not Specified
|
* Guess Widths If Not Specified
|
||||||
*-------------------------------------------------------*/
|
*-------------------------------------------------------*/
|
||||||
@@ -114,19 +118,21 @@
|
|||||||
* 64-bit Support
|
* 64-bit Support
|
||||||
*-------------------------------------------------------*/
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Auto-detect 64 Bit Support */
|
||||||
#ifndef UNITY_SUPPORT_64
|
#ifndef UNITY_SUPPORT_64
|
||||||
#if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64
|
#if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64
|
||||||
#define UNITY_SUPPORT_64
|
#define UNITY_SUPPORT_64
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 64-Bit Support Dependent Configuration */
|
||||||
#ifndef UNITY_SUPPORT_64
|
#ifndef UNITY_SUPPORT_64
|
||||||
/* No 64-bit Support */
|
/* No 64-bit Support */
|
||||||
typedef UNITY_UINT32 UNITY_UINT;
|
typedef UNITY_UINT32 UNITY_UINT;
|
||||||
typedef UNITY_INT32 UNITY_INT;
|
typedef UNITY_INT32 UNITY_INT;
|
||||||
|
#define UNITY_MAX_NIBBLES (8) /* Maximum number of nibbles in a UNITY_(U)INT */
|
||||||
#else
|
#else
|
||||||
|
/* 64-bit Support */
|
||||||
/* 64-bit Support */
|
|
||||||
#if (UNITY_LONG_WIDTH == 32)
|
#if (UNITY_LONG_WIDTH == 32)
|
||||||
typedef unsigned long long UNITY_UINT64;
|
typedef unsigned long long UNITY_UINT64;
|
||||||
typedef signed long long UNITY_INT64;
|
typedef signed long long UNITY_INT64;
|
||||||
@@ -138,7 +144,7 @@
|
|||||||
#endif
|
#endif
|
||||||
typedef UNITY_UINT64 UNITY_UINT;
|
typedef UNITY_UINT64 UNITY_UINT;
|
||||||
typedef UNITY_INT64 UNITY_INT;
|
typedef UNITY_INT64 UNITY_INT;
|
||||||
|
#define UNITY_MAX_NIBBLES (16) /* Maximum number of nibbles in a UNITY_(U)INT */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
/*-------------------------------------------------------
|
||||||
@@ -289,42 +295,67 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
|
|||||||
#define UNITY_OUTPUT_COMPLETE()
|
#define UNITY_OUTPUT_COMPLETE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UNITY_EXEC_TIME_RESET
|
|
||||||
#ifdef UNITY_INCLUDE_EXEC_TIME
|
#ifdef UNITY_INCLUDE_EXEC_TIME
|
||||||
#define UNITY_EXEC_TIME_RESET()\
|
#if !defined(UNITY_EXEC_TIME_START) && \
|
||||||
Unity.CurrentTestStartTime = 0;\
|
!defined(UNITY_EXEC_TIME_STOP) && \
|
||||||
Unity.CurrentTestStopTime = 0;
|
!defined(UNITY_PRINT_EXEC_TIME) && \
|
||||||
#else
|
!defined(UNITY_TIME_TYPE)
|
||||||
#define UNITY_EXEC_TIME_RESET()
|
/* If none any of these macros are defined then try to provide a default implementation */
|
||||||
#endif
|
|
||||||
|
#if defined(UNITY_CLOCK_MS)
|
||||||
|
/* This is a simple way to get a default implementation on platforms that support getting a millisecond counter */
|
||||||
|
#define UNITY_TIME_TYPE UNITY_UINT
|
||||||
|
#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS()
|
||||||
|
#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS()
|
||||||
|
#define UNITY_PRINT_EXEC_TIME() { \
|
||||||
|
UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \
|
||||||
|
UnityPrint(" ("); \
|
||||||
|
UnityPrintNumberUnsigned(execTimeMs); \
|
||||||
|
UnityPrint(" ms)"); \
|
||||||
|
}
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#include <time.h>
|
||||||
|
#define UNITY_TIME_TYPE clock_t
|
||||||
|
#define UNITY_GET_TIME(t) t = (clock_t)((clock() * 1000) / CLOCKS_PER_SEC)
|
||||||
|
#define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime)
|
||||||
|
#define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime)
|
||||||
|
#define UNITY_PRINT_EXEC_TIME() { \
|
||||||
|
UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \
|
||||||
|
UnityPrint(" ("); \
|
||||||
|
UnityPrintNumberUnsigned(execTimeMs); \
|
||||||
|
UnityPrint(" ms)"); \
|
||||||
|
}
|
||||||
|
#elif defined(__unix__)
|
||||||
|
#include <time.h>
|
||||||
|
#define UNITY_TIME_TYPE struct timespec
|
||||||
|
#define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t)
|
||||||
|
#define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime)
|
||||||
|
#define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime)
|
||||||
|
#define UNITY_PRINT_EXEC_TIME() { \
|
||||||
|
UNITY_UINT execTimeMs = ((Unity.CurrentTestStopTime.tv_sec - Unity.CurrentTestStartTime.tv_sec) * 1000L); \
|
||||||
|
execTimeMs += ((Unity.CurrentTestStopTime.tv_nsec - Unity.CurrentTestStartTime.tv_nsec) / 1000000L); \
|
||||||
|
UnityPrint(" ("); \
|
||||||
|
UnityPrintNumberUnsigned(execTimeMs); \
|
||||||
|
UnityPrint(" ms)"); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UNITY_EXEC_TIME_START
|
#ifndef UNITY_EXEC_TIME_START
|
||||||
#ifdef UNITY_INCLUDE_EXEC_TIME
|
#define UNITY_EXEC_TIME_START() do{}while(0)
|
||||||
#define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS();
|
|
||||||
#else
|
|
||||||
#define UNITY_EXEC_TIME_START()
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UNITY_EXEC_TIME_STOP
|
#ifndef UNITY_EXEC_TIME_STOP
|
||||||
#ifdef UNITY_INCLUDE_EXEC_TIME
|
#define UNITY_EXEC_TIME_STOP() do{}while(0)
|
||||||
#define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS();
|
|
||||||
#else
|
|
||||||
#define UNITY_EXEC_TIME_STOP()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef UNITY_TIME_TYPE
|
||||||
|
#define UNITY_TIME_TYPE UNITY_UINT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UNITY_PRINT_EXEC_TIME
|
#ifndef UNITY_PRINT_EXEC_TIME
|
||||||
#ifdef UNITY_INCLUDE_EXEC_TIME
|
#define UNITY_PRINT_EXEC_TIME() do{}while(0)
|
||||||
#define UNITY_PRINT_EXEC_TIME() \
|
|
||||||
UnityPrint(" (");\
|
|
||||||
UNITY_COUNTER_TYPE execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime);
|
|
||||||
UnityPrintNumberUnsigned(execTimeMs);\
|
|
||||||
UnityPrint(" ms)");
|
|
||||||
#else
|
|
||||||
#define UNITY_PRINT_EXEC_TIME()
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
/*-------------------------------------------------------
|
||||||
@@ -355,7 +386,6 @@ typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
|
|||||||
# undef UNITY_WEAK_PRAGMA
|
# undef UNITY_WEAK_PRAGMA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
/*-------------------------------------------------------
|
||||||
* Internal Structs Needed
|
* Internal Structs Needed
|
||||||
*-------------------------------------------------------*/
|
*-------------------------------------------------------*/
|
||||||
@@ -368,7 +398,7 @@ typedef void (*UnityTestFunction)(void);
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
UNITY_DISPLAY_STYLE_INT = sizeof(int)+ UNITY_DISPLAY_RANGE_INT,
|
UNITY_DISPLAY_STYLE_INT = sizeof(int) + UNITY_DISPLAY_RANGE_INT,
|
||||||
UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT,
|
UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT,
|
||||||
UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT,
|
UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT,
|
||||||
UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT,
|
UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT,
|
||||||
@@ -376,7 +406,7 @@ UNITY_DISPLAY_STYLE_INT = sizeof(int)+ UNITY_DISPLAY_RANGE_INT,
|
|||||||
UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT,
|
UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT,
|
UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT,
|
||||||
UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT,
|
UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT,
|
||||||
UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT,
|
UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT,
|
||||||
UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT,
|
UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT,
|
||||||
@@ -396,11 +426,13 @@ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT,
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
UNITY_EQUAL_TO = 1,
|
UNITY_WITHIN = 0x0,
|
||||||
UNITY_GREATER_THAN = 2,
|
UNITY_EQUAL_TO = 0x1,
|
||||||
UNITY_GREATER_OR_EQUAL = 2 + UNITY_EQUAL_TO,
|
UNITY_GREATER_THAN = 0x2,
|
||||||
UNITY_SMALLER_THAN = 4,
|
UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO,
|
||||||
UNITY_SMALLER_OR_EQUAL = 4 + UNITY_EQUAL_TO
|
UNITY_SMALLER_THAN = 0x4,
|
||||||
|
UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO,
|
||||||
|
UNITY_UNKNOWN
|
||||||
} UNITY_COMPARISON_T;
|
} UNITY_COMPARISON_T;
|
||||||
|
|
||||||
#ifndef UNITY_EXCLUDE_FLOAT
|
#ifndef UNITY_EXCLUDE_FLOAT
|
||||||
@@ -421,7 +453,8 @@ typedef enum UNITY_FLOAT_TRAIT
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
UNITY_ARRAY_TO_VAL = 0,
|
UNITY_ARRAY_TO_VAL = 0,
|
||||||
UNITY_ARRAY_TO_ARRAY
|
UNITY_ARRAY_TO_ARRAY,
|
||||||
|
UNITY_ARRAY_UNKNOWN
|
||||||
} UNITY_FLAGS_T;
|
} UNITY_FLAGS_T;
|
||||||
|
|
||||||
struct UNITY_STORAGE_T
|
struct UNITY_STORAGE_T
|
||||||
@@ -439,8 +472,8 @@ struct UNITY_STORAGE_T
|
|||||||
UNITY_COUNTER_TYPE CurrentTestFailed;
|
UNITY_COUNTER_TYPE CurrentTestFailed;
|
||||||
UNITY_COUNTER_TYPE CurrentTestIgnored;
|
UNITY_COUNTER_TYPE CurrentTestIgnored;
|
||||||
#ifdef UNITY_INCLUDE_EXEC_TIME
|
#ifdef UNITY_INCLUDE_EXEC_TIME
|
||||||
UNITY_COUNTER_TYPE CurrentTestStartTime;
|
UNITY_TIME_TYPE CurrentTestStartTime;
|
||||||
UNITY_COUNTER_TYPE CurrentTestStopTime;
|
UNITY_TIME_TYPE CurrentTestStopTime;
|
||||||
#endif
|
#endif
|
||||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||||
jmp_buf AbortFrame;
|
jmp_buf AbortFrame;
|
||||||
@@ -485,6 +518,11 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
|
|||||||
*-------------------------------------------------------*/
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
void UnityPrint(const char* string);
|
void UnityPrint(const char* string);
|
||||||
|
|
||||||
|
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
|
||||||
|
void UnityPrintFormatted(const char* format, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
void UnityPrintLen(const char* string, const UNITY_UINT32 length);
|
void UnityPrintLen(const char* string, const UNITY_UINT32 length);
|
||||||
void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number);
|
void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number);
|
||||||
void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style);
|
void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style);
|
||||||
@@ -564,9 +602,18 @@ void UnityAssertNumbersWithin(const UNITY_UINT delta,
|
|||||||
const UNITY_LINE_TYPE lineNumber,
|
const UNITY_LINE_TYPE lineNumber,
|
||||||
const UNITY_DISPLAY_STYLE_T style);
|
const UNITY_DISPLAY_STYLE_T style);
|
||||||
|
|
||||||
void UnityFail(const char* msg, const UNITY_LINE_TYPE line);
|
void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
|
||||||
|
UNITY_INTERNAL_PTR expected,
|
||||||
|
UNITY_INTERNAL_PTR actual,
|
||||||
|
const UNITY_UINT32 num_elements,
|
||||||
|
const char* msg,
|
||||||
|
const UNITY_LINE_TYPE lineNumber,
|
||||||
|
const UNITY_DISPLAY_STYLE_T style,
|
||||||
|
const UNITY_FLAGS_T flags);
|
||||||
|
|
||||||
void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line);
|
void UnityFail(const char* message, const UNITY_LINE_TYPE line);
|
||||||
|
|
||||||
|
void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);
|
||||||
|
|
||||||
#ifndef UNITY_EXCLUDE_FLOAT
|
#ifndef UNITY_EXCLUDE_FLOAT
|
||||||
void UnityAssertFloatsWithin(const UNITY_FLOAT delta,
|
void UnityAssertFloatsWithin(const UNITY_FLOAT delta,
|
||||||
@@ -624,6 +671,11 @@ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num);
|
|||||||
* Error Strings We Might Need
|
* Error Strings We Might Need
|
||||||
*-------------------------------------------------------*/
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
extern const char UnityStrOk[];
|
||||||
|
extern const char UnityStrPass[];
|
||||||
|
extern const char UnityStrFail[];
|
||||||
|
extern const char UnityStrIgnore[];
|
||||||
|
|
||||||
extern const char UnityStrErrFloat[];
|
extern const char UnityStrErrFloat[];
|
||||||
extern const char UnityStrErrDouble[];
|
extern const char UnityStrErrDouble[];
|
||||||
extern const char UnityStrErr64[];
|
extern const char UnityStrErr64[];
|
||||||
@@ -640,12 +692,6 @@ extern const char UnityStrErr64[];
|
|||||||
#define TEST_ABORT() return
|
#define TEST_ABORT() return
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef UNITY_EXCLUDE_TIME_H
|
|
||||||
#define UNITY_CLOCK_MS() (UNITY_COUNTER_TYPE)((clock() * 1000) / CLOCKS_PER_SEC)
|
|
||||||
#else
|
|
||||||
#define UNITY_CLOCK_MS()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */
|
/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */
|
||||||
#ifndef RUN_TEST
|
#ifndef RUN_TEST
|
||||||
#ifdef __STDC_VERSION__
|
#ifdef __STDC_VERSION__
|
||||||
@@ -780,6 +826,20 @@ int UnityTestMatches(void);
|
|||||||
#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16)
|
#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16)
|
||||||
#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32)
|
#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32)
|
||||||
|
|
||||||
|
|
||||||
|
#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
|
||||||
|
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER)
|
#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(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_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line))
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line))
|
#define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line))
|
||||||
@@ -822,9 +882,9 @@ int UnityTestMatches(void);
|
|||||||
#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY)
|
#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY)
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY)
|
#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY)
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY)
|
#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY)
|
||||||
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL)
|
#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL)
|
||||||
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL)
|
#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL)
|
||||||
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL)
|
#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL)
|
||||||
#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
|
#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
|
||||||
#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
|
#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
|
||||||
#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)
|
#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)
|
||||||
@@ -840,6 +900,9 @@ int UnityTestMatches(void);
|
|||||||
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
|
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
|
||||||
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
|
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
|
||||||
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)
|
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)
|
||||||
|
#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY)
|
||||||
|
#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY)
|
||||||
#else
|
#else
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
#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_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
@@ -862,6 +925,9 @@ int UnityTestMatches(void);
|
|||||||
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
|
#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
|
#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
|
#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef UNITY_EXCLUDE_FLOAT
|
#ifdef UNITY_EXCLUDE_FLOAT
|
||||||
@@ -906,10 +972,10 @@ int UnityTestMatches(void);
|
|||||||
#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_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)
|
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble)
|
||||||
#else
|
#else
|
||||||
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)line)
|
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line))
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual, (UNITY_LINE_TYPE)(line), message)
|
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message))
|
||||||
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_ARRAY)
|
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY)
|
||||||
#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_VAL)
|
#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL)
|
||||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF)
|
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF)
|
||||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF)
|
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF)
|
||||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN)
|
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Style/HashSyntax:
|
|||||||
EnforcedStyle: no_mixed_keys
|
EnforcedStyle: no_mixed_keys
|
||||||
|
|
||||||
# This is disabled because it seems to get confused over nested hashes
|
# This is disabled because it seems to get confused over nested hashes
|
||||||
Style/AlignHash:
|
Layout/AlignHash:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
EnforcedHashRocketStyle: table
|
EnforcedHashRocketStyle: table
|
||||||
EnforcedColonStyle: table
|
EnforcedColonStyle: table
|
||||||
|
|||||||
@@ -4,17 +4,16 @@
|
|||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
UNITY_ROOT = File.expand_path(File.dirname(__FILE__)) + '/'
|
|
||||||
$verbose = false
|
$verbose = false
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
require UNITY_ROOT + 'rakefile_helper'
|
require_relative 'rakefile_helper'
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
TEMP_DIRS = [
|
TEMP_DIRS = [
|
||||||
File.join(UNITY_ROOT, 'build'),
|
File.join(__dir__, 'build'),
|
||||||
File.join(UNITY_ROOT, 'sandbox')
|
File.join(__dir__, 'sandbox')
|
||||||
]
|
]
|
||||||
|
|
||||||
TEMP_DIRS.each do |dir|
|
TEMP_DIRS.each do |dir|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require UNITY_ROOT + '../auto/unity_test_summary'
|
require_relative '../auto/unity_test_summary'
|
||||||
require UNITY_ROOT + '../auto/generate_test_runner'
|
require_relative '../auto/generate_test_runner'
|
||||||
require UNITY_ROOT + '../auto/colour_reporter'
|
require_relative '../auto/colour_reporter'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
C_EXTENSION = '.c'.freeze
|
C_EXTENSION = '.c'.freeze
|
||||||
@@ -179,7 +179,7 @@ module RakefileHelpers
|
|||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.root = UNITY_ROOT
|
summary.root = __dir__
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
|
|||||||
@@ -46,6 +46,14 @@ void flushSpy(void) {}
|
|||||||
|
|
||||||
int SetToOneToFailInTearDown;
|
int SetToOneToFailInTearDown;
|
||||||
int SetToOneMeanWeAlreadyCheckedThisGuy;
|
int SetToOneMeanWeAlreadyCheckedThisGuy;
|
||||||
|
static unsigned NextExpectedStringIndex;
|
||||||
|
static unsigned NextExpectedCharIndex;
|
||||||
|
|
||||||
|
void suiteSetUp(void)
|
||||||
|
{
|
||||||
|
NextExpectedStringIndex = 0;
|
||||||
|
NextExpectedCharIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void setUp(void)
|
void setUp(void)
|
||||||
{
|
{
|
||||||
@@ -111,3 +119,56 @@ void test_NormalFailsStillWork(void)
|
|||||||
TEST_ASSERT_TRUE(0);
|
TEST_ASSERT_TRUE(0);
|
||||||
VERIFY_FAILS_END
|
VERIFY_FAILS_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(0, "abc")
|
||||||
|
TEST_CASE(1, "{")
|
||||||
|
TEST_CASE(2, "}")
|
||||||
|
TEST_CASE(3, ";")
|
||||||
|
TEST_CASE(4, "\"quoted\"")
|
||||||
|
void test_StringsArePreserved(unsigned index, const char * str)
|
||||||
|
{
|
||||||
|
static const char * const expected[] =
|
||||||
|
{
|
||||||
|
"abc",
|
||||||
|
"{",
|
||||||
|
"}",
|
||||||
|
";",
|
||||||
|
"\"quoted\""
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Ensure that no test cases are skipped by tracking the next expected index */
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(NextExpectedStringIndex, index);
|
||||||
|
TEST_ASSERT_LESS_THAN(sizeof(expected) / sizeof(expected[0]), index);
|
||||||
|
TEST_ASSERT_EQUAL_STRING(expected[index], str);
|
||||||
|
|
||||||
|
NextExpectedStringIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE(0, 'x')
|
||||||
|
TEST_CASE(1, '{')
|
||||||
|
TEST_CASE(2, '}')
|
||||||
|
TEST_CASE(3, ';')
|
||||||
|
TEST_CASE(4, '\'')
|
||||||
|
TEST_CASE(5, '"')
|
||||||
|
void test_CharsArePreserved(unsigned index, char c)
|
||||||
|
{
|
||||||
|
static const char expected[] =
|
||||||
|
{
|
||||||
|
'x',
|
||||||
|
'{',
|
||||||
|
'}',
|
||||||
|
';',
|
||||||
|
'\'',
|
||||||
|
'"'
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Ensure that no test cases are skipped by tracking the next expected index */
|
||||||
|
TEST_ASSERT_EQUAL_UINT32(NextExpectedCharIndex, index);
|
||||||
|
TEST_ASSERT_LESS_THAN(sizeof(expected) / sizeof(expected[0]), index);
|
||||||
|
TEST_ASSERT_EQUAL(expected[index], c);
|
||||||
|
|
||||||
|
NextExpectedCharIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user