1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 08:25:58 +01:00

103 Commits

Author SHA1 Message Date
Mark VanderVoord
0b899aec14 Fix conditional issue in generator script.
Bump version.
2021-01-26 08:59:27 -05:00
Mark VanderVoord
d8eb8414f4 Stop noticing my sublime files. ;) 2021-01-16 21:20:09 -05:00
Mark VanderVoord
05994f5061 Merge pull request #536 from ThrowTheSwitch/test/switch_to_actions
Attempt to get Actions Working
2021-01-16 21:05:49 -05:00
Mark VanderVoord
fcab680286 Ruby script cleanup.
Fix warnings.
Remove 32-bit tests from standard suite because they're not running on most platforms.
2021-01-16 21:03:18 -05:00
Mark VanderVoord
3c1c5338af Need to checkout.
Drop Slack support
2021-01-16 20:27:49 -05:00
Mark VanderVoord
9e7c259822 Do we need to be admin to install gems? 2021-01-16 20:19:29 -05:00
Mark VanderVoord
ce132da37f Merge pull request #535 from ThrowTheSwitch/test/switch_to_actions
Switch from Travis to Github Actions.
2021-01-16 20:15:22 -05:00
Mark VanderVoord
ffb51ecb7e Switch from Travis to Github Actions.
Update year in docs.
2021-01-16 20:05:20 -05:00
Mark VanderVoord
0b078cdb6e Merge pull request #533 from carsonalh/master
Fixed CMake install when compiled with extensions
2021-01-08 09:01:41 -05:00
Carson Holloway
53e1449f89 Fixed CMake install when compiled with extensions
This is a fix from the change I made in
`commit 418c1635f2f1bcd353b6fce23a16594c914047b8`
where I added options to compile unity with the `fixture` and `memory`
extensions:

In that version, Unity had been able to build, but there were some issues when
trying to install it. Namely, the CMake generator expressions were not
evaluated correctly, and it would try to install with a path that had
un-expanded generator commands in it, which would obviously fail and throw an
error. I've got a feeling that this is a bug with CMake, but for now the
workaround that worked in [this stackoverflow
post](https://stackoverflow.com/questions/51541678/nested-cmake-generator-expressions-are-only-partially-evaluated)
seemed to work here, as well.

Another issue with that commit was that it tried to include a
`unity_memory_internals.h` file, which did not exist. This has also been
resolved.
2021-01-08 10:34:38 +10:00
Mark VanderVoord
830f77f9ee Merge pull request #509 from alecoding/issue_507
Fix warning for issue #507
2021-01-07 18:08:51 -05:00
Mark VanderVoord
038dd81213 Merge pull request #520 from softwareinmotion/runner_mock_suffix
parse mock files correctly
2021-01-07 18:08:09 -05:00
Mark VanderVoord
99fb90a939 Merge pull request #522 from JuPrgn/master
Add guard TEST on test module template
2021-01-07 18:05:48 -05:00
Mark VanderVoord
b7469138a5 Merge pull request #530 from carsonalh/master
Added options to compile "fixture" and "memory" extensions in CMakeLists
2021-01-07 18:05:05 -05:00
Carson Holloway
418c1635f2 Added option to compile fixture and memory extensions in CMakeLists.txt 2020-12-20 12:58:11 +11:00
Mark VanderVoord
386c540510 Merge pull request #524 from sardior/exlude-details-compile-fix
Update unity.c
2020-10-12 08:36:48 -04:00
Robert Sławomir Kőműves
723b9fee53 Update unity.c
UNITY_EXCLUDE_DETAILS caused a compile error here due to UNITY_DETAIL{1,2}_NAME declaration already being skipped.
2020-10-08 00:55:47 +02:00
Julien PEYREGNE
76c3755fe3 Add guard TEST on test module template
With a test file guarded we can include this file on IDE project
(MPLAB X in my case) and compile without excluding test files.
Excluding test files on MPLAB X disable autocompletion and function
navigation.
2020-09-07 10:37:26 +02:00
Fabian Weik
c3afe99a77 parse mock files correctly 2020-08-27 13:21:45 +02:00
Mark VanderVoord
98045925af Merge pull request #514 from michaelbrockus/let_meson_handle_flags
Let meson handle flags
2020-08-06 06:37:48 -04:00
Michael Brockus
62d0e7d68e Update meson.build 2020-08-05 21:15:37 -07:00
Michael Brockus
52d5f59b72 Update meson.build 2020-08-05 21:13:06 -07:00
Mark VanderVoord
09acb0b64f Merge pull request #513 from carsonalh/msvcfix
Fix for MSVC compilation errors
2020-07-18 10:37:51 -04:00
Carson Holloway
e640949eb3 Patched compilation error for MSVC. 2020-07-18 21:59:55 +10:00
Carson Holloway
6fecc8eb38 Added MSVC options to CMakeLists.txt. 2020-07-18 21:58:54 +10:00
Carson Holloway
777ad17420 Added MSVC options to CMakeLists.txt. 2020-07-18 21:52:00 +10:00
Alessio Centazzo
8bbfe1f5ac Fix warning from issue #507
UnityFail() and UnityIgnore had the noreturn attribute with long jumps disabled
2020-06-06 08:07:57 -07:00
Mark VanderVoord
0126e4804c Merge pull request #504 from phyrwork/master
Fix TEST_ASSERT_BIT(S)_HIGH testing only lower 32-bits (Thanks @phyrwork !)
2020-05-26 08:04:03 -04:00
Connor Newton
b4b1994bd7 Fix TEST_ASSERT_BIT(S)_HIGH testing only lower 32-bits
The high/low bits masks for TEST_ASSERT_BIT(S)_HIGH/LOW are created
by casting 0/-1 to UNITY_UINT32. This isn't OK on 64-bit platforms
as it results in a high bits mask of 0x00000000ffffffff instead of
0xffffffffffffffff.

Cast 0/-1 to UNITY_UINT instead.
2020-05-26 12:58:14 +01:00
Mark VanderVoord
fedd1495c2 Merge pull request #503 from andred/master
unity: annotate noreturn APIs (fix Wsuggest-attribute=noreturn warnings)
2020-05-25 11:09:55 -04:00
André Draszik
a6a4e9766d unity: annotate noreturn APIs (fix Wsuggest-attribute=noreturn warnings)
GCC (& Clang) have the notion of pure and const functions [1],
where those attributes are intended to help the optimiser.

Annotate a few APIs here with the appropriate key words, which
also fixes Wsuggest-attribute=noreturn warning, which a
source base might have enabled:
Compiling unity.c...
.../src/unity.c: In function ‘UnityFail’:
.../src/unity.c:1759:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
 1759 | void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
      |      ^~~~~~~~~
.../src/unity.c: In function ‘UnityIgnore’:
.../src/unity.c:1796:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
 1796 | void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
      |      ^~~~~~~~~~~

[1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Signed-off-by: André Draszik <git@andred.net>
2020-05-25 15:49:47 +01:00
Mark VanderVoord
06a668579f Merge pull request #501 from andred/master
allow compilation with stricter warnings (Thanks @andred !)
2020-05-25 06:59:32 -04:00
André Draszik
9760c4f14f unity: fix Wswitch-enum warning
Compiling a source base / test with Wswitch-enum enabled, gives
the following warning:

../src/unity.c: In function ‘UnityAssertFloatSpecial’:
../src/unity.c:1092:5: warning: enumeration value ‘UNITY_FLOAT_INVALID_TRAIT’ not handled in switch [-Wswitch-enum]
 1092 |     switch (style)
      |     ^~~~~~

Fix by adding the missing value to the default (unhandled) case.

Signed-off-by: André Draszik <git@andred.net>
2020-05-25 08:58:37 +01:00
André Draszik
f5ff3504b5 auto/run_test: fix Wsign-compare warning
Compiling a source base / test with Wsign-compare enabled, gives
the following warning:

build/test/runners/test_system_runner.c: In function ‘run_test’:
build/test/runners/test_system_runner.c:62:35: warning: conversion to ‘UNITY_UINT’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
   62 |     Unity.CurrentTestLineNumber = line_num;
      |                                   ^~~~~~~~

Fix by updating the type in the function declaration.

Signed-off-by: André Draszik <git@andred.net>
2020-05-25 07:14:14 +01:00
Mark VanderVoord
b0032caca4 Merge pull request #499 from jsloth/bugfix/suiteTearDown
Fixed suiteTearDown not matching prototype
2020-05-04 16:09:30 -04:00
Jakob Olesen
dcb30731f8 Fixed suiteTearDown not matching prototype
Fixed suiteTearDown to match prototype in unity.h
2020-05-04 20:34:45 +02:00
Mark VanderVoord
77c394e975 Merge pull request #498 from AlariOis/master
c99 support for new RUN_TEST macro. Thanks @AlariOis !
2020-05-04 09:48:23 -04:00
Mark VanderVoord
87f382fbb2 Merge branch 'master' into master 2020-05-04 09:45:03 -04:00
Alari Õis
97f6d55256 c99 support for new RUN_TEST macro 2020-05-04 08:20:19 +03:00
Mark VanderVoord
cf949f45ca Bump Version 2020-05-03 16:03:07 -04:00
Mark VanderVoord
fd80d514ee Revert "More elegant RUN_TEST macro"
This reverts commit cdfb7e092c.
2020-05-03 08:57:21 -04:00
Mark VanderVoord
9f4b2251de Merge pull request #493 from VShilenkov/master
cmake: update CMake
2020-05-02 14:38:02 -04:00
Mark VanderVoord
c5413ce16b Merge pull request #497 from AlariOis/master
More elegant RUN_TEST macro
2020-05-02 14:36:03 -04:00
Alari Õis
cdfb7e092c More elegant RUN_TEST macro 2020-05-01 08:18:09 +03:00
Mark VanderVoord
ae8b98e80b Merge pull request #496 from AlariOis/master
Fixed typos in documentation
2020-04-25 08:55:07 -04:00
Alari Õis
ec31dfacad Fixed typos in documentation 2020-04-25 07:14:21 +03:00
Vitalii Shylienkov
a2af08c773 project: revert UNITY_VERSION_* to unity.h 2020-04-14 11:02:24 +02:00
Vitalii Shylienkov
b397a72e89 cmake: get version from meson 2020-04-13 13:08:18 +02:00
Vitalii Shylienkov
2a2a4d19c5 meson: supports version
- generate version header
2020-04-13 12:47:07 +02:00
Mark VanderVoord
a78e6c8566 Merge pull request #494 from jlindgren90/master
Wrap UNITY_TEST_ASSERT in a do ... while(0) block
2020-04-09 16:10:46 -04:00
John Lindgren
2485d49d13 Wrap UNITY_TEST_ASSERT in a do ... while(0) block
This ensures that constructions like the following work correctly:

  if(condition)
    TEST_ASSERT(a);
  else
    TEST_ASSERT(b);
2020-04-09 13:03:16 -04:00
Vitalii Shylienkov
d603ccdc3b cmake: update CMake 2020-04-09 13:58:45 +02:00
Mark VanderVoord
10fd84f02b Merge pull request #492 from farshield/fix_small_typo
Fix small typo
2020-03-28 13:34:31 -04:00
Gavriil Pascalau
ff479e9aa0 Fix small typo 2020-03-28 18:31:43 +01:00
mvandervoord
87d8de6d55 Disable osx tests because (1) they are slow and (2) the toolchain is old and crusty 2020-03-19 10:02:38 -04:00
mvandervoord
615cf2349e Update self-test parameters 2020-03-19 09:48:40 -04:00
mvandervoord
8c4ae7aacd clarification in docs (#468) 2020-03-18 15:19:35 -04:00
mvandervoord
2c3e75e859 Fixed issue #486 2020-03-17 20:38:11 -04:00
mvandervoord
371e062555 Fixed issue #480 - better protection against bad pattern matching. 2020-03-17 16:24:25 -04:00
mvandervoord
f61a7ea8e4 Fix Issue #479 (Thanks @cy18) 2020-03-17 16:12:08 -04:00
Mark VanderVoord
a67cb27dd4 Merge pull request #472 from jlindgren90/master
auto: Only create run_test() function if it's needed.
2020-03-17 15:35:47 -04:00
mvandervoord
99199515fd Update documentation.
Add UNITY_PRINT_TEST_CONTEXT (thanks @jlindgren90 !)
Replaces PR #473
2020-03-17 15:01:46 -04:00
mvandervoord
3e4dfec147 Add support for alternate forms of header and source files to test runner generator. This borrows heavily from #477 (Thanks @Tuc-an) but maintains the ability to sort files that don't need to be relinked. 2020-03-17 14:02:54 -04:00
mvandervoord
75754de04e more of the same. 2020-03-16 20:38:54 -04:00
mvandervoord
6e3ecbf92b Declare the test variable static 2020-03-16 20:26:10 -04:00
mvandervoord
d7a05a56df Working with very picky compilers. :) 2020-03-16 20:14:02 -04:00
Mark VanderVoord
6a86a83207 Merge pull request #487 from michaelbadcrumble/master
Cleaning Meson build support implementation.
2020-03-16 19:55:55 -04:00
mvandervoord
3ee46e3da3 Forgot EOL 2020-03-16 19:51:05 -04:00
mvandervoord
a58054b013 Update makefile to run tests. tweak broken tests. 2020-03-16 19:33:51 -04:00
mvandervoord
71e77ce6fb Added NOT-EQUAL int variants.
Organized Unit Tests
2020-03-16 18:45:40 -04:00
mvandervoord
bad429428d Add assertion for checking empty null-terminated arrays. This is particularly useful for check c strings. 2020-03-16 15:04:40 -04:00
Mark VanderVoord
5e9acef74f Merge pull request #488 from jvcdk/feature/test_printf
Feature/test printf
2020-02-18 10:02:41 -05:00
Jørn Villesen Christensen
22a047ebb5 Updated documentation and examples to reflect the TEST_PRINTF function. 2020-02-14 22:45:58 +01:00
Jørn Villesen Christensen
3da0b4652c Implement macro TEST_PRINTF: Works like TEST_MESSAGE, but with a format-string.
Depends on UnityPrintFormatted (define UNITY_INCLUDE_PRINT_FORMATTED).
UnityPrintFormatted has been renamed to UnityPrintF due to changes below.

API of UnityPrintFormatted has been changed (hence the rename), but end users
(developers) can use the TEST_PRINTF as an almost-drop-in replacement TEST_PRINTF
is compatible with the old UnityPrintFormatted API (see below).

The behaviour of UnityPrintF has also been changed:
  - Now it prefixes the outout with test location information Output is marked
    as INFO.
  - It adds an EOL.

Both behaviours adopted from other output functions.
2020-02-14 22:43:51 +01:00
Michael
3b80ba73fe add clang to CI file 2020-02-08 10:39:34 -08:00
Michael
8a3a31f7b3 clean up meson support 2020-02-08 10:30:43 -08:00
Mark VanderVoord
c101cfa7d2 Merge pull request #485 from korigod/test-range
Add TEST_RANGE to specify arg ranges in parameterized tests
2020-02-02 15:12:03 -05:00
Andrei Korigodskii
218fa2cbe8 Add TEST_RANGE to specify arg ranges in parameterized tests
TEST_RANGE([start, stop, step]) generates following runs of the test
function: test(start), test(start + step), ..., test(start + n * step),
where start + n * step <= stop. The step must be positive.

If the test function takes several arguments, the following syntax must be used:
TEST_RANGE([arg1_start, arg1_stop, arg1_step], ..., [argN_start, argN_stop, argN_step])

This addresses issues #53 and #144.

Reported-by: Alex Rodriguez <alejmrm@gmail.com>
Reported-by: Hiroaki Yamazoe <PastelParasol@gmail.com>
2020-02-02 22:28:21 +03:00
Mark VanderVoord
d0714178a8 Merge pull request #484 from mr-bat/patch-1
update copyright message
2020-01-27 13:05:29 +02:00
mr-bat
04858be38f update copyright message 2020-01-26 11:22:07 -08:00
Mark VanderVoord
622918a7df Merge pull request #476 from art-of-dom/module-char-scrub
sub in '_' for '-' in define and test name in module generator
2019-12-26 07:14:53 -05:00
Dom Postorivo
3b5b491860 sub in '_' for '-' in define and test name in module generator 2019-12-26 01:10:09 -05:00
Mark VanderVoord
e449210977 Merge pull request #475 from ThrowTheSwitch/refactor/self-test-cleanup
Refactor/self test cleanup
2019-12-15 14:49:27 -05:00
mvandervoord
f3b87bb91c another tweak to how we handle the ci vs local testing. 2019-12-15 14:36:59 -05:00
mvandervoord
e276e1a458 Swap order so that CI runs all the makefile tests... but local test:all skips them as mostly redundant and very platform specific. 2019-12-15 10:30:26 -05:00
mvandervoord
d271759bcd Merge branch 'master' into refactor/self-test-cleanup 2019-12-15 10:10:44 -05:00
mvandervoord
47b630391d Minor tweak to the way we load includes 2019-12-15 10:07:05 -05:00
mvandervoord
fb45e3010b the makefiles in the extras are in the test dirs. 2019-12-14 22:38:52 -05:00
mvandervoord
ef0cf704d9 Centralize all testing to the test folder instead of each subproject.
Trigger ALL tests when calling `rake test:all` instead of that being just the core tests.
2019-12-14 22:24:30 -05:00
mvandervoord
461c6b3978 Clean up ci tasks.
Get the files to use the build directory again.
2019-12-14 05:18:46 -05:00
mvandervoord
3f71d10b2e Refactor all yaml files for self-tests to fit Ceedling format for wider reuse.
Fix mistake in unity selftest without output spy running.
Namespace self-tests for consistency across ThrowTheSwitch projects (like being able to test:all)
Reduce clutter of NAMED self-tests in task list.
2019-12-13 20:38:42 -05:00
John Lindgren
f39c856a37 auto: Only create run_test() function if it's needed.
Also fix some whitespace consistency issues.
Use 2 newlines (not 1 or 3) before /*====Heading====*/ comments.
2019-12-12 12:53:49 -05:00
Mark VanderVoord
5e3fb620fb Merge pull request #470 from LinoMastro/help_msg
Implement an -h/--help flag for Unity Fixtures and add documentation
2019-12-11 14:54:04 -05:00
Mark VanderVoord
1d1de74153 Merge pull request #469 from LinoMastro/bug_fixes
Bug fixes
2019-12-09 06:39:13 -05:00
Lino Mastrodomenico
5c5773720f Implement an -h/--help flag for Unity Fixtures and add documentation 2019-12-09 00:25:28 +00:00
Lino Mastrodomenico
e59185cd8d Fix another access outside array bounds. 2019-12-08 22:34:47 +00:00
Lino Mastrodomenico
86caf7ec97 Fix access outside array bounds. 2019-12-08 22:32:18 +00:00
mvandervoord
e3132cdddd Change the way we ignore the default runner. 2019-12-05 13:51:55 -05:00
mvandervoord
c5c36ab29f Do NOT include the default test runner if a custom runner has been defined.
Cleanup some style issues.
2019-12-05 13:19:43 -05:00
Mark VanderVoord
2f79302d5c Merge pull request #465 from michaelbadcrumble/meson_support
Keep Meson support back to 0.50.0:
2019-12-04 06:02:32 -05:00
Michael Brockus
de1cb75e4c Keep Meson support back to version 0.50.0 2019-12-03 22:49:22 -08:00
Michael Brockus
3fb17f33e2 Update root meson.build 2019-12-03 22:45:37 -08:00
mvandervoord
e2682ae43a update (commented out) example of using WEAK (which is not supported any longer) 2019-11-12 18:26:15 -05:00
64 changed files with 11230 additions and 10373 deletions

32
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
---
# Continuous Integration Workflow: Test case suite run + validation build check
name: CI
# Controls when the action will run.
# Triggers the workflow on push or pull request events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# Job: Unit test suite
unit-tests:
name: "Unit Tests"
runs-on: ubuntu-latest
steps:
# Install Ruby Testing Tools
- name: Setup Ruby Testing Tools
run: |
sudo gem install rspec
sudo gem install rubocop -v 0.57.2
# Checks out repository under $GITHUB_WORKSPACE
- name: Checkout Latest Repo
uses: actions/checkout@v2
# Run Tests
- name: Run All Unit Tests
run: |
cd test && rake ci

2
.gitignore vendored
View File

@@ -9,3 +9,5 @@ examples/example_1/test1.out
examples/example_1/test2.out
examples/example_2/all_tests.out
examples/example_4/builddir
*.sublime-project
*.sublime-workspace

View File

@@ -1,32 +0,0 @@
language: c
matrix:
include:
- os: osx
compiler: clang
osx_image: xcode7.3
- os: linux
dist: trusty
compiler: gcc
before_install:
- 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
install:
- gem install rspec
- gem install rubocop -v 0.57.2
script:
- cd test && rake ci
- make -s
- make -s DEBUG=-m32 #32-bit architecture with 64-bit support
- make -s DEBUG=-m32 UNITY_SUPPORT_64= #32-bit build without 64-bit types
- make -s UNITY_INCLUDE_DOUBLE= # without double
- cd ../extras/fixture/test && rake ci
- make -s default noStdlibMalloc
- make -s C89
- cd ../../../extras/memory/test && rake ci
- make -s default noStdlibMalloc
- make -s C89
- cd ../../../examples/example_1 && make -s ci
- cd ../example_2 && make -s ci
- cd ../example_3 && rake

View File

@@ -8,24 +8,152 @@
# License: MIT #
# #
###################################################################################
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.12)
project(unity LANGUAGES C DESCRIPTION "C Unit testing framework.")
# Read src/unity.h file and get project version from it
set(UNITY_HEADER "src/unity.h")
add_subdirectory(src)
target_include_directories(unity
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:src>"
PRIVATE "src"
file(STRINGS "${UNITY_HEADER}" UNITY_HEADER_CONTENT
REGEX "^#define UNITY_VERSION_(MAJOR|MINOR|BUILD) +[0-9]+$"
)
add_library(unity::framework ALIAS unity)
set(UNITY_HEADER_VERSION_MAJOR 0)
set(UNITY_HEADER_VERSION_MINOR 0)
set(UNITY_HEADER_VERSION_BUILD 0)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION src)
install(EXPORT unityConfig DESTINATION share/unityConfig/cmake)
foreach(VERSION_LINE IN LISTS UNITY_HEADER_CONTENT)
foreach(VERSION_PART MAJOR MINOR BUILD)
string(CONCAT REGEX_STRING "#define UNITY_VERSION_"
"${VERSION_PART}"
" +([0-9]+)"
)
# This makes the project importable from the build directory
export(TARGETS unity FILE unityConfig.cmake)
if(VERSION_LINE MATCHES "${REGEX_STRING}")
set(UNITY_HEADER_VERSION_${VERSION_PART} "${CMAKE_MATCH_1}")
endif()
endforeach()
endforeach()
project(unity
VERSION ${UNITY_HEADER_VERSION_MAJOR}.${UNITY_HEADER_VERSION_MINOR}.${UNITY_HEADER_VERSION_BUILD}
LANGUAGES C
DESCRIPTION "C Unit testing framework."
)
# Options to Build With Extras -------------------------------------------------
option(UNITY_EXTENSION_FIXTURE "Compiles Unity with the \"fixture\" extension." OFF)
option(UNITY_EXTENSION_MEMORY "Compiles Unity with the \"memory\" extension." OFF)
set(UNITY_EXTENSION_FIXTURE_ENABLED $<BOOL:${UNITY_EXTENSION_FIXTURE}>)
set(UNITY_EXTENSION_MEMORY_ENABLED $<OR:${UNITY_EXTENSION_FIXTURE_ENABLED},$<BOOL:${UNITY_EXTENSION_MEMORY}>>)
if(${UNITY_EXTENSION_FIXTURE})
message(STATUS "Unity: Bulding with the fixture extension.")
endif()
if(${UNITY_EXTENSION_MEMORY})
message(STATUS "Unity: Bulding with the memory extension.")
endif()
# Main target ------------------------------------------------------------------
add_library(${PROJECT_NAME} STATIC)
add_library(${PROJECT_NAME}::framework ALIAS ${PROJECT_NAME})
# Includes ---------------------------------------------------------------------
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
target_sources(${PROJECT_NAME}
PRIVATE
src/unity.c
$<$<BOOL:${UNITY_EXTENSION_FIXTURE_ENABLED}>:extras/fixture/src/unity_fixture.c>
$<$<BOOL:${UNITY_EXTENSION_MEMORY_ENABLED}>:extras/memory/src/unity_memory.c>
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
$<BUILD_INTERFACE:$<$<BOOL:${UNITY_EXTENSION_MEMORY_ENABLED}>:${CMAKE_CURRENT_SOURCE_DIR}/extras/memory/src>>
$<BUILD_INTERFACE:$<$<BOOL:${UNITY_EXTENSION_FIXTURE_ENABLED}>:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src>>
)
set(${PROJECT_NAME}_PUBLIC_HEADERS
src/unity.h
src/unity_internals.h
$<$<BOOL:${UNITY_EXTENSION_FIXTURE_ENABLED}>:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src/unity_fixture.h>
$<$<BOOL:${UNITY_EXTENSION_FIXTURE_ENABLED}>:${CMAKE_CURRENT_SOURCE_DIR}/extras/fixture/src/unity_fixture_internals.h>
$<$<BOOL:${UNITY_EXTENSION_MEMORY_ENABLED}>:${CMAKE_CURRENT_SOURCE_DIR}/extras/memory/src/unity_memory.h>
)
set_target_properties(${PROJECT_NAME}
PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
C_EXTENSIONS OFF
PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HEADERS}"
EXPORT_NAME framework
)
target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<C_COMPILER_ID:Clang>:-Wcast-align
-Wcast-qual
-Wconversion
-Wexit-time-destructors
-Wglobal-constructors
-Wmissing-noreturn
-Wmissing-prototypes
-Wno-missing-braces
-Wold-style-cast
-Wshadow
-Wweak-vtables
-Werror
-Wall>
$<$<C_COMPILER_ID:GNU>:-Waddress
-Waggregate-return
-Wformat-nonliteral
-Wformat-security
-Wformat
-Winit-self
-Wmissing-declarations
-Wmissing-include-dirs
-Wno-multichar
-Wno-parentheses
-Wno-type-limits
-Wno-unused-parameter
-Wunreachable-code
-Wwrite-strings
-Wpointer-arith
-Werror
-Wall>
$<$<C_COMPILER_ID:MSVC>:/Wall>
)
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
## Target installation
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
COMPONENT library
)
## Target's cmake files: targets export
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
## Target's cmake files: config and version config for find_package()
install(FILES ${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) <year> 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
Copyright (c) <year> 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,8 +1,17 @@
Unity Test API
==============
Unity Test ![CI](https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg)
==========
__Copyright (c) 2007 - 2021 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
[![Unity Build Status](https://api.travis-ci.org/ThrowTheSwitch/Unity.png?branch=master)](https://travis-ci.org/ThrowTheSwitch/Unity)
__Copyright (c) 2007 - 2019 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
Welcome to the Unity Test Project, one of the main projects of ThrowTheSwitch.org. Unity Test is a
unit testing framework built for C, with a focus on working with embedded toolchains.
This project is made to test code targetting microcontrollers big and small. The core project is a
single C file and a pair of headers, allowing it to the added to your existing build setup without
too much headache. You may use any compiler you wish, and may use most existing build systems
including make, cmake, etc. If you'd like to leave the hard work to us, you might be interested
in Ceedling, a build tool also by ThrowTheSwitch.org.
If you're new to Unity, we encourage you to tour the [getting started guide](docs/UnityGettingStartedGuide.md)
Getting Started
===============
@@ -182,10 +191,10 @@ Memory Assertions
Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
standard types... but since it's a memory compare, you have to be careful that your data types are packed.
_MESSAGE
--------
\_MESSAGE
---------
you can append _MESSAGE to any of the macros to make them take an additional argument. This argument
you can append \_MESSAGE to any of the macros to make them take an additional argument. This argument
is a string that will be printed at the end of the failure strings. This is useful for specifying more
information about the problem.

View File

@@ -13,7 +13,9 @@ require 'fileutils'
require 'pathname'
# TEMPLATE_TST
TEMPLATE_TST ||= '#include "unity.h"
TEMPLATE_TST ||= '#ifdef TEST
#include "unity.h"
%2$s#include "%1$s.h"
@@ -25,10 +27,12 @@ void tearDown(void)
{
}
void test_%1$s_NeedToImplement(void)
void test_%4$s_NeedToImplement(void)
{
TEST_IGNORE_MESSAGE("Need to Implement %1$s");
}
#endif // TEST
'.freeze
# TEMPLATE_SRC
@@ -163,24 +167,23 @@ class UnityModuleGenerator
files
end
############################
def neutralize_filename(name, start_cap = true)
return name if name.empty?
name = name.split(/(?:\s+|_|(?=[A-Z][a-z]))|(?<=[a-z])(?=[A-Z])/).map { |v| v.capitalize }.join('_')
name = name[0].downcase + name[1..-1] unless start_cap
return name
end
############################
def create_filename(part1, part2 = '')
if part2.empty?
case (@options[:naming])
when 'bumpy' then part1
when 'camel' then part1
when 'snake' then part1.downcase
when 'caps' then part1.upcase
else part1
end
else
case (@options[:naming])
when 'bumpy' then part1 + part2
when 'camel' then part1 + part2
when 'snake' then part1.downcase + '_' + part2.downcase
when 'caps' then part1.upcase + '_' + part2.upcase
else part1 + '_' + part2
end
name = part2.empty? ? part1 : part1 + '_' + part2
case (@options[:naming])
when 'bumpy' then neutralize_filename(name,false).delete('_')
when 'camel' then neutralize_filename(name).delete('_')
when 'snake' then neutralize_filename(name).downcase
when 'caps' then neutralize_filename(name).upcase
else name
end
end
@@ -208,7 +211,8 @@ class UnityModuleGenerator
f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil?
f.write(file[:template] % [file[:name],
file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join,
file[:name].upcase])
file[:name].upcase.gsub(/-/, '_'),
file[:name].gsub(/-/, '_')])
end
if @options[:update_svn]
`svn add \"#{file[:path]}\"`

View File

@@ -42,7 +42,9 @@ class UnityTestRunnerGenerator
main_export_decl: '',
cmdline_args: false,
omit_begin_end: false,
use_param_tests: false
use_param_tests: false,
include_extensions: '(?:hpp|hh|H|h)',
source_extensions: '(?:cpp|cc|ino|C|c)'
}
end
@@ -92,7 +94,7 @@ class UnityTestRunnerGenerator
create_suite_setup(output)
create_suite_teardown(output)
create_reset(output)
create_run_test(output)
create_run_test(output) unless tests.empty?
create_args_wrappers(output, tests)
create_main(output, input_file, tests, used_mocks)
end
@@ -108,7 +110,7 @@ class UnityTestRunnerGenerator
tests_and_line_numbers = []
# contains characters which will be substituted from within strings, doing
# this prevents these characters from interferring with scrubbers
# this prevents these characters from interfering 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)
@@ -128,7 +130,7 @@ class UnityTestRunnerGenerator
lines.each_with_index do |line, _index|
# find tests
next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m
next unless line =~ /^((?:\s*(?:TEST_CASE|TEST_RANGE)\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/m
arguments = Regexp.last_match(1)
name = Regexp.last_match(2)
@@ -139,6 +141,20 @@ class UnityTestRunnerGenerator
if @options[:use_param_tests] && !arguments.empty?
args = []
arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] }
arguments.scan(/\s*TEST_RANGE\s*\((.*)\)\s*$/).flatten.each do |range_str|
args += range_str.scan(/\[(-?\d+.?\d*), *(-?\d+.?\d*), *(-?\d+.?\d*)\]/).map do |arg_values_str|
arg_values_str.map do |arg_value_str|
arg_value_str.include?('.') ? arg_value_str.to_f : arg_value_str.to_i
end
end.map do |arg_values|
(arg_values[0]..arg_values[1]).step(arg_values[2]).to_a
end.reduce do |result, arg_range_expanded|
result.product(arg_range_expanded)
end.map do |arg_combinations|
arg_combinations.flatten.join(', ')
end
end
end
tests_and_line_numbers << { test: name, args: args, call: call, params: params, line_number: 0 }
@@ -170,9 +186,9 @@ class UnityTestRunnerGenerator
# parse out includes
includes = {
local: source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten,
local: source.scan(/^\s*#include\s+\"\s*(.+\.#{@options[:include_extensions]})\s*\"/).flatten,
system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" },
linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+)\.[cC]\w*\s*\"/).flatten
linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+\.#{@options[:source_extensions]})\s*\"/).flatten
}
includes
end
@@ -181,7 +197,7 @@ class UnityTestRunnerGenerator
mock_headers = []
includes.each do |include_path|
include_file = File.basename(include_path)
mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}.*#{@options[:mock_suffix]}$/i
mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}.*#{@options[:mock_suffix]}\.h$/i
end
mock_headers
end
@@ -190,7 +206,7 @@ class UnityTestRunnerGenerator
@options[:has_setup] = source =~ /void\s+#{@options[:setup_name]}\s*\(/
@options[:has_teardown] = source =~ /void\s+#{@options[:teardown_name]}\s*\(/
@options[:has_suite_setup] ||= (source =~ /void\s+suiteSetUp\s*\(/)
@options[:has_suite_teardown] ||= (source =~ /void\s+suiteTearDown\s*\(/)
@options[:has_suite_teardown] ||= (source =~ /int\s+suiteTearDown\s*\(int\s+([a-zA-Z0-9_])+\s*\)/)
end
def create_header(output, mocks, testfile_includes = [])
@@ -205,14 +221,14 @@ class UnityTestRunnerGenerator
output.puts("#include \"#{File.basename(@options[:header_file])}\"")
else
@options[:includes].flatten.uniq.compact.each do |inc|
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}")
end
testfile_includes.each do |inc|
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}")
end
end
mocks.each do |mock|
output.puts("#include \"#{mock.gsub('.h', '')}.h\"")
output.puts("#include \"#{mock}\"")
end
output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
@@ -247,7 +263,7 @@ class UnityTestRunnerGenerator
output.puts(' GlobalOrderError = NULL;')
end
mocks = mock_headers.map { |mock| File.basename(mock) }
mocks = mock_headers.map { |mock| File.basename(mock, '.*') }
mocks.each do |mock|
mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
output.puts(" #{mock_clean}_Init();")
@@ -325,8 +341,8 @@ class UnityTestRunnerGenerator
def create_run_test(output)
require 'erb'
template = ERB.new(File.read(File.join(__dir__, 'run_test.erb')))
output.puts(template.result(binding))
template = ERB.new(File.read(File.join(__dir__, 'run_test.erb')), nil, '<>')
output.puts("\n" + template.result(binding))
end
def create_args_wrappers(output, tests)
@@ -346,7 +362,7 @@ class UnityTestRunnerGenerator
end
def create_main(output, filename, tests, used_mocks)
output.puts("\n\n/*=======MAIN=====*/")
output.puts("\n/*=======MAIN=====*/")
main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s
if @options[:cmdline_args]
if main_name != 'main'
@@ -410,7 +426,7 @@ class UnityTestRunnerGenerator
output.puts(' return suiteTearDown(UnityEnd());')
end
else
output.puts(' return UnityEnd();') if not @options[:omit_begin_end]
output.puts(' return UnityEnd();') unless @options[:omit_begin_end]
end
output.puts('}')
end
@@ -423,10 +439,10 @@ class UnityTestRunnerGenerator
output.puts("#include \"#{@options[:framework]}.h\"")
output.puts('#include "cmock.h"') unless used_mocks.empty?
@options[:includes].flatten.uniq.compact.each do |inc|
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}")
end
testfile_includes.each do |inc|
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc}\""}")
end
output.puts "\n"
tests.each do |test|
@@ -449,13 +465,13 @@ if $0 == __FILE__
when '-cexception'
options[:plugins] = [:cexception]
true
when /\.*\.ya?ml/
when /\.*\.ya?ml$/
options = UnityTestRunnerGenerator.grab_config(arg)
true
when /--(\w+)=\"?(.*)\"?/
options[Regexp.last_match(1).to_sym] = Regexp.last_match(2)
true
when /\.*\.h/
when /\.*\.(?:hpp|hh|H|h)$/
options[:includes] << arg
true
else false

View File

@@ -1,5 +1,5 @@
/*=======Test Runner Used To Run Each Test=====*/
static void run_test(UnityTestFunction func, const char* name, int line_num)
static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num)
{
Unity.CurrentTestName = name;
Unity.CurrentTestLineNumber = line_num;
@@ -16,13 +16,14 @@ static void run_test(UnityTestFunction func, const char* name, int line_num)
<% if @options[:plugins].include?(:cexception) %>
CEXCEPTION_T e;
Try {
<% end %>
<%= @options[:setup_name] %>();
func();
<% if @options[:plugins].include?(:cexception) %>
} Catch(e) {
TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!");
}
<% else %>
<%= @options[:setup_name] %>();
func();
<% end %>
}
if (TEST_PROTECT())

View File

@@ -67,18 +67,20 @@ to be well designed code.
The convention of assertion parameters generally follows this order:
TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} )
```
TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} )
```
The very simplest assertion possible uses only a single "actual" parameter (e.g.
The very simplest assertion possible uses only a single `actual` parameter (e.g.
a simple null check).
"Actual" is the value being tested and unlike the other parameters in an
assertion construction is the only parameter present in all assertion variants.
"Modifiers" are masks, ranges, bit flag specifiers, floating point deltas.
"Expected" is your expected value (duh) to compare to an "actual" value; it's
marked as an optional parameter because some assertions only need a single
"actual" parameter (e.g. null check).
"Size/count" refers to string lengths, number of array elements, etc.
- `Actual` is the value being tested and unlike the other parameters in an
assertion construction is the only parameter present in all assertion variants.
- `Modifiers` are masks, ranges, bit flag specifiers, floating point deltas.
- `Expected` is your expected value (duh) to compare to an `actual` value; it's
marked as an optional parameter because some assertions only need a single
`actual` parameter (e.g. null check).
- `Size/count` refers to string lengths, number of array elements, etc.
Many of Unity's assertions are clear duplications in that the same data type
is handled by several assertions. The differences among these are in how failure
@@ -98,11 +100,15 @@ the reference list below and add a string as the final parameter.
_Example:_
TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} )
```
TEST_ASSERT_X( {modifiers}, {expected}, actual, {size/count} )
```
becomes messageified like thus...
TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message )
```
TEST_ASSERT_X_MESSAGE( {modifiers}, {expected}, actual, {size/count}, message )
```
Notes:
- The `_MESSAGE` variants intentionally do not support `printf` style formatting
@@ -122,18 +128,21 @@ with the `_MESSAGE`variants of Unity's Asserts in that for pretty much any Unity
type assertion you can tack on `_ARRAY` and run assertions on an entire block of
memory.
```
TEST_ASSERT_EQUAL_TYPEX_ARRAY( expected, actual, {size/count} )
```
"Expected" is an array itself.
"Size/count" is one or two parameters necessary to establish the number of array
elements and perhaps the length of elements within the array.
- `Expected` is an array itself.
- `Size/count` is one or two parameters necessary to establish the number of array
elements and perhaps the length of elements within the array.
Notes:
- The `_MESSAGE` variant convention still applies here to array assertions. The
`_MESSAGE` variants of the `_ARRAY` assertions have names ending with
`_ARRAY_MESSAGE`.
- Assertions for handling arrays of floating point values are grouped with float
and double assertions (see immediately following section).
- The `_MESSAGE` variant convention still applies here to array assertions. The
`_MESSAGE` variants of the `_ARRAY` assertions have names ending with
`_ARRAY_MESSAGE`.
- Assertions for handling arrays of floating point values are grouped with float
and double assertions (see immediately following section).
### TEST_ASSERT_EACH_EQUAL_X Variants
@@ -142,19 +151,22 @@ Unity provides a collection of assertions for arrays containing a variety of
types which can be compared to a single value as well. These are documented in
the Each Equal section below. these are almost on par with the `_MESSAGE`
variants of Unity's Asserts in that for pretty much any Unity type assertion you
can inject _EACH_EQUAL and run assertions on an entire block of memory.
can inject `_EACH_EQUAL` and run assertions on an entire block of memory.
TEST_ASSERT_EACH_EQUAL_TYPEX( expected, actual, {size/count} )
```
TEST_ASSERT_EACH_EQUAL_TYPEX( expected, actual, {size/count} )
```
"Expected" is a single value to compare to.
"Actual" is an array where each element will be compared to the expected value.
"Size/count" is one of two parameters necessary to establish the number of array
elements and perhaps the length of elements within the array.
- `Expected` is a single value to compare to.
- `Actual` is an array where each element will be compared to the expected value.
- `Size/count` is one of two parameters necessary to establish the number of array
elements and perhaps the length of elements within the array.
Notes:
- The `_MESSAGE` variant convention still applies here to Each Equal assertions.
- Assertions for handling Each Equal of floating point values are grouped with
float and double assertions (see immediately following section).
- The `_MESSAGE` variant convention still applies here to Each Equal assertions.
- Assertions for handling Each Equal of floating point values are grouped with
float and double assertions (see immediately following section).
### Configuration
@@ -189,6 +201,7 @@ performing logic beyond a simple assertion. That is, in practice, `TEST_FAIL()`
will always be found inside a conditional code block.
_Examples:_
- Executing a state machine multiple times that increments a counter your test
code then verifies as a final step.
- Triggering an exception and verifying it (as in Try / Catch / Throw - see the
@@ -236,6 +249,15 @@ conditional statements.
##### `TEST_ASSERT_NOT_NULL (pointer)`
Verify if a pointer is or is not NULL.
##### `TEST_ASSERT_EMPTY (pointer)`
##### `TEST_ASSERT_NOT_EMPTY (pointer)`
Verify if the first element dereferenced from a pointer is or is not zero. This
is particularly useful for checking for empty (or non-empty) null-terminated
C strings, but can be just as easily used for other null-terminated arrays.
### Signed and Unsigned Integers (of all sizes)
@@ -327,59 +349,18 @@ Asserts the specified bit of the `actual` parameter is low.
These assertions verify that the `actual` parameter is less than or greater
than `threshold` (exclusive). For example, if the threshold value is 0 for the
greater than assertion will fail if it is 0 or less.
##### `TEST_ASSERT_GREATER_THAN (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT (threshold, actual)`
greater than assertion will fail if it is 0 or less. There are assertions for
all the various sizes of ints, as for the equality assertions. Some examples:
##### `TEST_ASSERT_GREATER_THAN_INT8 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_INT32 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT8 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_UINT32 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_HEX8 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_HEX16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_HEX32 (threshold, actual)`
##### `TEST_ASSERT_GREATER_THAN_CHAR (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT8 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT16 (threshold, actual)`
##### `TEST_ASSERT_GREATER_OR_EQUAL_INT16 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_INT32 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT (threshold, actual)`
##### `TEST_ASSERT_LESS_OR_EQUAL_UINT (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT8 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT16 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_UINT32 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_HEX8 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_HEX16 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_HEX32 (threshold, actual)`
##### `TEST_ASSERT_LESS_THAN_CHAR (threshold, actual)`
##### `TEST_ASSERT_NOT_EQUAL_UINT8 (threshold, actual)`
### Integer Ranges (of all sizes)

View File

@@ -39,6 +39,10 @@ toolchain's search paths). In this file, you will list definitions and macros
specific to your target. All you must do is define `UNITY_INCLUDE_CONFIG_H` and
Unity will rely on `unity_config.h` for any further definitions it may need.
Unfortunately, it doesn't usually work well to just #define these things in the
test itself. These defines need to take effect where ever unity.h is included.
This would be test test, the test runner (if you're generating one), and from
unity.c when it's compiled.
## The Options
@@ -282,18 +286,18 @@ _Example:_
#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);
TEST_PRINTF("Decimal %d\n", -7);
TEST_PRINTF("Unsigned %u\n", 987);
TEST_PRINTF("Float %f\n", 3.1415926535897932384);
TEST_PRINTF("Binary %b\n", 0xA);
TEST_PRINTF("Hex %X\n", 0xFAB);
TEST_PRINTF("Pointer %p\n", &a);
TEST_PRINTF("Character %c\n", 'F');
TEST_PRINTF("String %s\n", "My string");
TEST_PRINTF("Percent %%\n");
TEST_PRINTF("Color Red \033[41mFAIL\033[00m\n");
TEST_PRINTF("\n");
TEST_PRINTF("Multiple (%d) (%i) (%u) (%x)\n", -100, 0, 200, 0x12345);
```
@@ -350,7 +354,7 @@ specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required.
##### `UNITY_OUTPUT_FOR_QT_CREATOR`
When managing your own builds, it is often handy to have messages output in a format which is
recognized by your IDE. These are some standard formats which can be supported. If you're using
recognized by your IDE. These are some standard formats which can be supported. If you're using
Ceedling to manage your builds, it is better to stick with the standard format (leaving these
all undefined) and allow Ceedling to use its own decorators.
@@ -392,6 +396,24 @@ _Example:_
#define UNITY_EXCLUDE_DETAILS
```
##### `UNITY_PRINT_TEST_CONTEXT`
This option allows you to specify your own function to print additional context
as part of the error message when a test has failed. It can be useful if you
want to output some specific information about the state of the test at the point
of failure, and `UNITY_SET_DETAILS` isn't flexible enough for your needs.
_Example:_
```C
#define UNITY_PRINT_TEST_CONTEXT PrintIterationCount
extern int iteration_count;
void PrintIterationCount(void)
{
UnityPrintFormatted("At iteration #%d: ", iteration_count);
}
```
##### `UNITY_EXCLUDE_SETJMP`
@@ -441,12 +463,12 @@ will allow you to specify how Unity will treat these assertions.
#### `UNITY_SUPPORT_VARIADIC_MACROS`
This will force Unity to support variadic macros when using its own built-in
This will force Unity to support variadic macros when using its own built-in
RUN_TEST macro. This will rarely be necessary. Most often, Unity will automatically
detect if the compiler supports variadic macros by checking to see if it's C99+
compatible. In the event that the compiler supports variadic macros, but is primarily
C89 (ANSI), defining this option will allow you to use them. This option is also not
necessary when using Ceedling or the test runner generator script.
C89 (ANSI), defining this option will allow you to use them. This option is also not
necessary when using Ceedling or the test runner generator script.
## Getting Into The Guts

View File

@@ -48,7 +48,7 @@ ruby generate_test_runner.rb TestFile.c NameOfRunner.c
```
Alternatively, if you include only the test file parameter, the script will copy
the name of the test file and automatically append "_Runner" to the name of the
the name of the test file and automatically append `_Runner` to the name of the
generated file. The example immediately below will create TestFile_Runner.c.
```Shell
@@ -194,6 +194,18 @@ If you are using CMock, it is very likely that you are already passing an array
of plugins to CMock. You can just use the same array here. This script will just
ignore the plugins that don't require additional support.
##### `:include_extensions`
This option specifies the pattern for matching acceptable header file extensions.
By default it will accept hpp, hh, H, and h files. If you need a different combination
of files to search, update this from the default `'(?:hpp|hh|H|h)'`.
##### `:source_extensions`
This option specifies the pattern for matching acceptable source file extensions.
By default it will accept cpp, cc, C, c, and ino files. If you need a different combination
of files to search, update this from the default `'(?:cpp|cc|ino|C|c)'`.
### `unity_test_summary.rb`

View File

@@ -11,7 +11,7 @@ int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious a
int FindFunction_WhichIsBroken(int NumberToFind)
{
int i = 0;
while (i <= 8) //Notice I should have been in braces
while (i < 8) //Notice I should have been in braces
i++;
if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it!
return i;

View File

@@ -11,7 +11,7 @@ int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious a
int FindFunction_WhichIsBroken(int NumberToFind)
{
int i = 0;
while (i <= 8) //Notice I should have been in braces
while (i < 8) //Notice I should have been in braces
i++;
if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it!
return i;

View File

@@ -1,14 +1,9 @@
###################################################################################
# #
# NAME: meson.build #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
#
# build script written by : Michael Brockus.
# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams.
#
# license: MIT
#
project('example-4', 'c')
unity_dep = dependency('unity', fallback : ['unity', 'unity_dep'])

View File

@@ -1,14 +1,9 @@
###################################################################################
# #
# NAME: meson.build #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
#
# build script written by : Michael Brockus.
# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams.
#
# license: MIT
#
inc_dir = include_directories('.')
lib_list = {'a': ['ProductionCode.c' ], 'b': ['ProductionCode2.c']}

View File

@@ -1,12 +1,7 @@
###################################################################################
# #
# NAME: meson.build #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
#
# build script written by : Michael Brockus.
# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams.
#
# license: MIT
#
subdir('test_runners')

View File

@@ -1,16 +1,13 @@
###################################################################################
# #
# NAME: meson.build #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
cases = [['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c')],
['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')]]
#
# build script written by : Michael Brockus.
# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams.
#
# license: MIT
#
cases = [
['TestProductionCode_Runner.c', join_paths('..' ,'TestProductionCode.c' )],
['TestProductionCode2_Runner.c', join_paths('..' ,'TestProductionCode2.c')]
]
test('Running: 01-test-case', executable('01-test-case', cases[0], dependencies: [ a_dep, unity_dep ]))
test('Running: 02-test-case', executable('02-test-case', cases[1], dependencies: [ b_dep, unity_dep ]))

View File

@@ -186,8 +186,8 @@
*/
/* #define UNITY_EXCLUDE_STDDEF_H */
/* Define this to enable the unity formatted print function:
* "UnityPrintFormatted"
/* Define this to enable the unity formatted print macro:
* "TEST_PRINTF"
*/
/* #define UNITY_INCLUDE_PRINT_FORMATTED */
@@ -224,25 +224,6 @@
/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */
/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */
/* For some targets, Unity can make the otherwise required `setUp()` and
* `tearDown()` functions optional. This is a nice convenience for test writers
* since `setUp` and `tearDown` don't often actually _do_ anything. If you're
* using gcc or clang, this option is automatically defined for you. Other
* compilers can also support this behavior, if they support a C feature called
* weak functions. A weak function is a function that is compiled into your
* executable _unless_ a non-weak version of the same function is defined
* elsewhere. If a non-weak version is found, the weak version is ignored as if
* it never existed. If your compiler supports this feature, you can let Unity
* know by defining `UNITY_SUPPORT_WEAK` as the function attributes that would
* need to be applied to identify a function as weak. If your compiler lacks
* support for weak functions, you will always need to define `setUp` and
* `tearDown` functions (though they can be and often will be just empty). The
* most common options for this feature are:
*/
/* #define UNITY_SUPPORT_WEAK weak */
/* #define UNITY_SUPPORT_WEAK __attribute__((weak)) */
/* #define UNITY_NO_WEAK */
/* Some compilers require a custom attribute to be assigned to pointers, like
* `near` or `far`. In these cases, you can give Unity a safe default for these
* by defining this option with the attribute you would like.

View File

@@ -1,44 +0,0 @@
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require_relative 'rakefile_helper'
TEMP_DIRS = [
File.join(__dir__, 'build')
].freeze
TEMP_DIRS.each do |dir|
directory(dir)
CLOBBER.include(dir)
end
task prepare_for_tests: TEMP_DIRS
# Load default configuration, for now
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze
configure_toolchain(DEFAULT_CONFIG_FILE)
task unit: [:prepare_for_tests] do
run_tests
end
desc 'Build and test Unity Framework'
task all: %i[clean unit]
task default: %i[clobber all]
task ci: %i[no_color default]
task cruise: %i[no_color default]
desc 'Load configuration'
task :config, :config_file do |_t, args|
configure_toolchain(args[:config_file])
end
task :no_color do
$colour_output = false
end

View File

@@ -1,183 +0,0 @@
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require 'yaml'
require 'fileutils'
require 'rbconfig'
require_relative '../../auto/unity_test_summary'
require_relative '../../auto/generate_test_runner'
require_relative '../../auto/colour_reporter'
$is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
C_EXTENSION = '.c'.freeze
def load_configuration(config_file)
return if $configured
$cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
$cfg = YAML.load(File.read($cfg_file))
$colour_output = false unless $cfg['colour']
$configured = true if config_file != DEFAULT_CONFIG_FILE
end
def configure_clean
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
end
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
config_file += '.yml' unless config_file =~ /\.yml$/
config_file = config_file unless config_file =~ /[\\|\/]/
load_configuration(config_file)
configure_clean
end
def tackit(strings)
result = if strings.is_a?(Array)
"\"#{strings.join}\""
else
strings
end
result
end
def squash(prefix, items)
result = ''
items.each { |item| result += " #{prefix}#{tackit(item)}" }
result
end
def build_compiler_fields
command = tackit($cfg['compiler']['path'])
defines = if $cfg['compiler']['defines']['items'].nil?
''
else
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
end
options = squash('', $cfg['compiler']['options'])
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ command: command, defines: defines, options: options, includes: includes }
end
def compile(file, _defines = [])
compiler = build_compiler_fields
unity_include = $cfg['compiler']['includes']['prefix'] + '../../src'
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str)
end
def build_linker_fields
command = tackit($cfg['linker']['path'])
options = if $cfg['linker']['options'].nil?
''
else
squash('', $cfg['linker']['options'])
end
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
''
else
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ command: command, options: options, includes: includes }
end
def link_it(exe_name, obj_list)
linker = build_linker_fields
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join +
$cfg['linker']['bin_files']['prefix'] + ' ' +
$cfg['linker']['bin_files']['destination'] +
exe_name + $cfg['linker']['bin_files']['extension']
execute(cmd_str)
end
def build_simulator_fields
return nil if $cfg['simulator'].nil?
command = if $cfg['simulator']['path'].nil?
''
else
(tackit($cfg['simulator']['path']) + ' ')
end
pre_support = if $cfg['simulator']['pre_support'].nil?
''
else
squash('', $cfg['simulator']['pre_support'])
end
post_support = if $cfg['simulator']['post_support'].nil?
''
else
squash('', $cfg['simulator']['post_support'])
end
{ command: command, pre_support: pre_support, post_support: post_support }
end
def execute(command_string, verbose = true)
report command_string
output = `#{command_string}`.chomp
report(output) if verbose && !output.nil? && !output.empty?
raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0
output
end
def report_summary
summary = UnityTestSummary.new
summary.root = __dir__
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob.tr!('\\', '/')
results = Dir[results_glob]
summary.targets = results
summary.run
end
def run_tests
report 'Running Unity system tests...'
# Tack on TEST define for compiling unit tests
load_configuration($cfg_file)
test_defines = ['TEST']
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
$cfg['compiler']['defines']['items'] << "UNITY_FIXTURE_NO_EXTRAS"
# Get a list of all source files needed
src_files = Dir["#{__dir__}/src/*.c"]
src_files += Dir["#{__dir__}/test/*.c"]
src_files += Dir["#{__dir__}/test/main/*.c"]
src_files << '../../src/unity.c'
# Build object files
src_files.each { |f| compile(f, test_defines) }
obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
# Link the test executable
test_base = 'framework_test'
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
cmd_str = if simulator.nil?
executable + ' -v -r'
else
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str)
test_results = $cfg['compiler']['build_path'] + test_base
test_results += if output.match(/OK$/m).nil?
'.testfail'
else
'.testpass'
end
File.open(test_results, 'w') { |f| f.print output }
end

View File

@@ -15,3 +15,15 @@ Fixtures, by default, uses the Memory addon as well. This is to make it simple f
follow along with James' book. Using them together is completely optional. You may choose to use
Fixtures without Memory handling by defining `UNITY_FIXTURE_NO_EXTRAS`. It will then stop automatically
pulling in extras and leave you to do it as desired.
# Usage information
By default the test executables produced by Unity Fixtures run all tests once, but the behavior can
be configured with command-line flags. Run the test executable with the `--help` flag for more
information.
It's possible to add a custom line at the end of the help message, typically to point to
project-specific or company-specific unit test documentation. Define `UNITY_CUSTOM_HELP_MSG` to
provide a custom message, e.g.:
#define UNITY_CUSTOM_HELP_MSG "If any test fails see https://example.com/troubleshooting"

View File

@@ -192,7 +192,42 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
for (i = 1; i < argc; )
{
if (strcmp(argv[i], "-v") == 0)
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
{
/* Usage */
UnityPrint("Runs a series of unit tests.");
UNITY_PRINT_EOL();
UNITY_PRINT_EOL();
UnityPrint("When no flag is specified, all tests are run.");
UNITY_PRINT_EOL();
UNITY_PRINT_EOL();
UnityPrint("Optional flags:");
UNITY_PRINT_EOL();
UnityPrint(" -v Verbose output: show all tests executed even if they pass");
UNITY_PRINT_EOL();
UnityPrint(" -s Silent mode: minimal output showing only test failures");
UNITY_PRINT_EOL();
UnityPrint(" -g NAME Only run tests in groups that contain the string NAME");
UNITY_PRINT_EOL();
UnityPrint(" -n NAME Only run tests whose name contains the string NAME");
UNITY_PRINT_EOL();
UnityPrint(" -r NUMBER Repeatedly run all tests NUMBER times");
UNITY_PRINT_EOL();
UnityPrint(" -h, --help Display this help message");
UNITY_PRINT_EOL();
UNITY_PRINT_EOL();
#ifdef UNITY_CUSTOM_HELP_MSG
/* User-defined help message, e.g. to point to project-specific documentation */
UnityPrint(UNITY_CUSTOM_HELP_MSG);
UNITY_PRINT_EOL();
#else
/* Default help suffix if a custom one is not defined */
UnityPrint("More information about Unity: https://www.throwtheswitch.org/unity");
UNITY_PRINT_EOL();
#endif
return 1; /* Exit without running the tests */
}
else if (strcmp(argv[i], "-v") == 0)
{
UnityFixture.Verbose = 1;
i++;

View File

@@ -1,45 +0,0 @@
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require_relative 'rakefile_helper'
TEMP_DIRS = [
File.join(__dir__, 'build')
].freeze
TEMP_DIRS.each do |dir|
directory(dir)
CLOBBER.include(dir)
end
task prepare_for_tests: TEMP_DIRS
# Load default configuration, for now
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'.freeze
configure_toolchain(DEFAULT_CONFIG_FILE)
task unit: [:prepare_for_tests] do
run_tests(false)
run_tests(true)
end
desc 'Build and test Unity Framework'
task all: %i[clean unit]
task default: %i[clobber all]
task ci: %i[no_color default]
task cruise: %i[no_color default]
desc 'Load configuration'
task :config, :config_file do |_t, args|
configure_toolchain(args[:config_file])
end
task :no_color do
$colour_output = false
end

View File

@@ -1,187 +0,0 @@
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require 'yaml'
require 'fileutils'
require 'rbconfig'
require_relative '../../auto/unity_test_summary'
require_relative '../../auto/generate_test_runner'
require_relative '../../auto/colour_reporter'
$is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
C_EXTENSION = '.c'.freeze
def load_configuration(config_file)
return if $configured
$cfg_file = "#{__dir__}/../../test/targets/#{config_file}" unless config_file =~ /[\\|\/]/
$cfg = YAML.load(File.read($cfg_file))
$colour_output = false unless $cfg['colour']
$configured = true if config_file != DEFAULT_CONFIG_FILE
end
def configure_clean
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
end
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
config_file += '.yml' unless config_file =~ /\.yml$/
config_file = config_file unless config_file =~ /[\\|\/]/
load_configuration(config_file)
configure_clean
end
def tackit(strings)
result = if strings.is_a?(Array)
"\"#{strings.join}\""
else
strings
end
result
end
def squash(prefix, items)
result = ''
items.each { |item| result += " #{prefix}#{tackit(item)}" }
result
end
def build_compiler_fields
command = tackit($cfg['compiler']['path'])
defines = if $cfg['compiler']['defines']['items'].nil?
''
else
decl = if $is_windows
'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)'
else
'UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)'
end
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar'] + [decl])
end
options = squash('', $cfg['compiler']['options'])
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ command: command, defines: defines, options: options, includes: includes }
end
def compile(file, _defines = [])
compiler = build_compiler_fields
unity_include = $cfg['compiler']['includes']['prefix'] + '../../src'
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{unity_include} #{file} " \
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}" \
"#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str)
end
def build_linker_fields
command = tackit($cfg['linker']['path'])
options = if $cfg['linker']['options'].nil?
''
else
squash('', $cfg['linker']['options'])
end
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
''
else
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ command: command, options: options, includes: includes }
end
def link_it(exe_name, obj_list)
linker = build_linker_fields
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join +
$cfg['linker']['bin_files']['prefix'] + ' ' +
$cfg['linker']['bin_files']['destination'] +
exe_name + $cfg['linker']['bin_files']['extension']
execute(cmd_str)
end
def build_simulator_fields
return nil if $cfg['simulator'].nil?
command = if $cfg['simulator']['path'].nil?
''
else
(tackit($cfg['simulator']['path']) + ' ')
end
pre_support = if $cfg['simulator']['pre_support'].nil?
''
else
squash('', $cfg['simulator']['pre_support'])
end
post_support = if $cfg['simulator']['post_support'].nil?
''
else
squash('', $cfg['simulator']['post_support'])
end
{ command: command, pre_support: pre_support, post_support: post_support }
end
def execute(command_string, verbose = true)
report command_string
output = `#{command_string}`.chomp
report(output) if verbose && !output.nil? && !output.empty?
raise "Command failed. (Returned #{$?.exitstatus})" if $?.exitstatus != 0
output
end
def report_summary
summary = UnityTestSummary.new
summary.root = __dir__
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob.tr!('\\', '/')
results = Dir[results_glob]
summary.targets = results
summary.run
end
def run_tests(exclude_stdlib=false)
report 'Running Unity system tests...'
# Tack on TEST define for compiling unit tests
load_configuration($cfg_file)
test_defines = ['TEST']
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
$cfg['compiler']['defines']['items'] << 'UNITY_EXCLUDE_STDLIB_MALLOC' if exclude_stdlib
# Get a list of all source files needed
src_files = Dir["#{__dir__}/src/*.c"]
src_files += Dir["#{__dir__}/test/*.c"]
src_files << '../../src/unity.c'
# Build object files
src_files.each { |f| compile(f, test_defines) }
obj_list = src_files.map { |f| File.basename(f.ext($cfg['compiler']['object_files']['extension'])) }
# Link the test executable
test_base = 'framework_test'
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
cmd_str = if simulator.nil?
executable + ' -v -r'
else
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str)
test_results = $cfg['compiler']['build_path'] + test_base
test_results += if output.match(/OK$/m).nil?
'.testfail'
else
'.testpass'
end
File.open(test_results, 'w') { |f| f.print output }
end

View File

@@ -1,69 +1,14 @@
###################################################################################
# #
# NAME: meson.build #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
#
# build script written by : Michael Brockus.
# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams.
#
# license: MIT
#
project('unity', 'c',
license : 'MIT',
meson_version : '>=0.52.0',
default_options: [
'buildtype=minsize',
'optimization=3',
'warning_level=3',
'werror=true',
]
license: 'MIT',
meson_version: '>=0.53.0',
default_options: ['werror=true', 'c_std=c11']
)
lang = 'c'
cc = meson.get_compiler(lang)
##
#
# Meson: Add compiler flags
#
##
if cc.get_id() == 'clang'
add_project_arguments(cc.get_supported_arguments(
[
'-Wweak-vtables', '-Wexit-time-destructors',
'-Wglobal-constructors', '-Wmissing-noreturn'
]
), language: lang)
endif
if cc.get_argument_syntax() == 'gcc'
add_project_arguments(cc.get_supported_arguments(
[
'-Wformat', '-Waddress', '-Winit-self', '-Wno-multichar',
'-Wpointer-arith' , '-Wwrite-strings' ,
'-Wno-parentheses' , '-Wno-type-limits' ,
'-Wformat-security' , '-Wunreachable-code' ,
'-Waggregate-return' , '-Wformat-nonliteral' ,
'-Wmissing-prototypes' , '-Wold-style-definition' ,
'-Wmissing-declarations', '-Wmissing-include-dirs' ,
'-Wno-unused-parameter' , '-Wdeclaration-after-statement'
]
), language: lang)
endif
if cc.get_id() == 'msvc'
add_project_arguments(cc.get_supported_arguments(
[
'/w44265', '/w44061', '/w44062',
'/wd4018', '/wd4146', '/wd4244',
'/wd4305',
]
), language: lang)
endif
subdir('src')
unity_dep = declare_dependency(link_with: unity_lib, include_directories: unity_dir)

View File

@@ -1,22 +0,0 @@
###################################################################################
# #
# NAME: CMakeLists.txt #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
add_library(unity STATIC "unity.c")
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}")

View File

@@ -1,16 +1,11 @@
###################################################################################
# #
# NAME: meson.build #
# #
# AUTHOR: Mike Karlesky, Mark VanderVoord, Greg Williams. #
# WRITTEN BY: Michael Brockus. #
# #
# License: MIT #
# #
###################################################################################
#
# build script written by : Michael Brockus.
# github repo author: Mike Karlesky, Mark VanderVoord, Greg Williams.
#
# license: MIT
#
unity_dir = include_directories('.')
unity_lib = static_library(meson.project_name(),
sources: ['unity.c'],
files('unity.c'),
include_directories: unity_dir)

View File

@@ -1,6 +1,6 @@
/* =========================================================================
Unity Project - A Test Framework for C
Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams
Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
============================================================================ */
@@ -21,7 +21,7 @@ void UNITY_OUTPUT_CHAR(int);
/* Helpful macros for us to use here in Assert functions */
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); }
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); }
#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return
#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT()
struct UNITY_STORAGE_T Unity;
@@ -43,6 +43,7 @@ static const char PROGMEM UnityStrWas[] = " Was ";
static const char PROGMEM UnityStrGt[] = " to be greater than ";
static const char PROGMEM UnityStrLt[] = " to be less than ";
static const char PROGMEM UnityStrOrEqual[] = "or equal to ";
static const char PROGMEM UnityStrNotEqual[] = " to be not equal to ";
static const char PROGMEM UnityStrElement[] = " Element ";
static const char PROGMEM UnityStrByte[] = " Byte ";
static const char PROGMEM UnityStrMemory[] = " Memory Mismatch.";
@@ -66,9 +67,10 @@ static const char PROGMEM UnityStrBreaker[] = "------------------
static const char PROGMEM UnityStrResultsTests[] = " Tests ";
static const char PROGMEM UnityStrResultsFailures[] = " Failures ";
static const char PROGMEM UnityStrResultsIgnored[] = " Ignored ";
#ifndef UNITY_EXCLUDE_DETAILS
static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
#endif
/*-----------------------------------------------
* Pretty Printers & Test Result Output Handlers
*-----------------------------------------------*/
@@ -146,121 +148,6 @@ void UnityPrint(const char* string)
}
}
}
/*-----------------------------------------------*/
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
void UnityPrintFormatted(const char* format, ...)
{
const char* pch = format;
va_list va;
va_start(va, format);
if (pch != NULL)
{
while (*pch)
{
/* format identification character */
if (*pch == '%')
{
pch++;
if (pch != NULL)
{
switch (*pch)
{
case 'd':
case 'i':
{
const int number = va_arg(va, int);
UnityPrintNumber((UNITY_INT)number);
break;
}
#ifndef UNITY_EXCLUDE_FLOAT_PRINT
case 'f':
case 'g':
{
const double number = va_arg(va, double);
UnityPrintFloat((UNITY_DOUBLE)number);
break;
}
#endif
case 'u':
{
const unsigned int number = va_arg(va, unsigned int);
UnityPrintNumberUnsigned((UNITY_UINT)number);
break;
}
case 'b':
{
const unsigned int number = va_arg(va, unsigned int);
const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1;
UNITY_OUTPUT_CHAR('0');
UNITY_OUTPUT_CHAR('b');
UnityPrintMask(mask, (UNITY_UINT)number);
break;
}
case 'x':
case 'X':
case 'p':
{
const unsigned int number = va_arg(va, unsigned int);
UNITY_OUTPUT_CHAR('0');
UNITY_OUTPUT_CHAR('x');
UnityPrintNumberHex((UNITY_UINT)number, 8);
break;
}
case 'c':
{
const int ch = va_arg(va, int);
UnityPrintChar((const char *)&ch);
break;
}
case 's':
{
const char * string = va_arg(va, const char *);
UnityPrint(string);
break;
}
case '%':
{
UnityPrintChar(pch);
break;
}
default:
{
/* print the unknown format character */
UNITY_OUTPUT_CHAR('%');
UnityPrintChar(pch);
break;
}
}
}
}
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
else if ((*pch == 27) && (*(pch + 1) == '['))
{
pch += UnityPrintAnsiEscapeString(pch);
continue;
}
#endif
else if (*pch == '\n')
{
UNITY_PRINT_EOL();
}
else
{
UnityPrintChar(pch);
}
pch++;
}
}
va_end(va);
}
#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */
/*-----------------------------------------------*/
void UnityPrintLen(const char* string, const UNITY_UINT32 length)
{
@@ -680,6 +567,10 @@ static void UnityAddMsgIfSpecified(const char* msg)
if (msg)
{
UnityPrint(UnityStrSpacer);
#ifdef UNITY_PRINT_TEST_CONTEXT
UNITY_PRINT_TEST_CONTEXT();
#endif
#ifndef UNITY_EXCLUDE_DETAILS
if (Unity.CurrentDetail1)
{
@@ -863,9 +754,10 @@ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold,
UnityTestResultsFailBegin(lineNumber);
UnityPrint(UnityStrExpected);
UnityPrintNumberByStyle(actual, style);
if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); }
if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); }
if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); }
if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); }
if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); }
if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); }
if (compare == UNITY_NOT_EQUAL) { UnityPrint(UnityStrNotEqual); }
UnityPrintNumberByStyle(threshold, style);
UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL;
@@ -1110,7 +1002,7 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual,
is_trait = !isinf(actual) && !isnan(actual);
break;
default:
default: /* including UNITY_FLOAT_INVALID_TRAIT */
trait_index = 0;
trait_names[0] = UnityStrInvalidFloatTrait;
break;
@@ -1250,7 +1142,7 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
is_trait = !isinf(actual) && !isnan(actual);
break;
default:
default: /* including UNITY_FLOAT_INVALID_TRAIT */
trait_index = 0;
trait_names[0] = UnityStrInvalidFloatTrait;
break;
@@ -1731,6 +1623,133 @@ UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num)
}
#endif
/*-----------------------------------------------
* printf helper function
*-----------------------------------------------*/
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
static void UnityPrintFVA(const char* format, va_list va)
{
const char* pch = format;
if (pch != NULL)
{
while (*pch)
{
/* format identification character */
if (*pch == '%')
{
pch++;
if (pch != NULL)
{
switch (*pch)
{
case 'd':
case 'i':
{
const int number = va_arg(va, int);
UnityPrintNumber((UNITY_INT)number);
break;
}
#ifndef UNITY_EXCLUDE_FLOAT_PRINT
case 'f':
case 'g':
{
const double number = va_arg(va, double);
UnityPrintFloat((UNITY_DOUBLE)number);
break;
}
#endif
case 'u':
{
const unsigned int number = va_arg(va, unsigned int);
UnityPrintNumberUnsigned((UNITY_UINT)number);
break;
}
case 'b':
{
const unsigned int number = va_arg(va, unsigned int);
const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1;
UNITY_OUTPUT_CHAR('0');
UNITY_OUTPUT_CHAR('b');
UnityPrintMask(mask, (UNITY_UINT)number);
break;
}
case 'x':
case 'X':
case 'p':
{
const unsigned int number = va_arg(va, unsigned int);
UNITY_OUTPUT_CHAR('0');
UNITY_OUTPUT_CHAR('x');
UnityPrintNumberHex((UNITY_UINT)number, 8);
break;
}
case 'c':
{
const int ch = va_arg(va, int);
UnityPrintChar((const char *)&ch);
break;
}
case 's':
{
const char * string = va_arg(va, const char *);
UnityPrint(string);
break;
}
case '%':
{
UnityPrintChar(pch);
break;
}
default:
{
/* print the unknown format character */
UNITY_OUTPUT_CHAR('%');
UnityPrintChar(pch);
break;
}
}
}
}
#ifdef UNITY_OUTPUT_COLOR
/* print ANSI escape code */
else if ((*pch == 27) && (*(pch + 1) == '['))
{
pch += UnityPrintAnsiEscapeString(pch);
continue;
}
#endif
else if (*pch == '\n')
{
UNITY_PRINT_EOL();
}
else
{
UnityPrintChar(pch);
}
pch++;
}
}
}
void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...)
{
UnityTestResultsBegin(Unity.TestFile, line);
UnityPrint("INFO");
if(format != NULL)
{
UnityPrint(": ");
va_list va;
va_start(va, format);
UnityPrintFVA(format, va);
va_end(va);
}
UNITY_PRINT_EOL();
}
#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */
/*-----------------------------------------------
* Control Functions
*-----------------------------------------------*/
@@ -1746,6 +1765,9 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
{
UNITY_OUTPUT_CHAR(':');
#ifdef UNITY_PRINT_TEST_CONTEXT
UNITY_PRINT_TEST_CONTEXT();
#endif
#ifndef UNITY_EXCLUDE_DETAILS
if (Unity.CurrentDetail1)
{
@@ -1800,6 +1822,8 @@ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line)
}
/*-----------------------------------------------*/
/* If we have not defined our own test runner, then include our default test runner to make life easier */
#ifndef UNITY_SKIP_DEFAULT_RUNNER
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
{
Unity.CurrentTestName = FuncName;
@@ -1819,6 +1843,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
UNITY_EXEC_TIME_STOP();
UnityConcludeTest();
}
#endif
/*-----------------------------------------------*/
void UnitySetTestFile(const char* filename)

View File

@@ -1,6 +1,6 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams
Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
@@ -10,7 +10,7 @@
#define UNITY_VERSION_MAJOR 2
#define UNITY_VERSION_MINOR 5
#define UNITY_VERSION_BUILD 0
#define UNITY_VERSION_BUILD 2
#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD)
#ifdef __cplusplus
@@ -104,6 +104,9 @@ void verifyTest(void);
#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL)
#define TEST_MESSAGE(message) UnityMessage((message), __LINE__)
#define TEST_ONLY()
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__)
#endif
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
@@ -125,6 +128,8 @@ void verifyTest(void);
#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE")
#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL")
#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL")
#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty")
#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty")
/* Integers (of all sizes) */
#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
@@ -145,10 +150,28 @@ void verifyTest(void);
#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL)
#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL)
#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL)
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL)
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL)
#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL)
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL)
/* Integer Not Equal To (of all sizes) */
#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
/* Integer Greater Than/ Less Than (of all sizes) */
#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
@@ -373,6 +396,8 @@ void verifyTest(void);
#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message))
#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message))
#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message))
#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message))
#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, (message))
/* Integers (of all sizes) */
#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
@@ -398,6 +423,25 @@ void verifyTest(void);
#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message))
#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message))
/* Integer Not Equal To (of all sizes) */
#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
/* Integer Greater Than/ Less Than (of all sizes) */
#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))

View File

@@ -1,6 +1,6 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007-19 Mike Karlesky, Mark VanderVoord, Greg Williams
Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
@@ -40,6 +40,12 @@
#include <limits.h>
#endif
#if defined __GNUC__
# define UNITY_FUNCTION_ATTR(a) __attribute__((a))
#else
# define UNITY_FUNCTION_ATTR(a) /* ignore */
#endif
/*-------------------------------------------------------
* Guess Widths If Not Specified
*-------------------------------------------------------*/
@@ -421,6 +427,7 @@ typedef enum
UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO,
UNITY_SMALLER_THAN = 0x4,
UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO,
UNITY_NOT_EQUAL = 0x0,
UNITY_UNKNOWN
} UNITY_COMPARISON_T;
@@ -479,7 +486,12 @@ void UnityBegin(const char* filename);
int UnityEnd(void);
void UnitySetTestFile(const char* filename);
void UnityConcludeTest(void);
#ifndef RUN_TEST
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
#else
#define UNITY_SKIP_DEFAULT_RUNNER
#endif
/*-------------------------------------------------------
* Details Support
@@ -503,6 +515,10 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
#endif
#endif
#ifdef UNITY_PRINT_TEST_CONTEXT
void UNITY_PRINT_TEST_CONTEXT(void);
#endif
/*-------------------------------------------------------
* Test Output
*-------------------------------------------------------*/
@@ -510,7 +526,7 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
void UnityPrint(const char* string);
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
void UnityPrintFormatted(const char* format, ...);
void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...);
#endif
void UnityPrintLen(const char* string, const UNITY_UINT32 length);
@@ -601,8 +617,14 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta,
const UNITY_DISPLAY_STYLE_T style,
const UNITY_FLAGS_T flags);
#ifndef UNITY_EXCLUDE_SETJMP_H
void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn);
void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn);
#else
void UnityFail(const char* message, const UNITY_LINE_TYPE line);
void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);
#endif
void UnityMessage(const char* message, const UNITY_LINE_TYPE line);
#ifndef UNITY_EXCLUDE_FLOAT
@@ -691,11 +713,8 @@ extern const char UnityStrErrShorthand[];
#endif
#endif
#ifdef UNITY_SUPPORT_VARIADIC_MACROS
#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__))
#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway)
#define RUN_TEST_FIRST_HELPER(first, ...) (first), #first
#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway)
#define RUN_TEST_SECOND_HELPER(first, second, ...) (second)
#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway)
#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line)
#endif
#endif
@@ -753,9 +772,11 @@ int UnityTestMatches(void);
* Test Asserts
*-------------------------------------------------------*/
#define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}
#define UNITY_TEST_ASSERT(condition, line, message) do {if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}} while(0)
#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (UNITY_LINE_TYPE)(line), (message))
#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8)
@@ -771,6 +792,19 @@ int UnityTestMatches(void);
#define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR)
#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line))
#define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8)
#define UNITY_TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16)
#define UNITY_TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32)
#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT)
#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8)
#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16)
#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32)
#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8)
#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16)
#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32)
#define UNITY_TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16)
@@ -900,6 +934,9 @@ int UnityTestMatches(void);
#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_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_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)
#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64)
#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64)
#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64)

View File

@@ -20,6 +20,14 @@ Style/HashSyntax:
EnforcedStyle: no_mixed_keys
Style/NumericPredicate:
Enabled: false
Style/MultilineBlockChain:
Enabled: false
Style/Alias:
Enabled: false
Style/EvalWithLocation:
Enabled: false
Style/MixinUsage:
Enabled: false
# These are also places we diverge... but we will likely comply down the road
Style/IfUnlessModifier:

View File

@@ -7,8 +7,10 @@ E = -Weverything
CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes
CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn
endif
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Wconversion -Werror
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros
CFLAGS += -Wno-switch-enum -Wno-double-promotion
CFLAGS += -Wno-poison-system-directories
CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \
-Wstrict-prototypes -Wswitch-default -Wundef
#DEBUG = -O0 -g
@@ -20,7 +22,14 @@ DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=putcharSpy\(int\)
DEFINES += -D UNITY_OUTPUT_FLUSH=flushSpy
DEFINES += -D UNITY_OUTPUT_FLUSH_HEADER_DECLARATION=flushSpy\(void\)
DEFINES += $(UNITY_SUPPORT_64) $(UNITY_INCLUDE_DOUBLE)
SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c
SRC1 = ../src/unity.c tests/test_unity_arrays.c build/test_unity_arraysRunner.c
SRC2 = ../src/unity.c tests/test_unity_core.c build/test_unity_coreRunner.c
SRC3 = ../src/unity.c tests/test_unity_doubles.c build/test_unity_doublesRunner.c
SRC4 = ../src/unity.c tests/test_unity_floats.c build/test_unity_floatsRunner.c
SRC5 = ../src/unity.c tests/test_unity_integers.c build/test_unity_integersRunner.c
SRC6 = ../src/unity.c tests/test_unity_integers_64.c build/test_unity_integers_64Runner.c
SRC7 = ../src/unity.c tests/test_unity_memory.c build/test_unity_memoryRunner.c
SRC8 = ../src/unity.c tests/test_unity_strings.c build/test_unity_stringsRunner.c
INC_DIR = -I ../src
COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src
BUILD_DIR = build
@@ -30,17 +39,80 @@ TARGET = build/testunity-cov.exe
# For verbose output of all the tests, run 'make test'.
default: coverage
.PHONY: default coverage test clean
coverage: $(BUILD_DIR)/testunityRunner.c
coverage: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC1), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC2), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC3), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC4), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC5), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC6), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC7), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
cd $(BUILD_DIR) && \
$(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC8), ../$i) $(COV_FLAGS) -o ../$(TARGET)
rm -f $(BUILD_DIR)/*.gcda
./$(TARGET) | grep 'Tests\|]]]' -A1
cd $(BUILD_DIR) && \
gcov unity.c | head -3
grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
test: $(BUILD_DIR)/testunityRunner.c
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC) -o $(TARGET)
test: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC1) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC2) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC3) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC4) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC5) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC6) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC7) -o $(TARGET)
./$(TARGET)
$(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC8) -o $(TARGET)
./$(TARGET)
# Compile only, for testing that preprocessor detection works
@@ -49,8 +121,29 @@ intDetection:
$(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_STDINT_H
$(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_LIMITS_H
$(BUILD_DIR)/testunityRunner.c: tests/testunity.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/testunity.c > $@
$(BUILD_DIR)/test_unity_arraysRunner.c: tests/test_unity_arrays.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_arrays.c > $@
$(BUILD_DIR)/test_unity_coreRunner.c: tests/test_unity_core.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_core.c > $@
$(BUILD_DIR)/test_unity_doublesRunner.c: tests/test_unity_doubles.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_doubles.c > $@
$(BUILD_DIR)/test_unity_floatsRunner.c: tests/test_unity_floats.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_floats.c > $@
$(BUILD_DIR)/test_unity_integersRunner.c: tests/test_unity_integers.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_integers.c > $@
$(BUILD_DIR)/test_unity_integers_64Runner.c: tests/test_unity_integers_64.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_integers_64.c > $@
$(BUILD_DIR)/test_unity_memoryRunner.c: tests/test_unity_memory.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_memory.c > $@
$(BUILD_DIR)/test_unity_stringsRunner.c: tests/test_unity_strings.c | $(BUILD_DIR)
awk $(AWK_SCRIPT) tests/test_unity_strings.c > $@
AWK_SCRIPT=\
'/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \
@@ -64,4 +157,4 @@ $(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/testunityRunner.c
rm -f $(TARGET) $(BUILD_DIR)/*.gc* $(BUILD_DIR)/test_unity_*Runner.c

View File

@@ -5,6 +5,7 @@
# ==========================================
$verbose = false
$extra_paths = []
require 'rake'
require 'rake/clean'
@@ -29,33 +30,70 @@ include RakefileHelpers
DEFAULT_CONFIG_FILE = 'gcc_auto_stdint.yml'
configure_toolchain(DEFAULT_CONFIG_FILE)
desc "Test unity with its own unit tests"
task :unit => [:prepare_for_tests] do
run_tests unit_test_files
end
############# ALL THE SELF-TESTS WE CAN PERFORM
namespace :test do
desc "Build and test Unity"
task :all => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:fixture', 'test:memory', 'test:summary']
task :ci => [:clean, :prepare_for_tests, 'test:scripts', 'test:unit', :style, 'test:make', 'test:fixture', 'test:memory', 'test:summary']
desc "Test unity's helper scripts"
task :scripts => [:prepare_for_tests] do
Dir['tests/test_*.rb'].each do |scriptfile|
require "./"+scriptfile
desc "Test unity with its own unit tests"
task :unit => [:prepare_for_tests] do
run_tests unit_test_files
end
namespace :unit do
unit_test_files.each do |f|
desc "test this unit only"
task File.basename(f,'.c').sub('test_unity_','') => [:prepare_for_tests] do
run_tests [f]
end
end
end
desc "Test unity's helper scripts"
task :scripts => [:prepare_for_tests] do
Dir['tests/test_*.rb'].each do |scriptfile|
require "./"+scriptfile
end
end
desc "Test unity triggered from make"
task :make => [:prepare_for_tests] do
run_make_tests()
end
desc "Test unity fixture addon"
task :fixture => [:prepare_for_tests] do
test_fixtures()
end
desc "Test unity memory addon"
task :memory => [:prepare_for_tests] do
test_memory()
end
desc "Test unity examples"
task :examples => [:prepare_for_tests] do
execute("cd ../examples/example_1 && make -s ci", false)
execute("cd ../examples/example_2 && make -s ci", false)
execute("cd ../examples/example_3 && rake", false)
end
desc "Run all rspecs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
desc "Generate test summary"
task :summary do
report_summary
end
end
desc "Run all rspecs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
desc "Generate test summary"
task :summary do
report_summary
end
desc "Build and test Unity"
task :all => [:clean, :prepare_for_tests, :scripts, :unit, :style, :summary]
###################### Shorthand for many common tasks
task :ci => ['test:ci']
task :all => ['test:all']
task :default => [:clobber, :all]
task :ci => [:no_color, :default]
task :cruise => [:no_color, :default]
desc "Load configuration"
task :config, :config_file do |t, args|
@@ -70,6 +108,7 @@ task :verbose do
$verbose = true
end
################### CODING STYLE VALIDATION
namespace :style do
desc "Check style"
task :check do
@@ -81,7 +120,7 @@ namespace :style do
namespace :check do
Dir['../**/*.rb'].each do |f|
filename = File.basename(f, '.rb')
desc "Check Style of #{filename}"
#desc "Check Style of #{filename}"
task filename.to_sym => ['style:clean'] do
report execute("rubocop #{f} --color --config .rubocop.yml", true)
report "Style Checked for #{f}"
@@ -97,7 +136,7 @@ namespace :style do
namespace :c do
Dir['../{src,extras/**}/*.{c,h}'].each do |f|
filename = File.basename(f)[0..-3]
desc "Check Style of #{filename}"
#desc "Check Style of #{filename}"
task filename.to_sym do
run_astyle f
end

View File

@@ -22,7 +22,7 @@ module RakefileHelpers
end
def configure_clean
CLEAN.include($cfg['compiler']['build_path'] + '*.*') unless $cfg['compiler']['build_path'].nil?
CLEAN.include('build/*.*')
end
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
@@ -33,13 +33,16 @@ module RakefileHelpers
end
def unit_test_files
path = $cfg['compiler']['unit_tests_path'] + 'test*' + C_EXTENSION
path = 'tests/test*' + C_EXTENSION
path.tr!('\\', '/')
FileList.new(path)
end
def local_include_dirs
include_dirs = $cfg['compiler']['includes']['items'].dup
include_dirs = $cfg[:paths][:includes] || []
include_dirs += $cfg[:paths][:source] || []
include_dirs += $cfg[:paths][:test] || []
include_dirs += $cfg[:paths][:support] || []
include_dirs.delete_if { |dir| dir.is_a?(Array) }
include_dirs
end
@@ -86,75 +89,73 @@ module RakefileHelpers
end
end
def build_compiler_fields(inject_defines)
command = tackit($cfg['compiler']['path'])
defines = if $cfg['compiler']['defines']['items'].nil?
''
else
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'] + ['UNITY_OUTPUT_CHAR=putcharSpy'] + ['UNITY_OUTPUT_CHAR_HEADER_DECLARATION="putcharSpy(int)"'] + inject_defines)
end
options = squash('', $cfg['compiler']['options'])
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
def build_command_string(hash, values, defines = nil)
{ :command => command, :defines => defines, :options => options, :includes => includes }
# Replace named and numbered slots
args = []
hash[:arguments].each do |arg|
if arg.include? '$'
if arg.include? ': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
pattern = arg.gsub(': COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE','')
[ File.join('..','src') ].each do |f|
args << pattern.gsub(/\$/,f)
end
elsif arg.include? ': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
pattern = arg.gsub(': COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR','')
[ $extra_paths, 'src', File.join('tests'), File.join('testdata'), $cfg[:paths][:support] ].flatten.uniq.compact.each do |f|
args << pattern.gsub(/\$/,f)
end
elsif arg.include? ': COLLECTION_DEFINES_TEST_AND_VENDOR'
pattern = arg.gsub(': COLLECTION_DEFINES_TEST_AND_VENDOR','')
[ $cfg[:defines][:test], defines ].flatten.uniq.compact.each do |f|
args << pattern.gsub(/\$/,f)
end
elsif arg =~ /\$\{(\d+)\}/
i = $1.to_i - 1
if (values[i].is_a?(Array))
values[i].each {|v| args << arg.gsub(/\$\{\d+\}/, v)}
else
args << arg.gsub(/\$\{(\d)+\}/, values[i] || '')
end
else
args << arg
end
else
args << arg
end
end
# Build Command
return tackit(hash[:executable]) + squash('', args)
end
def compile(file, defines = [])
compiler = build_compiler_fields(defines)
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str + obj_file)
obj_file
end
def build_linker_fields
command = tackit($cfg['linker']['path'])
options = if $cfg['linker']['options'].nil?
''
else
squash('', $cfg['linker']['options'])
end
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
''
else
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
end.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ :command => command, :options => options, :includes => includes }
out_file = File.join('build', File.basename(file, C_EXTENSION)) + $cfg[:extension][:object]
cmd_str = build_command_string( $cfg[:tools][:test_compiler], [ file, out_file ], defines )
execute(cmd_str)
out_file
end
def link_it(exe_name, obj_list)
linker = build_linker_fields
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join +
$cfg['linker']['bin_files']['prefix'] + ' ' +
$cfg['linker']['bin_files']['destination'] +
exe_name + $cfg['linker']['bin_files']['extension']
exe_name = File.join('build', File.basename(exe_name))
cmd_str = build_command_string( $cfg[:tools][:test_linker], [ obj_list, exe_name ] )
execute(cmd_str)
end
def build_simulator_fields
return nil if $cfg['simulator'].nil?
command = if $cfg['simulator']['path'].nil?
''
else
(tackit($cfg['simulator']['path']) + ' ')
end
pre_support = if $cfg['simulator']['pre_support'].nil?
''
else
squash('', $cfg['simulator']['pre_support'])
end
post_support = if $cfg['simulator']['post_support'].nil?
''
else
squash('', $cfg['simulator']['post_support'])
end
{ :command => command, :pre_support => pre_support, :post_support => post_support }
def runtest(bin_name, ok_to_fail = false, extra_args = nil)
bin_name = File.join('build', File.basename(bin_name))
extra_args = extra_args.nil? ? "" : " " + extra_args
if $cfg[:tools][:test_fixture]
cmd_str = build_command_string( $cfg[:tools][:test_fixture], [ bin_name, extra_args ] )
else
cmd_str = bin_name + extra_args
end
execute(cmd_str, ok_to_fail)
end
def run_astyle(style_what)
@@ -180,21 +181,75 @@ module RakefileHelpers
def report_summary
summary = UnityTestSummary.new
summary.root = __dir__
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob = File.join('build','*.test*')
results_glob.tr!('\\', '/')
results = Dir[results_glob]
summary.targets = results
report summary.run
end
def run_tests(test_files)
report 'Running Unity system tests...'
def save_test_results(test_base, output)
test_results = File.join('build',test_base)
if output.match(/OK$/m).nil?
test_results += '.testfail'
else
report output unless $verbose # Verbose already prints this line, as does a failure
test_results += '.testpass'
end
File.open(test_results, 'w') { |f| f.print output }
end
# Tack on TEST define for compiling unit tests
load_configuration($cfg_file)
test_defines = ['TEST']
$cfg['compiler']['defines']['items'] ||= []
$cfg['compiler']['defines']['items'] << 'TEST'
def test_fixtures()
report "\nRunning Fixture Addon"
# Get a list of all source files needed
src_files = Dir[File.join('..','extras','fixture','src','*.c')]
src_files += Dir[File.join('..','extras','fixture','test','*.c')]
src_files += Dir[File.join('..','extras','fixture','test','main','*.c')]
src_files += Dir[File.join('..','extras','memory','src','*.c')]
src_files << File.join('..','src','unity.c')
# Build object files
$extra_paths = [File.join('..','extras','fixture','src'), File.join('..','extras','memory','src')]
obj_list = src_files.map { |f| compile(f, ['UNITY_SKIP_DEFAULT_RUNNER', 'UNITY_FIXTURE_NO_EXTRAS']) }
# Link the test executable
test_base = File.basename('framework_test', C_EXTENSION)
link_it(test_base, obj_list)
# Run and collect output
output = runtest(test_base + " -v -r")
save_test_results(test_base, output)
end
def test_memory()
{ 'w_malloc' => [],
'wo_malloc' => ['UNITY_EXCLUDE_STDLIB_MALLOC']
}.each_pair do |name, defs|
report "\nRunning Memory Addon #{name}"
# Get a list of all source files needed
src_files = Dir[File.join('..','extras','memory','src','*.c')]
src_files += Dir[File.join('..','extras','memory','test','*.c')]
src_files += Dir[File.join('..','extras','memory','test','main','*.c')]
src_files << File.join('..','src','unity.c')
# Build object files
$extra_paths = [File.join('..','extras','memory','src')]
obj_list = src_files.map { |f| compile(f, defs) }
# Link the test executable
test_base = File.basename("memory_test_#{name}", C_EXTENSION)
link_it(test_base, obj_list)
# Run and collect output
output = runtest(test_base)
save_test_results(test_base, output)
end
end
def run_tests(test_files)
report "\nRunning Unity system tests"
include_dirs = local_include_dirs
@@ -209,13 +264,9 @@ module RakefileHelpers
end
end
report "\nRunning Tests in #{test}"
obj_list = []
unless $cfg['compiler']['aux_sources'].nil?
$cfg['compiler']['aux_sources'].each do |aux|
obj_list << compile(aux, test_defines)
end
end
test_defines = []
# Detect dependencies and build required modules
extract_headers(test).each do |header|
@@ -227,14 +278,8 @@ module RakefileHelpers
# Build the test runner (generate if configured to do so)
test_base = File.basename(test, C_EXTENSION)
runner_name = test_base + '_Runner.c'
runner_path = if $cfg['compiler']['runner_path'].nil?
$cfg['compiler']['build_path'] + runner_name
else
$cfg['compiler']['runner_path'] + runner_name
end
runner_path = File.join('build',runner_name)
options = $cfg[:unity]
options[:use_param_tests] = test =~ /parameterized/ ? true : false
@@ -248,22 +293,23 @@ module RakefileHelpers
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
cmd_str = if simulator.nil?
executable
else
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str)
test_results = $cfg['compiler']['build_path'] + test_base
if output.match(/OK$/m).nil?
test_results += '.testfail'
else
report output unless $verbose # Verbose already prints this line, as does a failure
test_results += '.testpass'
end
File.open(test_results, 'w') { |f| f.print output }
output = runtest(test_base)
save_test_results(test_base, output)
end
end
def run_make_tests()
[ "make -s", # test with all defaults
#"make -s DEBUG=-m32", # test 32-bit architecture with 64-bit support
#"make -s DEBUG=-m32 UNITY_SUPPORT_64=", # test 32-bit build without 64-bit types
"make -s UNITY_INCLUDE_DOUBLE= ", # test without double
"cd #{File.join("..","extras","fixture",'test')} && make -s default noStdlibMalloc",
"cd #{File.join("..","extras","fixture",'test')} && make -s C89",
"cd #{File.join("..","extras","memory",'test')} && make -s default noStdlibMalloc",
"cd #{File.join("..","extras","memory",'test')} && make -s C89",
].each do |cmd|
report "Testing '#{cmd}'"
execute(cmd, false)
end
end
end

View File

@@ -1,49 +1,44 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-ansi'
#- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_EXCLUDE_TESTING_NEW_COMMENTS
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
---
colour: true
:unity:
:plugins: []
:skip_tests:
- :parameterized
- :parameterized
:tools:
:test_compiler:
:name: compiler
:executable: gcc
:arguments:
- "-c"
- "-m64"
- "-Wall"
- "-Wno-address"
- "-ansi"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: gcc
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_EXCLUDE_TESTING_NEW_COMMENTS
- UNITY_SUPPORT_64

View File

@@ -1,78 +1,72 @@
---
compiler:
path: clang
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-Wall'
- '-Wextra'
- '-Werror'
- '-Wcast-qual'
- '-Wconversion'
- '-Wdisabled-optimization'
- '-Wformat=2'
- '-Winit-self'
- '-Winline'
- '-Winvalid-pch'
- '-Wmissing-include-dirs'
- '-Wnonnull'
- '-Wpacked'
- '-Wpointer-arith'
- '-Wswitch-default'
- '-Wstrict-aliasing'
- '-Wstrict-overflow=5'
- '-Wuninitialized'
- '-Wunused'
# - '-Wunreachable-code'
- '-Wreturn-type'
- '-Wshadow'
- '-Wundef'
- '-Wwrite-strings'
- '-Wno-nested-externs'
- '-Wno-unused-parameter'
- '-Wno-variadic-macros'
- '-Wbad-function-cast'
- '-fms-extensions'
- '-fno-omit-frame-pointer'
- '-ffloat-store'
- '-fno-common'
- '-fstrict-aliasing'
- '-std=gnu99'
- '-pedantic'
- '-O0'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_64
- UNITY_OUTPUT_RESULTS_FILE
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: clang
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: clang
:arguments:
- "-c"
- "-Wall"
- "-Wextra"
- "-Werror"
- "-Wcast-qual"
- "-Wconversion"
- "-Wdisabled-optimization"
- "-Wformat=2"
- "-Winit-self"
- "-Winline"
- "-Winvalid-pch"
- "-Wmissing-include-dirs"
- "-Wnonnull"
- "-Wpacked"
- "-Wpointer-arith"
- "-Wswitch-default"
- "-Wstrict-aliasing"
- "-Wstrict-overflow=5"
- "-Wuninitialized"
- "-Wunused"
- "-Wreturn-type"
- "-Wshadow"
- "-Wundef"
- "-Wwrite-strings"
- "-Wno-nested-externs"
- "-Wno-unused-parameter"
- "-Wno-variadic-macros"
- "-Wbad-function-cast"
- "-fms-extensions"
- "-fno-omit-frame-pointer"
- "-ffloat-store"
- "-fno-common"
- "-fstrict-aliasing"
- "-std=gnu99"
- "-pedantic"
- "-O0"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: clang
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_64
- UNITY_OUTPUT_RESULTS_FILE

View File

@@ -1,78 +1,71 @@
---
compiler:
path: clang
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-Wall'
- '-Wextra'
- '-Werror'
- '-Wcast-qual'
- '-Wconversion'
- '-Wdisabled-optimization'
- '-Wformat=2'
- '-Winit-self'
- '-Winline'
- '-Winvalid-pch'
- '-Wmissing-include-dirs'
- '-Wnonnull'
- '-Wpacked'
- '-Wpointer-arith'
- '-Wswitch-default'
- '-Wstrict-aliasing'
- '-Wstrict-overflow=5'
- '-Wuninitialized'
- '-Wunused'
# - '-Wunreachable-code'
- '-Wreturn-type'
- '-Wshadow'
- '-Wundef'
- '-Wwrite-strings'
- '-Wno-nested-externs'
- '-Wno-unused-parameter'
- '-Wno-variadic-macros'
- '-Wbad-function-cast'
- '-fms-extensions'
- '-fno-omit-frame-pointer'
#- '-ffloat-store'
- '-fno-common'
- '-fstrict-aliasing'
- '-std=gnu99'
- '-pedantic'
- '-O0'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: clang
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: clang
:arguments:
- "-c"
- "-Wall"
- "-Wextra"
- "-Werror"
- "-Wcast-qual"
- "-Wconversion"
- "-Wdisabled-optimization"
- "-Wformat=2"
- "-Winit-self"
- "-Winline"
- "-Winvalid-pch"
- "-Wmissing-include-dirs"
- "-Wnonnull"
- "-Wpacked"
- "-Wpointer-arith"
- "-Wswitch-default"
- "-Wstrict-aliasing"
- "-Wstrict-overflow=5"
- "-Wuninitialized"
- "-Wunused"
- "-Wreturn-type"
- "-Wshadow"
- "-Wundef"
- "-Wwrite-strings"
- "-Wno-nested-externs"
- "-Wno-unused-parameter"
- "-Wno-variadic-macros"
- "-Wbad-function-cast"
- "-fms-extensions"
- "-fno-omit-frame-pointer"
- "-fno-common"
- "-fstrict-aliasing"
- "-std=gnu99"
- "-pedantic"
- "-O0"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: clang
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64

View File

@@ -1,49 +1,45 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m32'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_INT_WIDTH=32
- UNITY_LONG_WIDTH=32
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m32'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
---
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: gcc
:arguments:
- "-c"
- "-m32"
- "-Wall"
- "-Wno-address"
- "-std=c99"
- "-pedantic"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: gcc
:arguments:
- "${1}"
- "-lm"
- "-m32"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_INT_WIDTH=32
- UNITY_LONG_WIDTH=32

View File

@@ -1,50 +1,46 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
- UNITY_INT_WIDTH=32
- UNITY_LONG_WIDTH=64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
---
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: gcc
:arguments:
- "-c"
- "-m64"
- "-Wall"
- "-Wno-address"
- "-std=c99"
- "-pedantic"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: gcc
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_EXCLUDE_STDINT_H
- UNITY_EXCLUDE_LIMITS_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
- UNITY_INT_WIDTH=32
- UNITY_LONG_WIDTH=64

View File

@@ -1,47 +1,43 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_STDINT_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
---
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: gcc
:arguments:
- "-c"
- "-m64"
- "-Wall"
- "-Wno-address"
- "-std=c99"
- "-pedantic"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: gcc
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_EXCLUDE_STDINT_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64

View File

@@ -1,59 +1,55 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
- '-Wextra'
- '-Werror'
- '-Wpointer-arith'
- '-Wcast-align'
- '-Wwrite-strings'
- '-Wswitch-default'
- '-Wunreachable-code'
- '-Winit-self'
- '-Wmissing-field-initializers'
- '-Wno-unknown-pragmas'
- '-Wstrict-prototypes'
- '-Wundef'
- '-Wold-style-definition'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
---
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: gcc
:arguments:
- "-c"
- "-m64"
- "-Wall"
- "-Wno-address"
- "-std=c99"
- "-pedantic"
- "-Wextra"
- "-Werror"
- "-Wpointer-arith"
- "-Wcast-align"
- "-Wwrite-strings"
- "-Wswitch-default"
- "-Wunreachable-code"
- "-Winit-self"
- "-Wmissing-field-initializers"
- "-Wno-unknown-pragmas"
- "-Wstrict-prototypes"
- "-Wundef"
- "-Wold-style-definition"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: gcc
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64

View File

@@ -1,47 +1,43 @@
compiler:
path: gcc
source_path: '../src/'
unit_tests_path: &unit_tests_path 'tests/'
build_path: &build_path 'build/'
options:
- '-c'
- '-m64'
- '-Wall'
- '-Wno-address'
- '-std=c99'
- '-pedantic'
includes:
prefix: '-I'
items:
- 'src/'
- '../src/'
- 'testdata/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_EXCLUDE_MATH_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
- '-m64'
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
---
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable: gcc
:arguments:
- "-c"
- "-m64"
- "-Wall"
- "-Wno-address"
- "-std=c99"
- "-pedantic"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable: gcc
:arguments:
- "${1}"
- "-lm"
- "-m64"
- "-o ${2}"
:extension:
:object: ".o"
:executable: ".exe"
:paths:
:test:
- src/
- "../src/"
- testdata/
- tests/
:defines:
:test:
- UNITY_EXCLUDE_MATH_H
- UNITY_INCLUDE_DOUBLE
- UNITY_SUPPORT_TEST_CASES
- UNITY_SUPPORT_64

View File

@@ -1,101 +1,91 @@
# rumor has it that this yaml file works for the standard edition of the
# hitech PICC18 compiler, but not the pro version.
#
compiler:
path: cd build && picc18
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --chip=18F87J10
- --ide=hitide
- --q #quiet please
- --asmlist
- --codeoffset=0
- --emi=wordwrite # External memory interface protocol
- --warn=0 # allow all normal warning messages
- --errors=10 # Number of errors before aborting compile
- --char=unsigned
- -Bl # Large memory model
- -G # generate symbol file
- --cp=16 # 16-bit pointers
- --double=24
- -N255 # 255-char symbol names
- --opt=none # Do not use any compiler optimziations
- -c # compile only
- -M
includes:
prefix: '-I'
items:
- 'c:/Projects/NexGen/Prototypes/CMockTest/src/'
- 'c:/Projects/NexGen/Prototypes/CMockTest/mocks/'
- 'c:/CMock/src/'
- 'c:/CMock/examples/src/'
- 'c:/CMock/vendor/unity/src/'
- 'c:/CMock/vendor/unity/examples/helper/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- UNITY_INT_WIDTH=16
- UNITY_POINTER_WIDTH=16
- CMOCK_MEM_STATIC
- CMOCK_MEM_SIZE=3000
- UNITY_SUPPORT_TEST_CASES
- _PICC18
object_files:
# prefix: '-O' # Hi-Tech doesn't want a prefix. They key off of filename .extensions, instead
extension: '.obj'
destination: *build_path
linker:
path: cd build && picc18
options:
- --chip=18F87J10
- --ide=hitide
- --cp=24 # 24-bit pointers. Is this needed for linker??
- --double=24 # Is this needed for linker??
- -Lw # Scan the pic87*w.lib in the lib/ of the compiler installation directory
- --summary=mem,file # info listing
- --summary=+psect
- --summary=+hex
- --output=+intel
- --output=+mcof
- --runtime=+init # Directs startup code to copy idata, ibigdata and ifardata psects from ROM to RAM.
- --runtime=+clear # Directs startup code to clear bss, bigbss, rbss and farbss psects
- --runtime=+clib # link in the c-runtime
- --runtime=+keep # Keep the generated startup src after its obj is linked
- -G # Generate src-level symbol file
- -MIWasTheLastToBuild.map
- --warn=0 # allow all normal warning messages
- -Bl # Large memory model (probably not needed for linking)
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.obj'
bin_files:
prefix: '-O'
extension: '.hex'
destination: *build_path
simulator:
path:
pre_support:
- 'java -client -jar ' # note space
- ['C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\', 'simpic18.jar']
- 18F87J10
post_support:
---
:cmock:
:plugins: []
:includes:
- Types.h
- Types.h
:suite_teardown: |
if (num_failures)
_FAILED_TEST();
else
_PASSED_TESTS();
return 0;
colour: true
:tools:
:test_compiler:
:name: compiler
:executable: cd build && picc18
:arguments:
- "--chip=18F87J10"
- "--ide=hitide"
- "--q"
- "--asmlist"
- "--codeoffset=0"
- "--emi=wordwrite"
- "--warn=0"
- "--errors=10"
- "--char=unsigned"
- "-Bl"
- "-G"
- "--cp=16"
- "--double=24"
- "-N255"
- "--opt=none"
- "-c"
- "-M"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- " ${2}"
:test_linker:
:name: linker
:executable: cd build && picc18
:arguments:
- "${1}"
- "--chip=18F87J10"
- "--ide=hitide"
- "--cp=24"
- "--double=24"
- "-Lw"
- "--summary=mem,file"
- "--summary=+psect"
- "--summary=+hex"
- "--output=+intel"
- "--output=+mcof"
- "--runtime=+init"
- "--runtime=+clear"
- "--runtime=+clib"
- "--runtime=+keep"
- "-G"
- "-MIWasTheLastToBuild.map"
- "--warn=0"
- "-Bl"
- "-O ${2}"
:test_fixture:
:name: simulator
:executable: 'java -client -jar '
:arguments:
- - C:\Program Files\HI-TECH Software\HI-TIDE\3.15\lib\
- simpic18.jar
- 18F87J10
- "${1}"
:extension:
:object: ".obj"
:executable: ".hex"
:paths:
:test:
- c:/Projects/NexGen/Prototypes/CMockTest/src/
- c:/Projects/NexGen/Prototypes/CMockTest/mocks/
- c:/CMock/src/
- c:/CMock/examples/src/
- c:/CMock/vendor/unity/src/
- c:/CMock/vendor/unity/examples/helper/
- tests\
:defines:
:test:
- UNITY_INT_WIDTH=16
- UNITY_POINTER_WIDTH=16
- CMOCK_MEM_STATIC
- CMOCK_MEM_SIZE=3000
- UNITY_SUPPORT_TEST_CASES
- _PICC18

View File

@@ -1,90 +1,98 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\lib\dl4tptinl8n.h']
- -z3
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian little
- --cpu ARM7TDMI
- --stack_align 4
- --interwork
- -e
- --silent
- --warnings_are_errors
- --fpu None
- --diag_suppress Pa050
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'common\bin\xlink.exe']
options:
- -rt
- [*tools_root, 'arm\lib\dl4tptinl8n.r79']
- -D_L_EXTMEM_START=0
- -D_L_EXTMEM_SIZE=0
- -D_L_HEAP_SIZE=120
- -D_L_STACK_SIZE=32
- -e_small_write=_formatted_write
- -s
- __program_start
- -f
- [*tools_root, '\arm\config\lnkarm.xcl']
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\config\']
- [*tools_root, 'arm\lib\']
object_files:
path: *build_path
extension: '.r79'
bin_files:
prefix: '-o'
extension: '.d79'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\ioat91sam7X256.ddf']
- -d
- sim
---
tools_root: C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\bin\iccarm.exe
:arguments:
- "--dlib_config"
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\lib\dl4tptinl8n.h
- "-z3"
- "--no_cse"
- "--no_unroll"
- "--no_inline"
- "--no_code_motion"
- "--no_tbaa"
- "--no_clustering"
- "--no_scheduling"
- "--debug"
- "--cpu_mode thumb"
- "--endian little"
- "--cpu ARM7TDMI"
- "--stack_align 4"
- "--interwork"
- "-e"
- "--silent"
- "--warnings_are_errors"
- "--fpu None"
- "--diag_suppress Pa050"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- common\bin\xlink.exe
:arguments:
- "${1}"
- "-rt"
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\lib\dl4tptinl8n.r79
- "-D_L_EXTMEM_START=0"
- "-D_L_EXTMEM_SIZE=0"
- "-D_L_HEAP_SIZE=120"
- "-D_L_STACK_SIZE=32"
- "-e_small_write=_formatted_write"
- "-s"
- __program_start
- "-f"
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- "\\arm\\config\\lnkarm.xcl"
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- common\bin\CSpyBat.exe
:arguments:
- "--silent"
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\bin\armproc.dll
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\bin\armsim.dll
- "${1}"
- "--plugin"
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\bin\armbat.dll
- "--backend"
- "-B"
- "-p"
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\config\ioat91sam7X256.ddf
- "-d"
- sim
:extension:
:object: ".r79"
:executable: ".d79"
:paths:
:test:
- - C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\
- arm\inc\
- src\
- "..\\src\\"
- testdata/
- tests\
- vendor\unity\src\
:defines:
:test:
- UNITY_SUPPORT_64
- UNITY_SUPPORT_TEST_CASES

View File

@@ -1,80 +1,92 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=ARM7TDMI
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
- -d
- sim
---
tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\iccarm.exe
:arguments:
- "--dlib_config"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\inc\DLib_Config_Normal.h
- "--no_cse"
- "--no_unroll"
- "--no_inline"
- "--no_code_motion"
- "--no_tbaa"
- "--no_clustering"
- "--no_scheduling"
- "--debug"
- "--cpu_mode thumb"
- "--endian=little"
- "--cpu=ARM7TDMI"
- "--interwork"
- "--warnings_are_errors"
- "--fpu=None"
- "--diag_suppress=Pa050"
- "--diag_suppress=Pe111"
- "-e"
- "-On"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\ilinkarm.exe
:arguments:
- "${1}"
- "--redirect _Printf=_PrintfLarge"
- "--redirect _Scanf=_ScanfSmall"
- "--semihosting"
- "--entry __iar_program_start"
- "--config"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\config\generic.icf
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- common\bin\CSpyBat.exe
:arguments:
- "--silent"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\armproc.dll
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\armsim.dll
- "${1}"
- "--plugin"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\armbat.dll
- "--backend"
- "-B"
- "-p"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\config\debugger\atmel\ioat91sam7X256.ddf
- "-d"
- sim
:extension:
:object: ".r79"
:executable: ".out"
:paths:
:test:
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\inc\
- src\
- "..\\src\\"
- testdata/
- tests\
- vendor\unity\src\
- iar\iar_v5\incIAR\
:defines:
:test:
- UNITY_SUPPORT_64
- UNITY_SUPPORT_TEST_CASES

View File

@@ -1,80 +1,92 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=ARM7TDMI
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
- -d
- sim
---
tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\iccarm.exe
:arguments:
- "--dlib_config"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\inc\DLib_Config_Normal.h
- "--no_cse"
- "--no_unroll"
- "--no_inline"
- "--no_code_motion"
- "--no_tbaa"
- "--no_clustering"
- "--no_scheduling"
- "--debug"
- "--cpu_mode thumb"
- "--endian=little"
- "--cpu=ARM7TDMI"
- "--interwork"
- "--warnings_are_errors"
- "--fpu=None"
- "--diag_suppress=Pa050"
- "--diag_suppress=Pe111"
- "-e"
- "-On"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\ilinkarm.exe
:arguments:
- "${1}"
- "--redirect _Printf=_PrintfLarge"
- "--redirect _Scanf=_ScanfSmall"
- "--semihosting"
- "--entry __iar_program_start"
- "--config"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\config\generic.icf
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- common\bin\CSpyBat.exe
:arguments:
- "--silent"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\armproc.dll
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\armsim.dll
- "${1}"
- "--plugin"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\bin\armbat.dll
- "--backend"
- "-B"
- "-p"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\config\debugger\atmel\ioat91sam7X256.ddf
- "-d"
- sim
:extension:
:object: ".r79"
:executable: ".out"
:paths:
:test:
- - C:\Program Files\IAR Systems\Embedded Workbench 5.3\
- arm\inc\
- src\
- "..\\src\\"
- testdata/
- tests\
- vendor\unity\src\
- iar\iar_v5\incIAR\
:defines:
:test:
- UNITY_SUPPORT_64
- UNITY_SUPPORT_TEST_CASES

View File

@@ -1,94 +1,90 @@
#Default tool path for IAR 5.4 on Windows XP 64bit
tools_root: &tools_root 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --diag_suppress=Pa050
#- --diag_suppress=Pe111
- --debug
- --endian=little
- --cpu=Cortex-M3
- --no_path_in_file_macros
- -e
- --fpu=None
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
#- --preinclude --preinclude C:\Vss\T2 Working\common\system.h
- --interwork
- --warnings_are_errors
# - Ohz
- -Oh
# - --no_cse
# - --no_unroll
# - --no_inline
# - --no_code_motion
# - --no_tbaa
# - --no_clustering
# - --no_scheduling
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- ewarm
- PART_LM3S9B92
- TARGET_IS_TEMPEST_RB1
- USE_ROM_DRIVERS
- UART_BUFFERED
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
# - ['C:\Temp\lm3s9b92.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
#- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim2.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- --endian=little
- --cpu=Cortex-M3
- --fpu=None
- -p
- [*tools_root, 'arm\config\debugger\TexasInstruments\iolm3sxxxx.ddf']
- --semihosting
- --device=LM3SxBxx
#- -d
#- sim
---
tools_root: C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\bin\iccarm.exe
:arguments:
- "--diag_suppress=Pa050"
- "--debug"
- "--endian=little"
- "--cpu=Cortex-M3"
- "--no_path_in_file_macros"
- "-e"
- "--fpu=None"
- "--dlib_config"
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\inc\DLib_Config_Normal.h
- "--interwork"
- "--warnings_are_errors"
- "-Oh"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\bin\ilinkarm.exe
:arguments:
- "${1}"
- "--redirect _Printf=_PrintfLarge"
- "--redirect _Scanf=_ScanfSmall"
- "--semihosting"
- "--entry __iar_program_start"
- "--config"
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\config\generic.icf
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- common\bin\CSpyBat.exe
:arguments:
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\bin\armproc.dll
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\bin\armsim2.dll
- "${1}"
- "--plugin"
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\bin\armbat.dll
- "--backend"
- "-B"
- "--endian=little"
- "--cpu=Cortex-M3"
- "--fpu=None"
- "-p"
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\config\debugger\TexasInstruments\iolm3sxxxx.ddf
- "--semihosting"
- "--device=LM3SxBxx"
:extension:
:object: ".r79"
:executable: ".out"
:paths:
:test:
- - C:\Program Files (x86)\IAR Systems\Embedded Workbench 5.4 Kickstart\
- arm\inc\
- src\
- "..\\src\\"
- testdata/
- tests\
- vendor\unity\src\
- iar\iar_v5\incIAR\
:defines:
:test:
- ewarm
- PART_LM3S9B92
- TARGET_IS_TEMPEST_RB1
- USE_ROM_DRIVERS
- UART_BUFFERED
- UNITY_SUPPORT_64

View File

@@ -1,84 +1,94 @@
# unit testing under iar compiler / simulator for STM32 Cortex-M3
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.4\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=Cortex-M3
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\inc\']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
- 'iar\iar_v5\incIAR\'
defines:
prefix: '-D'
items:
- 'IAR'
- 'UNITY_SUPPORT_64'
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic_cortex.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\ST\iostm32f107xx.ddf']
- --cpu=Cortex-M3
- -d
- sim
---
tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.4\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\bin\iccarm.exe
:arguments:
- "--dlib_config"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\inc\DLib_Config_Normal.h
- "--no_cse"
- "--no_unroll"
- "--no_inline"
- "--no_code_motion"
- "--no_tbaa"
- "--no_clustering"
- "--no_scheduling"
- "--debug"
- "--cpu_mode thumb"
- "--endian=little"
- "--cpu=Cortex-M3"
- "--interwork"
- "--warnings_are_errors"
- "--fpu=None"
- "--diag_suppress=Pa050"
- "--diag_suppress=Pe111"
- "-e"
- "-On"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\bin\ilinkarm.exe
:arguments:
- "${1}"
- "--redirect _Printf=_PrintfLarge"
- "--redirect _Scanf=_ScanfSmall"
- "--semihosting"
- "--entry __iar_program_start"
- "--config"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\config\generic_cortex.icf
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- common\bin\CSpyBat.exe
:arguments:
- "--silent"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\bin\armproc.dll
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\bin\armsim.dll
- "${1}"
- "--plugin"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\bin\armbat.dll
- "--backend"
- "-B"
- "-p"
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\config\debugger\ST\iostm32f107xx.ddf
- "--cpu=Cortex-M3"
- "-d"
- sim
:extension:
:object: ".r79"
:executable: ".out"
:paths:
:test:
- - C:\Program Files\IAR Systems\Embedded Workbench 5.4\
- arm\inc\
- src\
- "..\\src\\"
- testdata/
- tests\
- vendor\unity\src\
- iar\iar_v5\incIAR\
:defines:
:test:
- IAR
- UNITY_SUPPORT_64
- UNITY_SUPPORT_TEST_CASES

View File

@@ -1,95 +1,112 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\'
core_root: &core_root [*tools_root, '430\']
core_bin: &core_bin [*core_root, 'bin\']
core_config: &core_config [*core_root, 'config\']
core_lib: &core_lib [*core_root, 'lib\']
core_inc: &core_inc [*core_root, 'inc\']
core_config: &core_config [*core_root, 'config\']
compiler:
path: [*core_bin, 'icc430.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*core_lib, 'dlib\dl430fn.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --debug
- -e
- -Ol
- --multiplier=16
- --double=32
- --diag_suppress Pa050
- --diag_suppress Pe111
includes:
prefix: '-I'
items:
- *core_inc
- [*core_inc, 'dlib']
- [*core_lib, 'dlib']
- 'src\'
- '../src/'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src'
defines:
prefix: '-D'
items:
- '__MSP430F149__'
- 'INT_WIDTH=16'
- 'UNITY_EXCLUDE_FLOAT'
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.r43'
destination: *build_path
linker:
path: [*core_bin, 'xlink.exe']
options:
- -rt
- [*core_lib, 'dlib\dl430fn.r43']
- -e_PrintfTiny=_Printf
- -e_ScanfSmall=_Scanf
- -s __program_start
- -D_STACK_SIZE=50
- -D_DATA16_HEAP_SIZE=50
- -D_DATA20_HEAP_SIZE=50
- -f
- [*core_config, 'lnk430f5438.xcl']
- -f
- [*core_config, 'multiplier.xcl']
includes:
prefix: '-I'
items:
- *core_config
- *core_lib
- [*core_lib, 'dlib']
object_files:
path: *build_path
extension: '.r79'
bin_files:
prefix: '-o'
extension: '.d79'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*core_bin, '430proc.dll']
- [*core_bin, '430sim.dll']
post_support:
- --plugin
- [*core_bin, '430bat.dll']
- --backend -B
- --cpu MSP430F5438
- -p
- [*core_config, 'MSP430F5438.ddf']
- -d sim
---
tools_root: C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\
core_root: &1
- C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\
- 430\
core_bin: &2
- *1
- bin\
core_config: &4
- *1
- config\
core_lib: &3
- *1
- lib\
core_inc: &5
- *1
- inc\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- *2
- icc430.exe
:arguments:
- "--dlib_config"
- - *3
- dlib\dl430fn.h
- "--no_cse"
- "--no_unroll"
- "--no_inline"
- "--no_code_motion"
- "--no_tbaa"
- "--debug"
- "-e"
- "-Ol"
- "--multiplier=16"
- "--double=32"
- "--diag_suppress Pa050"
- "--diag_suppress Pe111"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- *2
- xlink.exe
:arguments:
- "${1}"
- "-rt"
- - *3
- dlib\dl430fn.r43
- "-e_PrintfTiny=_Printf"
- "-e_ScanfSmall=_Scanf"
- "-s __program_start"
- "-D_STACK_SIZE=50"
- "-D_DATA16_HEAP_SIZE=50"
- "-D_DATA20_HEAP_SIZE=50"
- "-f"
- - *4
- lnk430f5438.xcl
- "-f"
- - *4
- multiplier.xcl
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 5.3 MSP430\
- common\bin\CSpyBat.exe
:arguments:
- "--silent"
- - *2
- 430proc.dll
- - *2
- 430sim.dll
- "${1}"
- "--plugin"
- - *2
- 430bat.dll
- "--backend -B"
- "--cpu MSP430F5438"
- "-p"
- - *4
- MSP430F5438.ddf
- "-d sim"
:extension:
:object: ".r43"
:executable: ".d79"
:paths:
:test:
- *5
- - *5
- dlib
- - *3
- dlib
- src\
- "../src/"
- testdata/
- tests\
- vendor\unity\src
:defines:
:test:
- __MSP430F149__
- INT_WIDTH=16
- UNITY_EXCLUDE_FLOAT
- UNITY_SUPPORT_TEST_CASES

View File

@@ -1,86 +1,99 @@
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 6.0\'
compiler:
path: [*tools_root, 'sh\bin\iccsh.exe']
source_path: '..\src\'
unit_tests_path: &unit_tests_path 'tests\'
build_path: &build_path 'build\'
options:
- -e
- --char_is_signed
- -Ol
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_scheduling
- --no_clustering
- --debug
- --dlib_config
- [*tools_root, 'sh\inc\DLib_Product.h']
- --double=32
- --code_model=huge
- --data_model=huge
- --core=sh2afpu
- --warnings_affect_exit_code
- --warnings_are_errors
- --mfc
- --use_unix_directory_separators
- --diag_suppress=Pe161
includes:
prefix: '-I'
items:
- [*tools_root, 'sh\inc\']
- [*tools_root, 'sh\inc\c']
- 'src\'
- '..\src\'
- 'testdata/'
- *unit_tests_path
- 'vendor\unity\src\'
defines:
prefix: '-D'
items:
- UNITY_SUPPORT_64
- 'UNITY_SUPPORT_TEST_CASES'
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: [*tools_root, 'sh\bin\ilinksh.exe']
options:
- --redirect __Printf=__PrintfSmall
- --redirect __Scanf=__ScanfSmall
- --config
- [*tools_root, 'sh\config\generic.icf']
- --config_def _CSTACK_SIZE=0x800
- --config_def _HEAP_SIZE=0x800
- --config_def _INT_TABLE=0x10
- --entry __iar_program_start
- --debug_lib
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'sh\bin\shproc.dll']
- [*tools_root, 'sh\bin\shsim.dll']
post_support:
- --plugin
- [*tools_root, 'sh\bin\shbat.dll']
- --backend
- -B
- --core sh2afpu
- -p
- [*tools_root, 'sh\config\debugger\io7264.ddf']
- -d
- sim
---
tools_root: C:\Program Files\IAR Systems\Embedded Workbench 6.0\
colour: true
:unity:
:plugins: []
:tools:
:test_compiler:
:name: compiler
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\bin\iccsh.exe
:arguments:
- "-e"
- "--char_is_signed"
- "-Ol"
- "--no_cse"
- "--no_unroll"
- "--no_inline"
- "--no_code_motion"
- "--no_tbaa"
- "--no_scheduling"
- "--no_clustering"
- "--debug"
- "--dlib_config"
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\inc\DLib_Product.h
- "--double=32"
- "--code_model=huge"
- "--data_model=huge"
- "--core=sh2afpu"
- "--warnings_affect_exit_code"
- "--warnings_are_errors"
- "--mfc"
- "--use_unix_directory_separators"
- "--diag_suppress=Pe161"
- '-I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE'
- '-I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR'
- "-D$: COLLECTION_DEFINES_TEST_AND_VENDOR"
- "${1}"
- "-o ${2}"
:test_linker:
:name: linker
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\bin\ilinksh.exe
:arguments:
- "${1}"
- "--redirect __Printf=__PrintfSmall"
- "--redirect __Scanf=__ScanfSmall"
- "--config"
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\config\generic.icf
- "--config_def _CSTACK_SIZE=0x800"
- "--config_def _HEAP_SIZE=0x800"
- "--config_def _INT_TABLE=0x10"
- "--entry __iar_program_start"
- "--debug_lib"
- "-o ${2}"
:test_fixture:
:name: simulator
:executable:
- C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- common\bin\CSpyBat.exe
:arguments:
- "--silent"
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\bin\shproc.dll
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\bin\shsim.dll
- "${1}"
- "--plugin"
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\bin\shbat.dll
- "--backend"
- "-B"
- "--core sh2afpu"
- "-p"
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\config\debugger\io7264.ddf
- "-d"
- sim
:extension:
:object: ".o"
:executable: ".out"
:paths:
:test:
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\inc\
- - C:\Program Files\IAR Systems\Embedded Workbench 6.0\
- sh\inc\c
- src\
- "..\\src\\"
- testdata/
- tests\
- vendor\unity\src\
:defines:
:test:
- UNITY_SUPPORT_64
- UNITY_SUPPORT_TEST_CASES

View File

@@ -0,0 +1,144 @@
#ifdef TEST_INSTANCES
#include <string.h>
#include <stdint.h>
/* Dividing by these constants produces +/- infinity.
* The rationale is given in UnityAssertFloatIsInf's body.
*/
#ifndef UNITY_EXCLUDE_FLOAT
static const UNITY_FLOAT f_zero = 0.0f;
#endif
#ifndef UNITY_EXCLUDE_DOUBLE
static const UNITY_DOUBLE d_zero = 0.0;
#endif
/* Macros for Catching An Expected Failure or Ignore */
#define EXPECT_ABORT_BEGIN \
startPutcharSpy(); \
if (TEST_PROTECT()) \
{
#define VERIFY_FAILS_END \
} \
endPutcharSpy(); /* start/end Spy to suppress output of failure message */ \
Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \
if (Unity.CurrentTestFailed == 1) { \
SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
UNITY_OUTPUT_CHAR(':'); \
UnityPrint(Unity.CurrentTestName); \
UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \
UNITY_OUTPUT_CHAR('\n'); \
}
#define VERIFY_IGNORES_END \
} \
endPutcharSpy(); /* start/end Spy to suppress output of ignore message */ \
Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \
Unity.CurrentTestIgnored = 0; \
if (Unity.CurrentTestFailed == 1) { \
SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
UNITY_OUTPUT_CHAR(':'); \
UnityPrint(Unity.CurrentTestName); \
UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \
UNITY_OUTPUT_CHAR('\n'); \
}
/* Tricky series of macros to set USING_OUTPUT_SPY */
#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0)
#define ASSIGN_VALUE(a) VAL_##a
#define VAL_putcharSpy 0, 1
#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway)
#define SECOND_PARAM(a, b, ...) b
#if USING_SPY_AS(UNITY_OUTPUT_CHAR)
#define USING_OUTPUT_SPY /* true only if UNITY_OUTPUT_CHAR = putcharSpy */
#endif
#ifdef USING_OUTPUT_SPY
#include <stdio.h>
#define SPY_BUFFER_MAX 40
static char putcharSpyBuffer[SPY_BUFFER_MAX];
#endif
static int indexSpyBuffer;
static int putcharSpyEnabled;
void startPutcharSpy(void)
{
indexSpyBuffer = 0;
putcharSpyEnabled = 1;
}
void endPutcharSpy(void)
{
putcharSpyEnabled = 0;
}
char* getBufferPutcharSpy(void)
{
#ifdef USING_OUTPUT_SPY
putcharSpyBuffer[indexSpyBuffer] = '\0';
return putcharSpyBuffer;
#else
return NULL;
#endif
}
void putcharSpy(int c)
{
#ifdef USING_OUTPUT_SPY
if (putcharSpyEnabled)
{
if (indexSpyBuffer < SPY_BUFFER_MAX - 1)
putcharSpyBuffer[indexSpyBuffer++] = (char)c;
} else
putchar((char)c);
#else
(void)c;
#endif
}
/* This is for counting the calls to the flushSpy */
static int flushSpyEnabled;
static int flushSpyCalls = 0;
void startFlushSpy(void)
{
flushSpyCalls = 0;
flushSpyEnabled = 1;
}
void endFlushSpy(void)
{
flushSpyCalls = 0;
flushSpyEnabled = 0;
}
int getFlushSpyCalls(void)
{
return flushSpyCalls;
}
void flushSpy(void)
{
if (flushSpyEnabled){ flushSpyCalls++; }
}
#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \
startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
}
#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \
startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
}
#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \
startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
}
#endif

View File

@@ -786,7 +786,7 @@ RUNNER_TESTS = [
:options => {
:cmdline_args => true,
},
:cmdline_args => "-n testRunnerGeneratorSma*",
:cmdline_args => "-n=testRunnerGeneratorSma*",
:expected => {
:to_pass => [ 'test_ThisTestAlwaysPasses',
'spec_ThisTestPassesWhenNormalSetupRan',
@@ -1183,15 +1183,7 @@ def runner_test(test, runner, expected, test_defines, cmdline_args, features)
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
cmdline_args ||= ""
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension'] + " #{cmdline_args}"
cmd_str = if simulator.nil?
executable
else
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str, true)
output = runtest(test_base, true, cmdline_args)
#compare to the expected pass/fail
allgood = expected[:to_pass].inject(true) {|s,v| s && verify_match(/#{v}:PASS/, output) }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,371 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity.h"
#define TEST_INSTANCES
#include "self_assessment_utils.h"
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
void testUnitySizeInitializationReminder(void)
{
/* This test ensures that sizeof(struct UNITY_STORAGE_T) doesn't change. If this
* test breaks, go look at the initialization of the Unity global variable
* in unity.c and make sure we're filling in the proper fields. */
const char* message = "Unexpected size for UNITY_STORAGE_T struct. Please check that "
"the initialization of the Unity symbol in unity.c is "
"still correct.";
/* Define a structure with all the same fields as `struct UNITY_STORAGE_T`. */
#ifdef UNITY_EXCLUDE_DETAILS
struct {
const char* TestFile;
const char* CurrentTestName;
UNITY_LINE_TYPE CurrentTestLineNumber;
UNITY_COUNTER_TYPE NumberOfTests;
UNITY_COUNTER_TYPE TestFailures;
UNITY_COUNTER_TYPE TestIgnores;
UNITY_COUNTER_TYPE CurrentTestFailed;
UNITY_COUNTER_TYPE CurrentTestIgnored;
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_TIME_TYPE CurrentTestStartTime;
UNITY_TIME_TYPE CurrentTestStopTime;
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf AbortFrame;
#endif
} _Expected_Unity;
#else
struct {
const char* TestFile;
const char* CurrentTestName;
const char* CurrentDetails1;
const char* CurrentDetails2;
UNITY_LINE_TYPE CurrentTestLineNumber;
UNITY_COUNTER_TYPE NumberOfTests;
UNITY_COUNTER_TYPE TestFailures;
UNITY_COUNTER_TYPE TestIgnores;
UNITY_COUNTER_TYPE CurrentTestFailed;
UNITY_COUNTER_TYPE CurrentTestIgnored;
#ifdef UNITY_INCLUDE_EXEC_TIME
UNITY_COUNTER_TYPE CurrentTestStartTime;
UNITY_COUNTER_TYPE CurrentTestStopTime;
#endif
#ifndef UNITY_EXCLUDE_SETJMP_H
jmp_buf AbortFrame;
#endif
} _Expected_Unity;
#endif
/* Compare our fake structure's size to the actual structure's size. They
* should be the same.
*
* This accounts for alignment, padding, and packing issues that might come
* up between different architectures. */
TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message);
}
void testPassShouldEndImmediatelyWithPass(void)
{
TEST_PASS();
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
}
void testPassShouldEndImmediatelyWithPassAndMessage(void)
{
TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!");
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
}
void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void)
{
TEST_MESSAGE("This is just a message");
TEST_MESSAGE("This is another message");
TEST_PASS();
}
void testMessageShouldDisplayMessageWithoutEndingAndGoOnToFail(void)
{
TEST_MESSAGE("This is yet another message");
EXPECT_ABORT_BEGIN
TEST_FAIL();
VERIFY_FAILS_END
}
void testTrue(void)
{
TEST_ASSERT(1);
TEST_ASSERT_TRUE(1);
}
void testFalse(void)
{
TEST_ASSERT_FALSE(0);
TEST_ASSERT_UNLESS(0);
}
void testSingleStatement(void)
{
for(int i = 0; i < 2; i++)
{
/* TEST_ASSERT_TRUE should expand to a single C statement, minus
* the semicolon. This if-else will fail to compile otherwise. */
if(i > 0)
TEST_ASSERT_TRUE(i);
else
TEST_ASSERT_FALSE(i);
}
}
void testPreviousPass(void)
{
TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures);
}
void testNotVanilla(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT(0);
VERIFY_FAILS_END
}
void testNotTrue(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_TRUE(0);
VERIFY_FAILS_END
}
void testNotFalse(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_FALSE(1);
VERIFY_FAILS_END
}
void testNotUnless(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_UNLESS(1);
VERIFY_FAILS_END
}
void testNotNotEqual(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_NOT_EQUAL(10, 10);
VERIFY_FAILS_END
}
void testFail(void)
{
EXPECT_ABORT_BEGIN
TEST_FAIL_MESSAGE("Expected for testing");
VERIFY_FAILS_END
}
void testIsNull(void)
{
char* ptr1 = NULL;
const char* ptr2 = "hello";
TEST_ASSERT_NULL(ptr1);
TEST_ASSERT_NOT_NULL(ptr2);
}
void testIsNullShouldFailIfNot(void)
{
const char* ptr1 = "hello";
EXPECT_ABORT_BEGIN
TEST_ASSERT_NULL(ptr1);
VERIFY_FAILS_END
}
void testNotNullShouldFailIfNULL(void)
{
char* ptr1 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_NOT_NULL(ptr1);
VERIFY_FAILS_END
}
void testIsEmpty(void)
{
const char* ptr1 = "\0";
const char* ptr2 = "hello";
TEST_ASSERT_EMPTY(ptr1);
TEST_ASSERT_NOT_EMPTY(ptr2);
}
void testIsEmptyShouldFailIfNot(void)
{
const char* ptr1 = "hello";
EXPECT_ABORT_BEGIN
TEST_ASSERT_EMPTY(ptr1);
VERIFY_FAILS_END
}
void testNotEmptyShouldFailIfEmpty(void)
{
const char* ptr1 = "\0";
EXPECT_ABORT_BEGIN
TEST_ASSERT_NOT_EMPTY(ptr1);
VERIFY_FAILS_END
}
void testIgnore(void)
{
EXPECT_ABORT_BEGIN
TEST_IGNORE();
TEST_FAIL_MESSAGE("This should not be reached");
VERIFY_IGNORES_END
}
void testIgnoreMessage(void)
{
EXPECT_ABORT_BEGIN
TEST_IGNORE_MESSAGE("This is an expected TEST_IGNORE_MESSAGE string!");
TEST_FAIL_MESSAGE("This should not be reached");
VERIFY_IGNORES_END
}
void testProtection(void)
{
volatile int mask = 0;
if (TEST_PROTECT())
{
mask |= 1;
TEST_ABORT();
}
else
{
Unity.CurrentTestFailed = 0;
mask |= 2;
}
TEST_ASSERT_EQUAL(3, mask);
}
void testIgnoredAndThenFailInTearDown(void)
{
SetToOneToFailInTearDown = 1;
TEST_IGNORE();
}
void testFailureCountIncrementsAndIsReturnedAtEnd(void)
{
#ifndef USING_OUTPUT_SPY
TEST_IGNORE();
#else
UNITY_UINT savedFailures = Unity.TestFailures;
Unity.CurrentTestFailed = 1;
startPutcharSpy(); /* Suppress output */
startFlushSpy();
TEST_ASSERT_EQUAL(0, getFlushSpyCalls());
UnityConcludeTest();
endPutcharSpy();
TEST_ASSERT_EQUAL(savedFailures + 1, Unity.TestFailures);
#if defined(UNITY_OUTPUT_FLUSH) && defined(UNITY_OUTPUT_FLUSH_HEADER_DECLARATION)
TEST_ASSERT_EQUAL(1, getFlushSpyCalls());
#else
TEST_ASSERT_EQUAL(0, getFlushSpyCalls());
#endif
endFlushSpy();
startPutcharSpy(); /* Suppress output */
int failures = UnityEnd();
Unity.TestFailures--;
endPutcharSpy();
TEST_ASSERT_EQUAL(savedFailures + 1, failures);
#endif
}
/* ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DETAIL SUPPORT ================== */
void testThatDetailsCanBeHandleOneDetail(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAIL("Detail1");
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_INT_MESSAGE(5, 6, "Should Fail And Say Detail1");
VERIFY_FAILS_END
#endif
}
void testThatDetailsCanHandleTestFail(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAILS("Detail1","Detail2");
EXPECT_ABORT_BEGIN
TEST_FAIL_MESSAGE("Should Fail And Say Detail1 and Detail2");
VERIFY_FAILS_END
#endif
}
void testThatDetailsCanBeHandleTwoDetails(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAILS("Detail1","Detail2");
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX8_MESSAGE(7, 8, "Should Fail And Say Detail1 and Detail2");
VERIFY_FAILS_END
#endif
}
void testThatDetailsCanBeHandleSingleDetailClearingTwoDetails(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAILS("Detail1","Detail2");
UNITY_SET_DETAIL("DetailNew");
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_MESSAGE("MEH", "GUH", "Should Fail And Say DetailNew");
VERIFY_FAILS_END
#endif
}

View File

@@ -0,0 +1,773 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity.h"
#define TEST_INSTANCES
#include "self_assessment_utils.h"
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
void testDoublesWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_WITHIN(0.00003, 187245.03485, 187245.03488);
TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0);
TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049);
TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424);
#endif
}
void testDoublesNotWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049);
VERIFY_FAILS_END
#endif
}
void testDoublesEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_DOUBLE(187245123456.0, 187245123456.0);
TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6);
TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699);
TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374);
#endif
}
void testDoublesNotEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualActualNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(85.963, 0.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualExpectedNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 85.963);
VERIFY_FAILS_END
#endif
}
void testDoublesEqualBothNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero);
#endif
}
void testDoublesNotEqualInfNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualNaNInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualActualInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(321.642, 1.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoublesNotEqualExpectedInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 321.642);
VERIFY_FAILS_END
#endif
}
void testDoublesEqualBothInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero);
#endif
}
void testDoublesNotEqualPlusMinusInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleIsPosInf1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_INF(2.0 / d_zero);
#endif
}
void testDoubleIsPosInf2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNegInf1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_NEG_INF(-3.0 / d_zero);
#endif
}
void testDoubleIsNegInf2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(-3.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNotPosInf1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_INF(2.0);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNotPosInf2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0);
#endif
}
void testDoubleIsNotNegInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NEG_INF(-999.876);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNan1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_NAN(0.0 / d_zero);
#endif
}
void testDoubleIsNan2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NOT_NAN(0.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNotNan1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NAN(234.9);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNotNan2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_NOT_NAN(234.9);
#endif
}
void testDoubleInfIsNotNan(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NAN(1.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleNanIsNotInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_INF(0.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleIsDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_DETERMINATE(0.0);
TEST_ASSERT_DOUBLE_IS_DETERMINATE(123.3);
TEST_ASSERT_DOUBLE_IS_DETERMINATE(-88.3);
#endif
}
void testDoubleIsDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-88.3);
VERIFY_FAILS_END
#endif
}
void testDoubleIsNotDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(1.0 / d_zero);
TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-1.0 / d_zero);
TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(0.0 / d_zero);
#endif
}
void testDoubleIsNotDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_DOUBLE_IS_DETERMINATE(-1.0 / d_zero);
VERIFY_FAILS_END
#endif
}
void testDoubleTraitFailsOnInvalidTrait(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
UnityAssertDoubleSpecial(1.0, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT);
VERIFY_FAILS_END
#endif
}
void testEqualDoubleArrays(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, -8.0, 25.4, -0.123};
double p1[] = {1.0, -8.0, 25.4, -0.123};
double p2[] = {1.0, -8.0, 25.4, -0.2};
double p3[] = {1.0, -23.0, 25.0, -0.26};
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 1);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 4);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p2, 3);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p3, 1);
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(NULL, NULL, 1);
#endif
}
void testNotEqualDoubleArraysExpectedNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double* p0 = NULL;
double p1[] = {1.0, 8.0, 25.4, 0.252};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysActualNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.253};
double* p1 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArrays1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.25666666667};
double p1[] = {1.0, 8.0, 25.4, 0.25666666666};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArrays2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.253};
double p1[] = {2.0, 8.0, 25.4, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArrays3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 8.0, 25.4, 0.253};
double p1[] = {1.0, 8.0, 25.5, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -8.0, -25.4, -0.2566666667};
double p1[] = {-1.0, -8.0, -25.4, -0.2566666666};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -8.0, -25.4, -0.253};
double p1[] = {-2.0, -8.0, -25.4, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleArraysNegative3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -8.0, -25.4, -0.253};
double p1[] = {-1.0, -8.0, -25.5, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testEqualDoubleArraysNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 0.0 / d_zero, 25.4, 0.253};
double p1[] = {1.0, 0.0 / d_zero, 25.4, 0.253};
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
#endif
}
void testEqualDoubleArraysInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 1.0 / d_zero, 25.4, 0.253};
double p1[] = {1.0, 1.0 / d_zero, 25.4, 0.253};
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
#endif
}
void testNotEqualDoubleArraysLengthZero(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[1] = {0.0};
double p1[1] = {0.0};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 0);
VERIFY_FAILS_END
#endif
}
void testEqualDoubleEachEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 1.0, 1.0, 1.0};
double p1[] = {-0.123, -0.123, -0.123, -0.123};
double p2[] = {25.4, 25.4, 25.4, -0.2};
double p3[] = {1.0, -23.0, 25.0, -0.26};
TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 1);
TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4);
TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.123, p1, 4);
TEST_ASSERT_EACH_EQUAL_DOUBLE(25.4, p2, 3);
TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p3, 1);
#endif
}
void testNotEqualDoubleEachEqualActualNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double* p0 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(5, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleEachEqual1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {0.253, 8.0, 0.253, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(0.253, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleEachEqual2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {8.0, 8.0, 8.0, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(8.0, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleEachEqual3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0, 1.0, 1.0, 0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleEachEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-1.0, -0.253, -0.253, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(-0.253, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleEachEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-25.4, -8.0, -25.4, -25.4};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(-25.4, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualDoubleEachEqualNegative3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {-8.0, -8.0, -8.0, -0.253};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(-8.0, p0, 4);
VERIFY_FAILS_END
#endif
}
void testEqualDoubleEachEqualNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero, 0.0 / d_zero};
TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0 / d_zero, p0, 4);
#endif
}
void testEqualDoubleEachEqualInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[] = {1.0 / d_zero, 1.0 / d_zero, 25.4, 0.253};
TEST_ASSERT_EACH_EQUAL_DOUBLE(1.0 / d_zero, p0, 2);
#endif
}
void testNotEqualDoubleEachEqualLengthZero(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
TEST_IGNORE();
#else
double p0[1] = {0.0};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_DOUBLE(0.0, p0, 0);
VERIFY_FAILS_END
#endif
}
void testDoublePrinting(void)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499);
TEST_ASSERT_EQUAL_PRINT_FLOATING("5.0000005e-07", 0.00000050000005);
TEST_ASSERT_EQUAL_PRINT_FLOATING("0.100469499", 0.100469499);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 0.9999999995); /*Rounding to int place*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25);
TEST_ASSERT_EQUAL_PRINT_FLOATING("7.99999999", 7.99999999); /*Not rounding*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000002", 16.0000002);
TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000004", 16.0000004);
TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006);
TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("0", -0.0); /* -0 no supported on all targets */
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -0.9999999995); /*Rounding to int place*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.99999999", -7.99999999); /*Not rounding*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000002", -16.0000002);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000004", -16.0000004);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.0000006", -16.0000006);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-999999999", -999999999.0); /*Last full print integer*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.10046949999999999);
TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967295.9);
TEST_ASSERT_EQUAL_PRINT_FLOATING("4.2949673e+09", 4294967296.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 9999999995.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199254740990.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100);
TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200);
TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967296.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100);
#endif
}
void testDoublePrintingRoundTiesToEven(void)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
#ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO
TEST_ASSERT_EQUAL_PRINT_FLOATING("1.00000001e+10", 10000000050.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719925e+15", 9007199245000000.0);
#else /* Default to Round ties to even */
TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000050.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("9.00719924e+15", 9007199245000000.0);
#endif
#endif
}
void testDoublePrintingInfinityAndNaN(void)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_EXCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0 / d_zero);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0 / d_zero);
TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0 / d_zero);
#endif
}

View File

@@ -0,0 +1,884 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity.h"
#define TEST_INSTANCES
#include "self_assessment_utils.h"
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
void testFloatsWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_WITHIN(0.00003f, 187245.03485f, 187245.03488f);
TEST_ASSERT_FLOAT_WITHIN(1.0f, 187245.0f, 187246.0f);
TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2549f, 9273.2049f);
TEST_ASSERT_FLOAT_WITHIN(0.007f, -726.93724f, -726.94424f);
#endif
}
void testFloatsNotWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2649f, 9273.2049f);
VERIFY_FAILS_END
#endif
}
void testFloatsEqual(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_FLOAT(187245.0f, 187246.0f);
TEST_ASSERT_EQUAL_FLOAT(18724.5f, 18724.6f);
TEST_ASSERT_EQUAL_FLOAT(9273.2549f, 9273.2599f);
TEST_ASSERT_EQUAL_FLOAT(-726.93724f, -726.9374f);
#endif
}
void testFloatsNotEqual(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(9273.9649f, 9273.0049f);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(-9273.9649f, -9273.0049f);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(-9273.0049f, -9273.9649f);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualActualNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(85.963f, 0.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualExpectedNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 85.963f);
VERIFY_FAILS_END
#endif
}
void testFloatsEqualBothNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero);
#endif
}
void testFloatsNotEqualInfNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 0.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualNaNInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 1.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualActualInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(321.642f, 1.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatsNotEqualExpectedInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 321.642f);
VERIFY_FAILS_END
#endif
}
void testFloatsEqualBothInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero);
#endif
}
void testFloatsNotEqualPlusMinusInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatIsPosInf1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_INF(2.0f / f_zero);
#endif
}
void testFloatIsPosInf2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatIsNegInf1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_NEG_INF(-3.0f / f_zero);
#endif
}
void testFloatIsNegInf2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(-3.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatIsNotPosInf1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_INF(2.0f);
VERIFY_FAILS_END
#endif
}
void testFloatIsNotPosInf2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f);
#endif
}
void testFloatIsNotNegInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NEG_INF(-999.876f);
VERIFY_FAILS_END
#endif
}
void testFloatIsNan1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_NAN(0.0f / f_zero);
#endif
}
void testFloatIsNan2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NOT_NAN(0.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatIsNotNan1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NAN(234.9f);
VERIFY_FAILS_END
#endif
}
void testFloatIsNotNan2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_NOT_NAN(234.9f);
#endif
}
void testFloatInfIsNotNan(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NAN(1.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatNanIsNotInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_INF(0.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatIsDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_DETERMINATE(0.0f);
TEST_ASSERT_FLOAT_IS_DETERMINATE(123.3f);
TEST_ASSERT_FLOAT_IS_DETERMINATE(-88.3f);
#endif
}
void testFloatIsDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-88.3f);
VERIFY_FAILS_END
#endif
}
void testFloatIsNotDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(1.0f / f_zero);
TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-1.0f / f_zero);
TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(0.0f / f_zero);
#endif
}
void testFloatIsNotDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_FLOAT_IS_DETERMINATE(-1.0f / f_zero);
VERIFY_FAILS_END
#endif
}
void testFloatTraitFailsOnInvalidTrait(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
UnityAssertFloatSpecial(1.0f, NULL, __LINE__, UNITY_FLOAT_INVALID_TRAIT);
VERIFY_FAILS_END
#endif
}
void testEqualFloatArrays(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, -8.0f, 25.4f, -0.123f};
float p1[] = {1.0f, -8.0f, 25.4f, -0.123f};
float p2[] = {1.0f, -8.0f, 25.4f, -0.2f};
float p3[] = {1.0f, -23.0f, 25.0f, -0.26f};
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 1);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 4);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p2, 3);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p3, 1);
TEST_ASSERT_EQUAL_FLOAT_ARRAY(NULL, NULL, 1);
#endif
}
void testNotEqualFloatArraysExpectedNull(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float* p0 = NULL;
float p1[] = {1.0f, 8.0f, 25.4f, 0.252f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysActualNull(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
float* p1 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArrays1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
float p1[] = {1.0f, 8.0f, 25.4f, 0.252f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArrays2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
float p1[] = {2.0f, 8.0f, 25.4f, 0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArrays3(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
float p1[] = {1.0f, 8.0f, 25.5f, 0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysNegative1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f};
float p1[] = {-1.0f, -8.0f, -25.4f, -0.252f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysNegative2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f};
float p1[] = {-2.0f, -8.0f, -25.4f, -0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatArraysNegative3(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f};
float p1[] = {-1.0f, -8.0f, -25.5f, -0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
VERIFY_FAILS_END
#endif
}
void testEqualFloatArraysNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f};
float p1[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f};
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
#endif
}
void testEqualFloatArraysInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f};
float p1[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f};
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
#endif
}
void testNotEqualFloatArraysLengthZero(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[1] = {0.0f};
float p1[1] = {0.0f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 0);
VERIFY_FAILS_END
#endif
}
void testEqualFloatEachEqual(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 1.0f, 1.0f, 1.0f};
float p1[] = {-0.123f, -0.123f, -0.123f, -0.123f};
float p2[] = {25.4f, 25.4f, 25.4f, -0.2f};
float p3[] = {1.0f, -23.0f, 25.0f, -0.26f};
TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 1);
TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 4);
TEST_ASSERT_EACH_EQUAL_FLOAT(-0.123f, p1, 4);
TEST_ASSERT_EACH_EQUAL_FLOAT(25.4f, p2, 3);
TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p3, 1);
#endif
}
void testNotEqualFloatEachEqualActualNull(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float* p0 = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(5, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatEachEqual1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {0.253f, 8.0f, 0.253f, 0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(0.253f, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatEachEqual2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {8.0f, 8.0f, 8.0f, 0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(8.0f, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatEachEqual3(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f, 1.0f, 1.0f, 0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatEachEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-1.0f, -0.253f, -0.253f, -0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(-0.253f, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatEachEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-25.4f, -8.0f, -25.4f, -25.4f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(-25.4f, p0, 4);
VERIFY_FAILS_END
#endif
}
void testNotEqualFloatEachEqualNegative3(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {-8.0f, -8.0f, -8.0f, -0.253f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(-8.0f, p0, 4);
VERIFY_FAILS_END
#endif
}
void testEqualFloatEachEqualNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {0.0f / f_zero, 0.0f / f_zero, 0.0f / f_zero, 0.0f / f_zero};
TEST_ASSERT_EACH_EQUAL_FLOAT(0.0f / f_zero, p0, 4);
#endif
}
void testEqualFloatEachEqualInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[] = {1.0f / f_zero, 1.0f / f_zero, 25.4f, 0.253f};
TEST_ASSERT_EACH_EQUAL_FLOAT(1.0f / f_zero, p0, 2);
#endif
}
void testNotEqualFloatEachEqualLengthZero(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
TEST_IGNORE();
#else
float p0[1] = {0.0f};
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_FLOAT(0.0f, p0, 0);
VERIFY_FAILS_END
#endif
}
void testFloatPrinting(void)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_PRINT_FLOATING("0", 0.0f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-07", 0.000000499f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("0.1004695", 0.100469499f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("2", 1.9999995f); /*Rounding to int place*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("1", 1.0f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1.25", 1.25f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("7.999999", 7.999999f); /*Not rounding*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00002", 16.00002f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00004", 16.00004f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("16.00006", 16.00006f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("9999999", 9999999.0f); /*Last full print integer*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.100469499f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-2", -1.9999995f); /*Rounding to int place*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("-1", -1.0f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-1.25", -1.25f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-7.999999", -7.999999f); /*Not rounding*/
TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00002", -16.00002f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00004", -16.00004f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-16.00006", -16.00006f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-9999999", -9999999.0f); /*Last full print integer*/
/* Fails, prints "4.294968e+09" due to FP math imprecision
* TEST_ASSERT_EQUAL_PRINT_FLOATING("4.294967e+09", 4294967296.0f); */
TEST_ASSERT_EQUAL_PRINT_FLOATING("5e+09", 5000000000.0f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("8e+09", 8.0e+09f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("8.309999e+09", 8309999104.0f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 1.0e+10f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1e+10", 10000000000.0f);
/* Some compilers have trouble with inexact float constants, a float cast works generally */
TEST_ASSERT_EQUAL_PRINT_FLOATING("1.000055e+10", (float)1.000055e+10f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1.1e+38", (float)1.10000005e+38f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("1.635299e+10", 1.63529943e+10f);
/* Fails, prints "3.402824e+38" due to FP math imprecision
* TEST_ASSERT_EQUAL_PRINT_FLOATING("3.402823e+38", 3.40282346638e38f); */
TEST_ASSERT_EQUAL_PRINT_FLOATING("-1e+10", -1.0e+10f);
/* Fails, prints "-3.402824e+38" due to FP math imprecision
* TEST_ASSERT_EQUAL_PRINT_FLOATING("-3.402823e+38", -3.40282346638e38f); */
#endif
}
void testFloatPrintingRoundTiesToEven(void)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
#ifdef UNITY_ROUND_TIES_AWAY_FROM_ZERO
TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882813", 0.00048828125f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.3", 488281.25f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("5.000001e-07", 0.00000050000005f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.000001e-07", -0.00000050000005f);
#else /* Default to Round ties to even */
TEST_ASSERT_EQUAL_PRINT_FLOATING("0.0004882812", 0.00048828125f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("488281.2", 488281.25f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("5e-07", 0.00000050000005f);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-5e-07", -0.00000050000005f);
#endif
#endif
}
void testFloatPrintingInfinityAndNaN(void)
{
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_PRINT_FLOATING("inf", 1.0f / f_zero);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-inf", -1.0f / f_zero);
TEST_ASSERT_EQUAL_PRINT_FLOATING("nan", 0.0f / f_zero);
#endif
}
#if defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) && defined(USING_OUTPUT_SPY)
#ifdef UNITY_INCLUDE_DOUBLE
static void printFloatValue(float f)
{
char expected[18];
startPutcharSpy();
UnityPrintFloat(f);
sprintf(expected, "%.9g", f);
/* We print all NaN's as "nan", not "-nan" */
if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan");
if (strcmp(expected, getBufferPutcharSpy()))
{
/* Fail with diagnostic printing */
TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f);
}
}
#else
static void printFloatValue(float f)
{
char expected[18];
char expected_lower[18];
char expected_lower2[18];
char expected_lower3[18];
char expected_higher[18];
char expected_higher2[18];
char expected_higher3[18];
startPutcharSpy();
UnityPrintFloat(f);
sprintf(expected, "%.7g", f);
/* We print all NaN's as "nan", not "-nan" */
if (strcmp(expected, "-nan") == 0) strcpy(expected, "nan");
strcpy(expected_lower, expected);
strcpy(expected_lower2, expected);
strcpy(expected_lower3, expected);
strcpy(expected_higher, expected);
strcpy(expected_higher2, expected);
strcpy(expected_higher3, expected);
/* Allow for rounding differences in the last digit */
double lower = (double)f * 0.99999995;
double higher = (double)f * 1.00000005;
if(isfinite(lower)) sprintf(expected_lower, "%.7g", lower);
if(isfinite(higher)) sprintf(expected_higher, "%.7g", higher);
/* Outside [1,10000000] allow for relative error of +/-2.5e-7 */
if (f < 1.0 || f > 10000000)
{
double lower2 = (double)f * 0.99999985;
double lower3 = (double)f * 0.99999975;
double higher2 = (double)f * 1.00000015;
double higher3 = (double)f * 1.00000025;
if (isfinite(lower2)) sprintf(expected_lower2, "%.7g", lower2);
if (isfinite(lower3)) sprintf(expected_lower3, "%.7g", lower3);
if (isfinite(higher2)) sprintf(expected_higher2, "%.7g", higher2);
if (isfinite(higher3)) sprintf(expected_higher3, "%.7g", higher3);
}
if (strcmp(expected, getBufferPutcharSpy()) != 0 &&
strcmp(expected_lower, getBufferPutcharSpy()) != 0 &&
strcmp(expected_lower2, getBufferPutcharSpy()) != 0 &&
strcmp(expected_lower3, getBufferPutcharSpy()) != 0 &&
strcmp(expected_higher, getBufferPutcharSpy()) != 0 &&
strcmp(expected_higher2, getBufferPutcharSpy()) != 0 &&
strcmp(expected_higher3, getBufferPutcharSpy()) != 0)
{
/* Fail with diagnostic printing */
TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, f);
}
}
#endif
#endif
void testFloatPrintingRandomSamples(void)
{
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
TEST_IGNORE();
#else
union { float f_value; uint32_t int_value; } u;
/* These values are not covered by the MINSTD generator */
u.int_value = 0x00000000; printFloatValue(u.f_value);
u.int_value = 0x80000000; printFloatValue(u.f_value);
u.int_value = 0x7fffffff; printFloatValue(u.f_value);
u.int_value = 0xffffffff; printFloatValue(u.f_value);
uint32_t a = 1;
for(int num_tested = 0; num_tested < 1000000; num_tested++)
{
/* MINSTD pseudo-random number generator */
a = (uint32_t)(((uint64_t)a * 48271u) % 2147483647u);
/* MINSTD does not set the highest bit; test both possibilities */
u.int_value = a; printFloatValue(u.f_value);
u.int_value = a | 0x80000000; printFloatValue(u.f_value);
}
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,773 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity.h"
#define TEST_INSTANCES
#include "self_assessment_utils.h"
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
void testInt64ArrayWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005};
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
TEST_ASSERT_INT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3);
TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3);
#endif
}
void testInt64ArrayWithinDeltaAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
UNITY_INT64 actualSmallDelta[] = {12345001, -12344996, 12345005};
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message.");
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message.");
#endif
}
void tesUInt64ArrayNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3);
VERIFY_FAILS_END
#endif
}
void testInt64ArrayNotWithinDeltaAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaPointless(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0);
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaPointlessAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaExpectedNull(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3);
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaExpectedNullAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 actualBigDelta[] = {12345101, -12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaActualNull(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN(110, expected, NULL, 3);
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaActualNullAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testInt64ArrayWithinDeltaSamePointer(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3);
#endif
}
void testInt64ArrayWithinDeltaSamePointerAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 expected[] = {12345000, -12344995, 12345005};
TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message.");
#endif
}
void testUInt64ArrayWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005};
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualSmallDelta, 3);
TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 3);
#endif
}
void testUInt64ArrayWithinDeltaAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
UNITY_UINT64 actualSmallDelta[] = {12345001, 12344996, 12345005};
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualSmallDelta, 3, "Custom Message.");
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 3, "Custom Message.");
#endif
}
void testUInt64ArrayNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN(1, expected, actualBigDelta, 3);
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayNotWithinDeltaAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(1, expected, actualBigDelta, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaPointless(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, actualBigDelta, 0);
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaPointlessAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, actualBigDelta, 0, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaExpectedNull(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN(110, NULL, actualBigDelta, 3);
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaExpectedNullAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 actualBigDelta[] = {12345101, 12344896, 12345055};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, NULL, actualBigDelta, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaActualNull(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, NULL, 3);
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaActualNullAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, NULL, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testUInt64ArrayWithinDeltaSamePointer(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
TEST_ASSERT_UINT64_ARRAY_WITHIN(110, expected, expected, 3);
#endif
}
void testUInt64ArrayWithinDeltaSamePointerAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {12345000, 12344995, 12345005};
TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(110, expected, expected, 3, "Custom Message.");
#endif
}
void testHEX64ArrayWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000};
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualSmallDelta, 3);
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 3);
#endif
}
void testHEX64ArrayWithinDeltaAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
UNITY_UINT64 actualSmallDelta[] = {0xABCD123500000000, 0xABCD112100000000, 0xABCD127700000000};
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualSmallDelta, 3, "Custom Message.");
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 3, "Custom Message.");
#endif
}
void testHEX64ArrayNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x100000000, expected, actualBigDelta, 3);
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayNotWithinDeltaAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x100000000, expected, actualBigDelta, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaPointless(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, actualBigDelta, 0);
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaPointlessAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, actualBigDelta, 0, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaExpectedNull(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, NULL, actualBigDelta, 3);
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaExpectedNullAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 actualBigDelta[] = {0xABCD126700000000, 0xABCD118800000000, 0xABCD12AC00000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, NULL, actualBigDelta, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaActualNull(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, NULL, 3);
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaActualNullAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, NULL, 3, "Custom Message.");
VERIFY_FAILS_END
#endif
}
void testHEX64ArrayWithinDeltaSamePointer(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
TEST_ASSERT_HEX64_ARRAY_WITHIN(0x6E00000000, expected, expected, 3);
#endif
}
void testHEX64ArrayWithinDeltaSamePointerAndMessage(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 expected[] = {0xABCD123400000000, 0xABCD112200000000, 0xABCD127700000000};
TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(0x6E00000000, expected, expected, 3, "Custom Message.");
#endif
}
void testEqualHex64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 v0, v1;
UNITY_UINT64 *p0, *p1;
v0 = 0x9876543201234567;
v1 = 0x9876543201234567;
p0 = &v0;
p1 = &v1;
TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, 0x9876543201234567);
TEST_ASSERT_EQUAL_HEX64(v0, v1);
TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, v1);
TEST_ASSERT_EQUAL_HEX64(v0, 0x9876543201234567);
TEST_ASSERT_EQUAL_HEX64(*p0, v1);
TEST_ASSERT_EQUAL_HEX64(*p0, *p1);
TEST_ASSERT_EQUAL_HEX64(*p0, 0x9876543201234567);
#endif
}
void testEqualUint64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 v0, v1;
UNITY_UINT64 *p0, *p1;
v0 = 0x9876543201234567;
v1 = 0x9876543201234567;
p0 = &v0;
p1 = &v1;
TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, 0x9876543201234567);
TEST_ASSERT_EQUAL_UINT64(v0, v1);
TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, v1);
TEST_ASSERT_EQUAL_UINT64(v0, 0x9876543201234567);
TEST_ASSERT_EQUAL_UINT64(*p0, v1);
TEST_ASSERT_EQUAL_UINT64(*p0, *p1);
TEST_ASSERT_EQUAL_UINT64(*p0, 0x9876543201234567);
#endif
}
void testEqualInt64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 v0, v1;
UNITY_INT64 *p0, *p1;
v0 = (UNITY_INT64)0x9876543201234567;
v1 = (UNITY_INT64)0x9876543201234567;
p0 = &v0;
p1 = &v1;
TEST_ASSERT_EQUAL_INT64(0x9876543201234567, 0x9876543201234567);
TEST_ASSERT_EQUAL_INT64(v0, v1);
TEST_ASSERT_EQUAL_INT64(0x9876543201234567, v1);
TEST_ASSERT_EQUAL_INT64(v0, 0x9876543201234567);
TEST_ASSERT_EQUAL_INT64(*p0, v1);
TEST_ASSERT_EQUAL_INT64(*p0, *p1);
TEST_ASSERT_EQUAL_INT64(*p0, 0x9876543201234567);
#endif
}
void testNotEqualHex64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 v0, v1;
v0 = 9000000000;
v1 = 9100000000;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX64(v0, v1);
VERIFY_FAILS_END
#endif
}
void testNotEqualUint64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_UINT64 v0, v1;
v0 = 9000000000;
v1 = 9100000000;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_UINT64(v0, v1);
VERIFY_FAILS_END
#endif
}
void testNotEqualInt64s(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 v0, v1;
v0 = -9000000000;
v1 = 9100000000;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_INT64(v0, v1);
VERIFY_FAILS_END
#endif
}
void testNotEqualHex64sIfSigned(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
UNITY_INT64 v0, v1;
v0 = -9000000000;
v1 = 9000000000;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX64(v0, v1);
VERIFY_FAILS_END
#endif
}
void testHEX64sWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
TEST_ASSERT_HEX64_WITHIN(5, 5000, 4996);
TEST_ASSERT_HEX64_WITHIN(5, 5000, 5005);
#endif
}
void testHEX64sNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
VERIFY_FAILS_END
#endif
}
void testHEX64sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_HEX64_WITHIN(5, 1, -1);
VERIFY_FAILS_END
#endif
}
void testUINT64sWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
TEST_ASSERT_UINT64_WITHIN(5, 5000, 4996);
TEST_ASSERT_UINT64_WITHIN(5, 5000, 5005);
#endif
}
void testUINT64sNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
VERIFY_FAILS_END
#endif
}
void testUINT64sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_UINT64_WITHIN(5, 1, -1);
VERIFY_FAILS_END
#endif
}
void testINT64sWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
TEST_ASSERT_INT64_WITHIN(5, 5000, 4996);
TEST_ASSERT_INT64_WITHIN(5, 5000, 5005);
#endif
}
void testINT64sNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
VERIFY_FAILS_END
#endif
}
void testINT64sNotWithinDeltaAndDifferenceOverflows(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
EXPECT_ABORT_BEGIN
TEST_ASSERT_INT64_WITHIN(1, 0x8000000000000000, 0x7FFFFFFFFFFFFFFF);
VERIFY_FAILS_END
#endif
}
void testPrintNumbersInt64(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
#ifndef USING_OUTPUT_SPY
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_PRINT_NUMBERS("0", 0);
TEST_ASSERT_EQUAL_PRINT_NUMBERS("10000000000", 10000000000);
TEST_ASSERT_EQUAL_PRINT_NUMBERS("-9223372036854775808", (UNITY_INT)0x8000000000000000);
TEST_ASSERT_EQUAL_PRINT_NUMBERS("-1", (UNITY_INT)0xFFFFFFFFFFFFFFFF);
#endif
#endif
}
void testPrintNumbersUInt64(void)
{
#ifndef UNITY_SUPPORT_64
TEST_IGNORE();
#else
#ifndef USING_OUTPUT_SPY
TEST_IGNORE();
#else
TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("0", 0);
TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("70000000000", 70000000000);
TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("9223372036854775808", (UNITY_UINT)0x8000000000000000);
TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS("18446744073709551615", (UNITY_UINT)0xFFFFFFFFFFFFFFFF);
#endif
#endif
}

View File

@@ -0,0 +1,81 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity.h"
#define TEST_INSTANCES
#include "self_assessment_utils.h"
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
void testEqualMemory(void)
{
const char *testString = "whatever";
TEST_ASSERT_EQUAL_MEMORY(testString, testString, 8);
TEST_ASSERT_EQUAL_MEMORY("whatever", "whatever", 8);
TEST_ASSERT_EQUAL_MEMORY("whatever", testString, 8);
TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 8);
TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 2);
TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 1);
}
void testNotEqualMemory1(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_MEMORY("foo", "bar", 3);
VERIFY_FAILS_END
}
void testNotEqualMemory2(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_MEMORY("fool", "food", 4);
VERIFY_FAILS_END
}
void testNotEqualMemory3(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_MEMORY(NULL, "food", 4);
VERIFY_FAILS_END
}
void testNotEqualMemory4(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_MEMORY("fool", NULL, 4);
VERIFY_FAILS_END
}
void testNotEqualMemoryLengthZero(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 0);
VERIFY_FAILS_END
}

View File

@@ -44,8 +44,8 @@ void flushSpy(void) {}
UNITY_OUTPUT_CHAR('\n'); \
}
int SetToOneToFailInTearDown;
int SetToOneMeanWeAlreadyCheckedThisGuy;
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
static unsigned NextExpectedStringIndex;
static unsigned NextExpectedCharIndex;
@@ -127,7 +127,7 @@ TEST_CASE(3, ";")
TEST_CASE(4, "\"quoted\"")
void test_StringsArePreserved(unsigned index, const char * str)
{
static const char * const expected[] =
static const char * const expected[] =
{
"abc",
"{",

View File

@@ -0,0 +1,329 @@
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity.h"
#define TEST_INSTANCES
#include "self_assessment_utils.h"
static int SetToOneToFailInTearDown;
static int SetToOneMeanWeAlreadyCheckedThisGuy;
void setUp(void)
{
SetToOneToFailInTearDown = 0;
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
}
void tearDown(void)
{
endPutcharSpy(); /* Stop suppressing test output */
if (SetToOneToFailInTearDown == 1)
{
/* These will be skipped internally if already failed/ignored */
TEST_FAIL_MESSAGE("<= Failed in tearDown");
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
}
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
{
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
UNITY_OUTPUT_CHAR('\n');
}
}
void testEqualStrings(void)
{
const char *testString = "foo";
TEST_ASSERT_EQUAL_STRING(testString, testString);
TEST_ASSERT_EQUAL_STRING_MESSAGE("foo", "foo", "foo isn't foo");
TEST_ASSERT_EQUAL_STRING("foo", testString);
TEST_ASSERT_EQUAL_STRING(testString, "foo");
TEST_ASSERT_EQUAL_STRING("", "");
}
void testEqualStringsLen(void)
{
const char *testString = "foobar";
TEST_ASSERT_EQUAL_STRING_LEN(testString, testString, strlen(testString));
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE("foobar", "foobaz", 5, "fooba isn't fooba");
TEST_ASSERT_EQUAL_STRING_LEN("foo", testString, 3);
TEST_ASSERT_EQUAL_STRING_LEN(testString, "foo", 3);
TEST_ASSERT_EQUAL_STRING_LEN("", "", 3);
}
void testEqualStringsWithCarriageReturnsAndLineFeeds(void)
{
const char *testString = "foo\r\nbar";
TEST_ASSERT_EQUAL_STRING(testString, testString);
TEST_ASSERT_EQUAL_STRING("foo\r\nbar", "foo\r\nbar");
TEST_ASSERT_EQUAL_STRING("foo\r\nbar", testString);
TEST_ASSERT_EQUAL_STRING(testString, "foo\r\nbar");
TEST_ASSERT_EQUAL_STRING("", "");
}
void testNotEqualString1(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("foo", "bar");
VERIFY_FAILS_END
}
void testNotEqualStringLen1(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 6);
VERIFY_FAILS_END
}
void testNotEqualString2(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("foo", "");
VERIFY_FAILS_END
}
void testNotEqualStringLen2(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_LEN("foo", "", 3);
VERIFY_FAILS_END
}
void testNotEqualString3(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("", "bar");
VERIFY_FAILS_END
}
void testNotEqualStringLen3(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_LEN("", "bar", 3);
VERIFY_FAILS_END
}
void testNotEqualString4(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("bar\r", "bar\n");
VERIFY_FAILS_END
}
void testNotEqualStringLen4(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_LEN("ba\r\x16", "ba\r\n", 4);
VERIFY_FAILS_END
}
void testNotEqualString5(void)
{
const char str1[] = { 0x41, 0x42, 0x03, 0x00 };
const char str2[] = { 0x41, 0x42, 0x04, 0x00 };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING(str1, str2);
VERIFY_FAILS_END
}
void testNotEqualString_ExpectedStringIsNull(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING(NULL, "bar");
VERIFY_FAILS_END
}
void testNotEqualStringLen_ExpectedStringIsNull(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_LEN(NULL, "bar", 1);
VERIFY_FAILS_END
}
void testNotEqualString_ActualStringIsNull(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("foo", NULL);
VERIFY_FAILS_END
}
void testNotEqualStringLen_ActualStringIsNull(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_LEN("foo", NULL, 1);
VERIFY_FAILS_END
}
void testNotEqualString_ExpectedStringIsLonger(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("foo2", "foo");
VERIFY_FAILS_END
}
void testNotEqualString_ActualStringIsLonger(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING("foo", "foo2");
VERIFY_FAILS_END
}
void testEqualStringArrays(void)
{
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, expStrings, 3);
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 3);
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 2);
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 1);
}
void testNotEqualStringArray1(void)
{
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringArray2(void)
{
const char *testStrings[] = { "zoo", "boo", "woo", "moo" };
const char *expStrings[] = { "foo", "boo", "woo", "moo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringArray3(void)
{
const char *testStrings[] = { "foo", "boo", "woo", NULL };
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringArray4(void)
{
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
const char *expStrings[] = { "foo", NULL, "woo", "moo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringArray5(void)
{
const char **testStrings = NULL;
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringArray6(void)
{
const char *testStrings[] = { "foo", "boo", "woo", "zoo" };
const char **expStrings = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
VERIFY_FAILS_END
}
void testEqualStringArrayIfBothNulls(void)
{
const char **testStrings = NULL;
const char **expStrings = NULL;
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
}
void testNotEqualStringArrayLengthZero(void)
{
const char *testStrings[] = {NULL};
const char **expStrings = NULL;
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 0);
VERIFY_FAILS_END
}
void testEqualStringEachEqual(void)
{
const char *testStrings1[] = { "foo", "foo", "foo", "foo" };
const char *testStrings2[] = { "boo", "boo", "boo", "zoo" };
const char *testStrings3[] = { "", "", "", "" };
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 4);
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 1);
TEST_ASSERT_EACH_EQUAL_STRING("boo", testStrings2, 3);
TEST_ASSERT_EACH_EQUAL_STRING("", testStrings3, 4);
}
void testNotEqualStringEachEqual1(void)
{
const char *testStrings[] = { "foo", "foo", "foo", "moo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringEachEqual2(void)
{
const char *testStrings[] = { "boo", "foo", "foo", "foo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringEachEqual3(void)
{
const char *testStrings[] = { "foo", "foo", "foo", NULL };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringEachEqual4(void)
{
const char *testStrings[] = { "foo", "foo", "woo", "foo" };
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
VERIFY_FAILS_END
}
void testNotEqualStringEachEqual5(void)
{
EXPECT_ABORT_BEGIN
TEST_ASSERT_EACH_EQUAL_STRING("foo", NULL, 1);
VERIFY_FAILS_END
}
void testCstringsEscapeSequence(void)
{
#ifndef USING_OUTPUT_SPY
TEST_IGNORE();
#else
startPutcharSpy();
UnityPrint("\x16\x10");
endPutcharSpy();
TEST_ASSERT_EQUAL_STRING("\\x16\\x10", getBufferPutcharSpy());
#endif
}

File diff suppressed because it is too large Load Diff

1
unityConfig.cmake Normal file
View File

@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/unityTargets.cmake)