Commit Graph

119 Commits

Author SHA1 Message Date
Alex Overchenko e4085eb8e6 Using default macro for TEST_CASEs define.
Improving docs about manual definition.
2022-11-27 14:36:22 +03:00
Alex Overchenko 4d5ed3d68b Adding possibility for automatically defining
TEST_CASE & TEST_RANGE macros
2022-11-27 13:05:13 +03:00
Erik Flodin 563786f97c Add support for TEST_RANGE with exclusive end
If the range is <start, end, step> instead of [start, end, step], the
end value will not be included in the range.

This can be useful if you have a define that defines e.g. the size of
something and you want to use this define as the end value. As the
pre-processor doesn't evalutate expressions (unless you do some macro
magic) you can't specify the range as [0, MY_SIZE - 1, 1]. With this
change you can then instead give the range <0, MY_SIZE, 1>.
2022-10-14 18:51:45 +02:00
Erik Flodin 76b7e359cc Improve handling of space in TEST_CASE/RANGE
The fix in 285bb6e282 didn't completly fix the issue.
2022-10-13 22:13:03 +02:00
Mark VanderVoord e54c9787b7 Merge pull request #560 from jonathangjertsen/more-float
Add macros for testing inequalities between floats, doubles
2022-05-25 11:04:56 -04:00
Mark VanderVoord 4389bab82e Support option to specify array length of zero to force pointer comparison. 2022-04-19 17:27:31 -04:00
Mark VanderVoord 0df1d442cb Rearrange details to always print if given, no matter if another msg added or not.
Print output on failures no matter if verbose or not.
Enforce that HEX comparisons are unsigned comparisons.
2022-04-19 16:21:04 -04:00
Jonathan Reichelt Gjertsen b732fbf1ca Add LESS_OR_EQUAL and GREATER_OR_EQUAL assertions for doubles and floats 2021-12-03 20:39:55 +01:00
Jonathan Reichelt Gjertsen 244edf6c16 Add NOT_EQUAL* and NOT_WITHIN* checks for floats and doubles 2021-12-03 19:53:31 +01:00
Jonathan Reichelt Gjertsen 410de1a02b Add macros for testing inequalities between floats, doubles 2021-05-24 17:02:58 +02: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
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
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
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 32e6d93ab0 Fix TEST_ASSERT_HEX64_ARRAY_WITHIN truncating delta to 32 bits. 2019-10-29 16:59:59 -04:00
mvandervoord 354e2b4da6 Added set of assertions for checking CHAR's and CHAR arrays (not as strings) 2019-10-28 16:54:32 -04:00
mvandervoord 60b23dc8a4 Stopped supported -0 as a float output because (a) it is non-portable, only existing on some architectures and (b) relies on the undefined behavior of 1.0/0.0 2019-10-28 13:43:32 -04:00
mvandervoord d16c27b085 - added target for checking ANSI compliance
- fixed ANSI (C89) issues, including #418
2019-10-25 10:17:12 -04:00
John Lindgren 277e844bed Convert RUN_TEST() to a function (generated from an ERB template).
Converting RUN_TEST() from a macro to a function significantly reduces the size
of the compiled binary.  On amd64, the largest test runner in the test suite
(testsample_DefaultsThroughCommandLine_runner.o) was reduced from 3.4 kB to 2.4
kB (stripped).
2019-10-22 15:18:20 -04:00
Mark VanderVoord 0000f1e6d2 Add TEST_MESSAGE for outputting messages without aborting a test and _MESSAGE variant to TEST_PASS collection. 2019-07-06 11:02:32 -04:00
Fabian Zahn 8168382b91 Adjust testHexPrintsUpToMaxNumberOfNibbles (independent of sizeof operator and arithmetics) 2019-05-12 09:16:41 +02:00
Mark VanderVoord d70047881e Merge pull request #377 from elliot-gawthrop/execution-time-embedded
Execution time improvements
2019-05-04 07:53:37 -04:00
Mark VanderVoord 7514de0582 Merge branch 'master' into test-cleanup-gt-lt 2019-05-04 07:28:12 -04:00
Dom Postorivo 9340582797 ARRAY_WITHIN in unity 2019-04-20 14:10:56 -04:00
Dom Postorivo 89465c88b0 Add tests for GREATER_OR_EQUAL, LESS_OR_EQUAL, LESS_THAN, and GREATER_THAN 2019-04-14 15:59:40 -04:00
Dom Postorivo f69fbe8a95 expliticly show test failures of unequal strings 2019-04-13 11:53:14 -04:00
elliot 076f0fff56 Improvements to the execution time feature
- Running time macros have been made more portable, previously it was not
  possible to override all macros
- Running time macros will be executed by default test runner, and auto test
  runners
- Adds a default execution time implementation for unix. (Previous default
  implementation only worked on Windows)
- For embedded platforms there is a simple method of getting a default
  implementation by defining a single macro UNITY_CLOCK_MS()
- Removed need for UNITY_EXEC_TIME_RESET. This was not being used for the default
  implementations, if anything ever did need reset-like functionality it could
  simply be wrapped up with the start or stop macros for that platform
2019-01-31 22:01:20 +00:00
Elliot Gawthrop 5db2a3dbd9 Add support for strings in TEST_CASE() 2018-12-10 20:53:27 +00:00
John Lindgren 39fbd13cae Merge branch 'master' into float-printing 2018-11-28 14:02:41 -05:00
elliot f0e4571c96 Merge branch 'master' into unit-test-execution-time 2018-07-28 20:01:50 +01:00
Fabian Zahn e038ae2ade Refactored the test evaluation of the flushSpy 2018-02-18 18:44:58 +01:00
Fabian Zahn 436a46d8ef Got the tests running 2018-02-18 17:43:08 +01:00
Fabian Zahn 2480a6124e Added unit test for the call to flush 2018-02-18 17:08:49 +01:00
Fabian Zahn 5f67ac6ab2 Fixed copy and paste error, changed the signature from:
void flushSpy(int c) {}
to:
 void flushSpy(void) {}
2018-02-18 16:32:04 +01:00
Fabian Zahn 37271e8a13 Fixed copy and paste error 2018-02-18 14:53:39 +01:00
Fabian Zahn 25804f3ab4 Added flushSpy and the respective helper functions 2018-02-18 14:46:42 +01:00
Fabian Zahn 456759296b Added flushSpy 2018-02-18 14:23:26 +01:00
John Lindgren a6d3f3a59a Restore round-to-even behavior. 2017-11-07 23:25:27 -05:00
John Lindgren 2d4e32cda1 Print 9 digits if we have double precision capability. 2017-11-07 22:44:59 -05:00
John Lindgren 74ba70283a Improve accuracy of UnityPrintFloat() for common cases. 2017-11-07 11:42:19 -05:00
John Lindgren 8ff74d6000 Allow UnityPrintFloat() to print a 7th digit. 2017-11-07 11:42:19 -05:00
balaksh cc909efed3 Implement optional printing of execution time for each test 2017-09-10 13:00:09 +12:00
Mark VanderVoord 7b2ad10c92 Merge pull request #285 from dpostorivo/gt_lt_asserts
Cleanup Greater than and Less than asserts from other PR (#264) (Thanks @dpostorivo and @Dommar92 !)
2017-09-08 13:27:22 -04:00
John Lindgren dbdd168e46 Fix test link error. 2017-08-25 15:47:40 -04:00
John Lindgren 0e7eb545b9 Rewrite UnityPrintFloat to match printf("%.6g").
The existing implementation was not very good:
 - It printed all very small values as "0.000000..."
 - It did not distinguish positive and negative zero
 - In some cases it printed extra garbage digits for single-precision values
   (e.g. 3.9e+30 was printed as 3.90000013+30)

Tests have been updated to check that we now match printf("%.6g") for
1,000,000 randomly chosen values, except for rounding of the 6th digit.
2017-08-25 14:27:37 -04:00