Commit Graph

324 Commits

Author SHA1 Message Date
jsalling
65e401f3de Always run the tearDown() even if test is ignored 2016-12-24 13:56:04 -06:00
jsalling
46560a8030 Add correct masking behavior on unsigned values 2016-12-23 22:28:37 -06:00
jsalling
5f386a42ff Refactor of IntArray function with switch inside loop, remove repeated code 2016-12-23 22:19:42 -06:00
jsalling
b0870ec8b9 Merge branch 'feature/print-floats'
Fix new type name conflicts

Conflicts:
	src/unity.c
	src/unity_internals.h
2016-12-15 21:15:30 -06:00
Mark VanderVoord
8e31f5d869 Revised internal type naming scheme to better sandbox Unity away from everything else. Sure, short was nice, but not at the expense of naming collisions. 2016-11-29 08:38:51 -05:00
jsalling
aa4d773df2 Tests for Printing All float values
Takes about 10 minutes to run all floats, so split into 3 tests for parallel
running later. This was useful during development for finding hard corner cases
and getting the routine to high quality. Off by default.
Note that all floats 16.0 and up can be represented uniquely (in this format) and will
round-trip back to the exact same float with sscanf(). This property is true for
UnityPrintFloat, despite a few rounding error cases, it will produce output identity.

Better comments and refactor on round ties to even
Add upper threshold value on round to even feature since numerical precision issues
start to give approximations when dividing one large double by another. When tested
on float values, using 1e22 gave the fewest rounding errors.

Fix warnings from gcc. Some float constants do not behave well in existing tests.
Add casts where conversions could be imprecise.
2016-11-19 13:59:19 -06:00
jsalling
25f6417351 Refactor repeated code to print float expected and actual
Move double tests down in the file
2016-11-19 13:52:24 -06:00
jsalling
9f4b1a332f Tests for Printing Floating Point numbers 2016-11-19 13:52:24 -06:00
jsalling
47f6a85b8c Make UnityPrintFloat on by default
Remove UNITY_FLOAT_VERBOSE entirely, add option UNITY_EXCLUDE_FLOAT_PRINT
Remove some questionable float casts from doubles
Default to Round Ties to Even behavior, add option to Round Ties Away from Zero
2016-11-19 13:52:24 -06:00
jsalling
54fe786fae Round ties to even by default, many C libraries follow this
Linux gcc & clang and OSX clang produce output with ties round to even
Windows mingw gcc does not
Example 0.0078125 prints '0.007812'
2016-11-19 13:52:24 -06:00
jsalling
4a27d14734 Correct boundary conditions and add tests 2016-11-19 13:52:24 -06:00
jsalling
1dfcb54491 Start adding tests. Add const and simplify code. 2016-11-19 13:52:24 -06:00
jsalling
393f2cb544 Refactor printing after the decimal point, signed types, small numbers...
Change some types to signed for simpler code and speed
Added format to distinguish small numbers
2016-11-19 13:52:24 -06:00
jsalling
2de0e8285d Key idea is using double precision calculations makes everything better
Print 9 digits
2016-11-19 13:52:24 -06:00
jsalling
e48fe0a07c Reorganize NaN and Inf printing into if-else blocks 2016-11-19 13:51:59 -06:00
jsalling
30ba118c47 Add printing for large numbers in exponential format
Delete old method for printing
2016-11-16 23:00:01 -06:00
jsalling
9653fbf7ac Use an integer cast to print floating point numbers more precisely
Improve printing six decimal places, remove trailing 0's, fix the carry when
numbers like 0.9999999 round up and print leading zeros in the decimal

The first attempt at printing floats had precision issues where the last few
digits would often be wrong. This next approach may yield a better algorithm
for numbers less than 4.29 billion, those that fit in 32 bits.
2016-11-16 20:37:12 -06:00
Mark VanderVoord
ac455f2798 We can’t guarantee that the built-in function insane will return 1. It might return any other non-negative value. Therefore we need to force it to be 1 so we can use the comparison operator later. 2016-11-15 09:29:08 -05:00
jsalling
d4a35f0949 Refactor to delete smaller number decimal format
Generalize loop to print decimal format and exponential
 Add '+' to exponent when printing larger floats
2016-11-12 23:08:54 -06:00
jsalling
6ec7c78b66 Writing a float printing routine 2016-11-12 23:08:54 -06:00
Mark VanderVoord
4ce86fd1c0 Merge pull request #226 from jsalling/feature/nan-not-eq-nan
Add option to set NaN not equal NaN for floating point assertions
2016-10-12 06:54:38 -04:00
jsalling
933cc97364 Add option to set NaN != NaN for floating point assertions 2016-10-10 21:20:10 -05:00
Jeremy Hannon
148b4977cf check 'i' limit before using it as an array index.
fix cppcheck "Array index 'i' is used before limits check."
2016-09-26 16:01:03 -05:00
Mark VanderVoord
dce6d329ff Finished fixing floating point comparisons. We have streamlined how floats and doubles are checked, but we still can't compare them for equality directly. So we're directly testing for infinite and NaN before checking diffs. Also, we've officially decided that for testing purposes NaN shall equal NaN, +Inf shall equal +Inf, and -Inf shall equal -Inf. It's what most people expect during a test. 2016-09-22 08:35:22 -04:00
Mark VanderVoord
0f07adfa00 Merge pull request #202 from kroesche/feature/fix_exclude_fp_warnings
Fix warnings if you use UNITY_EXCLUDE_FLOAT
2016-09-21 20:53:45 -04:00
Mark VanderVoord
7dc17efbb3 Merge pull request #215 from jsalling/bugfix/inf-equals-inf
Bugfix Inf equals Inf
2016-09-21 20:52:58 -04:00
jsalling
af590028fa Unity to print C-style escaped strings as "\x16"
Changes from "\0x16" before, makes it easier to copy strings from output
2016-09-01 01:18:03 -05:00
jsalling
6d54ec2ff7 Get rid of conversion warning when using UNITY_FLOAT_VERBOSE with doubles
Change the parameter of UnityPrintFloat from float to double (_UD)
 The call to snprintf uses implict default promotion to a double anyway
2016-08-27 15:34:10 -05:00
jsalling
54aa838c8a Change the fallback isinf() macro to NOT need f_zero defined
Delete old comments from before math.h was the default isinf() method
2016-08-27 15:27:52 -05:00
jsalling
028ca953d7 Finish checking for equal floats in Arrays functions
Refactor to use the same code everywhere for FloatWithin check
 Rename and fix a few tests for new behavior, infinity == infinity
2016-08-27 15:12:45 -05:00
jsalling
3108aba5c7 If two floats happen to be equal, return right away
Covers the cases where infinity == infinity
2016-08-23 22:36:02 -05:00
Mark VanderVoord
daad2bc82b removed some newer style comments that crept into the codebase. 2016-08-23 06:46:51 -04:00
Mark VanderVoord
57676b5edc - Fixed cases with wildcards in file handling. 2016-07-17 19:11:09 -04:00
Joe Kroesche
f2f073d533 Fix warnings if you use UNITY_EXCLUDE_FLOAT 2016-07-10 20:36:08 -05:00
Mark VanderVoord
1cecab30e8 - Added alias for filter -n of -f
- Added ability to surround filter strings in either type of quotes
- Added ability to filter on multiple test strings as a comma delimited list
- Added ability to filter on test_file:test_name
- Added ability to use alternate syntax for filter of -f="blah"
2016-07-08 17:35:37 -04:00
Mark VanderVoord
eba387fa3e - Add tests which prove command line arguments now work with runner. Fixed a few bugs in this area. 2016-06-27 08:41:58 -04:00
Mark VanderVoord
96f51e8530 Updated method of testing generate_test_runner script to be a FUNCTIONAL test instead of a perfect code match. Backfilled most tests and added some coverage not previously present. Still need to test new command line args and a few cmock details. 2016-06-22 20:57:11 -04:00
Mark VanderVoord
4d3d062b56 Adding command line support. Started with -n (test name matching) -x (test name exclusion).
Script verification hasn't been added yet.
2016-06-21 16:07:10 -04:00
Mark VanderVoord
b3bc196ab3 making new flush routines work under all defined conditions. 2016-06-21 10:01:34 -04:00
Andrzej Bieniek
61dd3f181b Change comments style in unity and test runner to compile with std=c89 2016-05-15 14:35:50 +01:00
Mark VanderVoord
c5c392b18a update UNITY_OUTPUT_CHAR to not return a value (because we never check it anyway).
add UNITY_OUTPUT_FLUSH to make sure we get the output we need on aborted tests and whatnot.
2016-05-06 10:47:39 -04:00
jsalling
b971ec921f Simplify printing StrPointless into a single macro, remove repeated code 2016-05-03 19:52:32 -05:00
jsalling
67a37a4db7 Refactor UnityPrintNumber(), remove unreachable code
Remove what looks like an overflow check. 'divisor' cannot overflow
  since it is the same type as 'number' and cannot be greater.
2016-05-02 23:50:28 -05:00
jsalling
0137f4a8c2 Add option to print FAILED instead of FAIL during the summary
For easier automation and searching for a test suite failure
2016-04-27 21:00:04 -05:00
Rik van der Heijden
23271e81a6 also check for isinf 2016-04-27 10:25:11 +02:00
Rik van der Heijden
74581c357e use isnan instead of comparing floats, fixes #188 2016-04-27 10:17:43 +02:00
Mark VanderVoord
4f2cdb03fc Merge pull request #185 from jsalling/feature/output-declaration
Add Unity Fixture to the travisCI build and restore header declaration of UNITY_OUTPUT_CHAR
2016-04-26 22:53:41 -04:00
Jerry Jacobs
6a02f7e51c Fixup issues when compiling with clang -Wmissing-variable-declarations 2016-04-26 14:17:10 +02:00
jsalling
593a03462e Add an option to omit UNITY_OUTPUT_CHAR declaration from the header
This solves the warnings from -Wredundant-decls when overriding the
  OUTPUT function with a function declared in another header.
 It's better this is the non-default option, since using it requires either
  a declaration of the new function OR a preprocessor guard on declaring
  UNITY_OUTPUT_CHAR (as in unity.c here), in every file using the function.
 See Pull Request #185 for more.
2016-04-24 23:30:19 -05:00
jsalling
573481729b Revert commits 720ea42 and a27b03c which broke the Fixture build
These were aimed at preventing the internals header from declaring
  a prototype for 'int UNITY_OUTPUT_CHAR(int);'. The second part fixed
  an omitted declaration in the tests caused by the first commit.
 Will replace the default behavior & add an option for this in next commit
2016-04-24 23:30:01 -05:00