ceedling 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/bin/ceedling +3 -5
  4. data/ceedling-0.21.0.gem +0 -0
  5. data/ceedling.gemspec +1 -0
  6. data/lib/ceedling/configurator.rb +7 -1
  7. data/lib/ceedling/configurator_plugins.rb +21 -21
  8. data/lib/ceedling/generator_test_runner.rb +3 -46
  9. data/lib/ceedling/setupinator.rb +1 -0
  10. data/lib/ceedling/version.rb +4 -4
  11. data/plugins/module_generator/lib/module_generator.rb +14 -127
  12. data/plugins/module_generator/module_generator.rake +15 -3
  13. data/spec/spec_system_helper.rb +1 -1
  14. data/vendor/c_exception/release/build.info +1 -1
  15. data/vendor/c_exception/release/version.info +1 -1
  16. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -146
  17. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +1 -1
  18. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
  19. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +1 -1
  20. data/vendor/c_exception/vendor/unity/examples/unity_config.h +11 -19
  21. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  22. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  23. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  24. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  25. data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +7 -13
  26. data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  27. data/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  28. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  29. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  30. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  31. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  32. data/vendor/c_exception/vendor/unity/release/build.info +1 -1
  33. data/vendor/c_exception/vendor/unity/release/version.info +1 -1
  34. data/vendor/c_exception/vendor/unity/src/unity.c +45 -72
  35. data/vendor/c_exception/vendor/unity/src/unity.h +3 -4
  36. data/vendor/c_exception/vendor/unity/src/unity_internals.h +71 -109
  37. data/vendor/c_exception/vendor/unity/test/Makefile +25 -13
  38. data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +0 -1
  39. data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +0 -1
  40. data/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +11 -5
  41. data/vendor/c_exception/vendor/unity/test/tests/testunity.c +32 -29
  42. data/vendor/cmock/docs/CMock_Summary.md +4 -0
  43. data/vendor/cmock/lib/cmock_config.rb +7 -2
  44. data/vendor/cmock/lib/cmock_generator.rb +9 -1
  45. data/vendor/cmock/release/build.info +1 -1
  46. data/vendor/cmock/release/version.info +1 -1
  47. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +7 -0
  48. data/vendor/cmock/vendor/c_exception/release/build.info +1 -1
  49. data/vendor/cmock/vendor/c_exception/release/version.info +1 -1
  50. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -146
  51. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +1 -1
  52. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
  53. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +1 -1
  54. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/unity_config.h +11 -19
  55. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  56. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  57. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  58. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  59. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +7 -13
  60. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  61. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  62. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  63. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  64. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  65. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  66. data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +1 -1
  67. data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +1 -1
  68. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +45 -72
  69. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +3 -4
  70. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +71 -109
  71. data/vendor/cmock/vendor/c_exception/vendor/unity/test/Makefile +25 -13
  72. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +0 -1
  73. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +0 -1
  74. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +11 -5
  75. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +32 -29
  76. data/vendor/cmock/vendor/unity/auto/generate_module.rb +202 -146
  77. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
  78. data/vendor/cmock/vendor/unity/examples/example_1/makefile +1 -1
  79. data/vendor/cmock/vendor/unity/examples/example_2/makefile +1 -1
  80. data/vendor/cmock/vendor/unity/examples/unity_config.h +11 -19
  81. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  82. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  83. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  84. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  85. data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +7 -13
  86. data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  87. data/vendor/cmock/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  88. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  89. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  90. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  91. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  92. data/vendor/cmock/vendor/unity/release/build.info +1 -1
  93. data/vendor/cmock/vendor/unity/release/version.info +1 -1
  94. data/vendor/cmock/vendor/unity/src/unity.c +45 -72
  95. data/vendor/cmock/vendor/unity/src/unity.h +3 -4
  96. data/vendor/cmock/vendor/unity/src/unity_internals.h +71 -109
  97. data/vendor/cmock/vendor/unity/test/Makefile +25 -13
  98. data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +0 -1
  99. data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +0 -1
  100. data/vendor/cmock/vendor/unity/test/tests/testparameterized.c +11 -5
  101. data/vendor/cmock/vendor/unity/test/tests/testunity.c +32 -29
  102. data/vendor/unity/auto/generate_module.rb +202 -146
  103. data/vendor/unity/auto/generate_test_runner.rb +1 -1
  104. data/vendor/unity/examples/example_1/makefile +1 -1
  105. data/vendor/unity/examples/example_2/makefile +1 -1
  106. data/vendor/unity/examples/unity_config.h +11 -19
  107. data/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  108. data/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  109. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  110. data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  111. data/vendor/unity/extras/fixture/test/Makefile +7 -13
  112. data/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  113. data/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  114. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  115. data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  116. data/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  117. data/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  118. data/vendor/unity/release/build.info +1 -1
  119. data/vendor/unity/release/version.info +1 -1
  120. data/vendor/unity/src/unity.c +45 -72
  121. data/vendor/unity/src/unity.h +3 -4
  122. data/vendor/unity/src/unity_internals.h +71 -109
  123. data/vendor/unity/test/Makefile +25 -13
  124. data/vendor/unity/test/targets/gcc_32.yml +0 -1
  125. data/vendor/unity/test/targets/gcc_64.yml +0 -1
  126. data/vendor/unity/test/tests/testparameterized.c +11 -5
  127. data/vendor/unity/test/tests/testunity.c +32 -29
  128. metadata +17 -6
  129. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
  130. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
  131. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
  132. data/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
@@ -1,9 +1,9 @@
1
- //- Copyright (c) 2010 James Grenning and Contributed to Unity Project
2
- /* ==========================================
3
- Unity Project - A Test Framework for C
4
- Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5
- [Released under MIT License. Please refer to license.txt for details]
6
- ========================================== */
1
+ /* Copyright (c) 2010 James Grenning and Contributed to Unity Project
2
+ * ==========================================
3
+ * Unity Project - A Test Framework for C
4
+ * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5
+ * [Released under MIT License. Please refer to license.txt for details]
6
+ * ========================================== */
7
7
 
8
8
  #include "unity_fixture.h"
9
9
 
@@ -1,9 +1,9 @@
1
- //- Copyright (c) 2010 James Grenning and Contributed to Unity Project
2
- /* ==========================================
3
- Unity Project - A Test Framework for C
4
- Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5
- [Released under MIT License. Please refer to license.txt for details]
6
- ========================================== */
1
+ /* Copyright (c) 2010 James Grenning and Contributed to Unity Project
2
+ * ==========================================
3
+ * Unity Project - A Test Framework for C
4
+ * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5
+ * [Released under MIT License. Please refer to license.txt for details]
6
+ * ========================================== */
7
7
 
8
8
 
9
9
  #include "unity_output_Spy.h"
@@ -1,9 +1,9 @@
1
- //- Copyright (c) 2010 James Grenning and Contributed to Unity Project
2
- /* ==========================================
3
- Unity Project - A Test Framework for C
4
- Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5
- [Released under MIT License. Please refer to license.txt for details]
6
- ========================================== */
1
+ /* Copyright (c) 2010 James Grenning and Contributed to Unity Project
2
+ * ==========================================
3
+ * Unity Project - A Test Framework for C
4
+ * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
5
+ * [Released under MIT License. Please refer to license.txt for details]
6
+ * ========================================== */
7
7
 
8
8
  #ifndef D_unity_output_Spy_H
9
9
  #define D_unity_output_Spy_H
@@ -1,2 +1,2 @@
1
- 119
1
+ 120
2
2
 
@@ -1,2 +1,2 @@
1
- 2.3.2
1
+ 2.4.0
2
2
 
@@ -36,12 +36,14 @@ static const char UnityStrDelta[] = " Values Not Within Delta "
36
36
  static const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless.";
37
37
  static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL";
38
38
  static const char UnityStrNullPointerForActual[] = " Actual pointer was NULL";
39
+ #ifndef UNITY_EXCLUDE_FLOAT
39
40
  static const char UnityStrNot[] = "Not ";
40
41
  static const char UnityStrInf[] = "Infinity";
41
42
  static const char UnityStrNegInf[] = "Negative Infinity";
42
43
  static const char UnityStrNaN[] = "NaN";
43
44
  static const char UnityStrDet[] = "Determinate";
44
45
  static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait";
46
+ #endif
45
47
  const char UnityStrErrFloat[] = "Unity Floating Point Disabled";
46
48
  const char UnityStrErrDouble[] = "Unity Double Precision Disabled";
47
49
  const char UnityStrErr64[] = "Unity 64-bit Support Disabled";
@@ -52,12 +54,6 @@ static const char UnityStrResultsIgnored[] = " Ignored ";
52
54
  static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " ";
53
55
  static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " ";
54
56
 
55
- #ifdef UNITY_FLOAT_NEEDS_ZERO
56
- /* Dividing by these constants produces +/- infinity.
57
- * The rationale is given in UnityAssertFloatIsInf's body. */
58
- static const _UF f_zero = 0.0f;
59
- #endif
60
-
61
57
  /* compiler-generic print formatting masks */
62
58
  static const _U_UINT UnitySizeMask[] =
63
59
  {
@@ -106,6 +102,7 @@ void UnityPrint(const char* string)
106
102
  else
107
103
  {
108
104
  UNITY_OUTPUT_CHAR('\\');
105
+ UNITY_OUTPUT_CHAR('x');
109
106
  UnityPrintNumberHex((_U_UINT)*pch, 2);
110
107
  }
111
108
  pch++;
@@ -143,6 +140,7 @@ void UnityPrintLen(const char* string, const _UU32 length)
143
140
  else
144
141
  {
145
142
  UNITY_OUTPUT_CHAR('\\');
143
+ UNITY_OUTPUT_CHAR('x');
146
144
  UnityPrintNumberHex((_U_UINT)*pch, 2);
147
145
  }
148
146
  pch++;
@@ -163,6 +161,8 @@ void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T s
163
161
  }
164
162
  else
165
163
  {
164
+ UNITY_OUTPUT_CHAR('0');
165
+ UNITY_OUTPUT_CHAR('x');
166
166
  UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
167
167
  }
168
168
  }
@@ -207,8 +207,6 @@ void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
207
207
  {
208
208
  _U_UINT nibble;
209
209
  char nibbles = nibbles_to_print;
210
- UNITY_OUTPUT_CHAR('0');
211
- UNITY_OUTPUT_CHAR('x');
212
210
 
213
211
  while (nibbles > 0)
214
212
  {
@@ -263,7 +261,7 @@ void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
263
261
  # endif
264
262
  #endif
265
263
 
266
- void UnityPrintFloat(_UF number)
264
+ void UnityPrintFloat(_UD number)
267
265
  {
268
266
  char TempBuffer[UNITY_VERBOSE_NUMBER_MAX_LENGTH + 1];
269
267
  snprintf(TempBuffer, sizeof(TempBuffer), "%.6f", number);
@@ -618,7 +616,28 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
618
616
  }
619
617
 
620
618
  /*-----------------------------------------------*/
619
+ /* Wrap this define in a function with variable types as float or double */
620
+ #define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
621
+ if (isinf(expected) && isinf(actual) && (isneg(expected) == isneg(actual))) return 1; \
622
+ if (UNITY_NAN_CHECK) return 1; \
623
+ diff = actual - expected; \
624
+ if (diff < 0.0f) diff = 0.0f - diff; \
625
+ if (delta < 0.0f) delta = 0.0f - delta; \
626
+ return !(isnan(diff) || isinf(diff) || (diff > delta))
627
+ /* This first part of this condition will catch any NaN or Infinite values */
628
+ #ifndef UNITY_NAN_NOT_EQUAL_NAN
629
+ #define UNITY_NAN_CHECK isnan(expected) && isnan(actual)
630
+ #else
631
+ #define UNITY_NAN_CHECK 0
632
+ #endif
633
+
621
634
  #ifndef UNITY_EXCLUDE_FLOAT
635
+ static int UnityFloatsWithin(_UF delta, _UF expected, _UF actual)
636
+ {
637
+ _UF diff;
638
+ UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
639
+ }
640
+
622
641
  void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
623
642
  UNITY_PTR_ATTRIBUTE const _UF* actual,
624
643
  const _UU32 num_elements,
@@ -628,7 +647,6 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
628
647
  _UU32 elements = num_elements;
629
648
  UNITY_PTR_ATTRIBUTE const _UF* ptr_expected = expected;
630
649
  UNITY_PTR_ATTRIBUTE const _UF* ptr_actual = actual;
631
- _UF diff, tol;
632
650
 
633
651
  UNITY_SKIP_EXECUTION;
634
652
 
@@ -642,15 +660,7 @@ void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
642
660
 
643
661
  while (elements--)
644
662
  {
645
- diff = *ptr_expected - *ptr_actual;
646
- if (diff < 0.0f)
647
- diff = 0.0f - diff;
648
- tol = UNITY_FLOAT_PRECISION * *ptr_expected;
649
- if (tol < 0.0f)
650
- tol = 0.0f - tol;
651
-
652
- /* This first part of this condition will catch any NaN or Infinite values */
653
- if (isnan(diff) || isinf(diff) || (diff > tol))
663
+ if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual))
654
664
  {
655
665
  UnityTestResultsFailBegin(lineNumber);
656
666
  UnityPrint(UnityStrElement);
@@ -678,22 +688,10 @@ void UnityAssertFloatsWithin(const _UF delta,
678
688
  const char* msg,
679
689
  const UNITY_LINE_TYPE lineNumber)
680
690
  {
681
- _UF diff = actual - expected;
682
- _UF pos_delta = delta;
683
-
684
691
  UNITY_SKIP_EXECUTION;
685
692
 
686
- if (diff < 0.0f)
687
- {
688
- diff = 0.0f - diff;
689
- }
690
- if (pos_delta < 0.0f)
691
- {
692
- pos_delta = 0.0f - pos_delta;
693
- }
694
693
 
695
- /* This first part of this condition will catch any NaN or Infinite values */
696
- if (isnan(diff) || isinf(diff) || (pos_delta < diff))
694
+ if (!UnityFloatsWithin(delta, expected, actual))
697
695
  {
698
696
  UnityTestResultsFailBegin(lineNumber);
699
697
  #ifdef UNITY_FLOAT_VERBOSE
@@ -724,8 +722,6 @@ void UnityAssertFloatSpecial(const _UF actual,
724
722
 
725
723
  switch(style)
726
724
  {
727
- /* To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
728
- * We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise */
729
725
  case UNITY_FLOAT_IS_INF:
730
726
  case UNITY_FLOAT_IS_NOT_INF:
731
727
  is_trait = isinf(actual) & ispos(actual);
@@ -735,7 +731,6 @@ void UnityAssertFloatSpecial(const _UF actual,
735
731
  is_trait = isinf(actual) & isneg(actual);
736
732
  break;
737
733
 
738
- /* NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN. */
739
734
  case UNITY_FLOAT_IS_NAN:
740
735
  case UNITY_FLOAT_IS_NOT_NAN:
741
736
  is_trait = isnan(actual);
@@ -780,6 +775,12 @@ void UnityAssertFloatSpecial(const _UF actual,
780
775
 
781
776
  /*-----------------------------------------------*/
782
777
  #ifndef UNITY_EXCLUDE_DOUBLE
778
+ static int UnityDoublesWithin(_UD delta, _UD expected, _UD actual)
779
+ {
780
+ _UD diff;
781
+ UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff);
782
+ }
783
+
783
784
  void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
784
785
  UNITY_PTR_ATTRIBUTE const _UD* actual,
785
786
  const _UU32 num_elements,
@@ -789,7 +790,6 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
789
790
  _UU32 elements = num_elements;
790
791
  UNITY_PTR_ATTRIBUTE const _UD* ptr_expected = expected;
791
792
  UNITY_PTR_ATTRIBUTE const _UD* ptr_actual = actual;
792
- _UD diff, tol;
793
793
 
794
794
  UNITY_SKIP_EXECUTION;
795
795
 
@@ -803,15 +803,7 @@ void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
803
803
 
804
804
  while (elements--)
805
805
  {
806
- diff = *ptr_expected - *ptr_actual;
807
- if (diff < 0.0)
808
- diff = 0.0 - diff;
809
- tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
810
- if (tol < 0.0)
811
- tol = 0.0 - tol;
812
-
813
- /* This first part of this condition will catch any NaN or Infinite values */
814
- if (isnan(diff) || isinf(diff) || (diff > tol))
806
+ if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual))
815
807
  {
816
808
  UnityTestResultsFailBegin(lineNumber);
817
809
  UnityPrint(UnityStrElement);
@@ -839,22 +831,9 @@ void UnityAssertDoublesWithin(const _UD delta,
839
831
  const char* msg,
840
832
  const UNITY_LINE_TYPE lineNumber)
841
833
  {
842
- _UD diff = actual - expected;
843
- _UD pos_delta = delta;
844
-
845
834
  UNITY_SKIP_EXECUTION;
846
835
 
847
- if (diff < 0.0)
848
- {
849
- diff = 0.0 - diff;
850
- }
851
- if (pos_delta < 0.0)
852
- {
853
- pos_delta = 0.0 - pos_delta;
854
- }
855
-
856
- /* This first part of this condition will catch any NaN or Infinite values */
857
- if (isnan(diff) || isinf(diff) || (pos_delta < diff))
836
+ if (!UnityDoublesWithin(delta, expected, actual))
858
837
  {
859
838
  UnityTestResultsFailBegin(lineNumber);
860
839
  #ifdef UNITY_DOUBLE_VERBOSE
@@ -886,8 +865,6 @@ void UnityAssertDoubleSpecial(const _UD actual,
886
865
 
887
866
  switch(style)
888
867
  {
889
- /* To determine Inf / Neg Inf, we compare to an Inf / Neg Inf value we create on the fly
890
- * We are using a variable to hold the zero value because some compilers complain about dividing by zero otherwise */
891
868
  case UNITY_FLOAT_IS_INF:
892
869
  case UNITY_FLOAT_IS_NOT_INF:
893
870
  is_trait = isinf(actual) & ispos(actual);
@@ -897,7 +874,6 @@ void UnityAssertDoubleSpecial(const _UD actual,
897
874
  is_trait = isinf(actual) & isneg(actual);
898
875
  break;
899
876
 
900
- /* NaN is the only floating point value that does NOT equal itself. Therefore if Actual == Actual, then it is NOT NaN. */
901
877
  case UNITY_FLOAT_IS_NAN:
902
878
  case UNITY_FLOAT_IS_NOT_NAN:
903
879
  is_trait = isnan(actual);
@@ -1033,7 +1009,7 @@ void UnityAssertEqualStringLen(const char* expected,
1033
1009
  /* if both pointers not null compare the strings */
1034
1010
  if (expected && actual)
1035
1011
  {
1036
- for (i = 0; (expected[i] || actual[i]) && i < length; i++)
1012
+ for (i = 0; (i < length) && (expected[i] || actual[i]); i++)
1037
1013
  {
1038
1014
  if (expected[i] != actual[i])
1039
1015
  {
@@ -1142,7 +1118,6 @@ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
1142
1118
 
1143
1119
  while (elements--)
1144
1120
  {
1145
- /* /////////////////////////////////// */
1146
1121
  bytes = length;
1147
1122
  while (bytes--)
1148
1123
  {
@@ -1167,8 +1142,6 @@ void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected,
1167
1142
  ptr_exp = (UNITY_INTERNAL_PTR)((_UP)ptr_exp + 1);
1168
1143
  ptr_act = (UNITY_INTERNAL_PTR)((_UP)ptr_act + 1);
1169
1144
  }
1170
- /* /////////////////////////////////// */
1171
-
1172
1145
  }
1173
1146
  }
1174
1147
 
@@ -1413,14 +1386,14 @@ int UnityStringArgumentMatches(const char* str)
1413
1386
  const char* ptr2;
1414
1387
  const char* ptrf;
1415
1388
 
1416
- //Go through the options and get the substrings for matching one at a time
1389
+ /* Go through the options and get the substrings for matching one at a time */
1417
1390
  ptr1 = str;
1418
1391
  while (ptr1[0] != 0)
1419
1392
  {
1420
1393
  if ((ptr1[0] == '"') || (ptr1[0] == '\''))
1421
1394
  ptr1++;
1422
1395
 
1423
- //look for the start of the next partial
1396
+ /* look for the start of the next partial */
1424
1397
  ptr2 = ptr1;
1425
1398
  ptrf = 0;
1426
1399
  do {
@@ -1431,26 +1404,26 @@ int UnityStringArgumentMatches(const char* str)
1431
1404
  while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ',')))
1432
1405
  ptr2++;
1433
1406
 
1434
- //done if complete filename match
1407
+ /* done if complete filename match */
1435
1408
  retval = IsStringInBiggerString(Unity.TestFile, ptr1);
1436
1409
  if (retval == 1)
1437
1410
  return retval;
1438
1411
 
1439
- //done if testname match after filename partial match
1412
+ /* done if testname match after filename partial match */
1440
1413
  if ((retval == 2) && (ptrf != 0))
1441
1414
  {
1442
1415
  if (IsStringInBiggerString(Unity.CurrentTestName, ptrf))
1443
1416
  return 1;
1444
1417
  }
1445
1418
 
1446
- //done if complete testname match
1419
+ /* done if complete testname match */
1447
1420
  if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1)
1448
1421
  return 1;
1449
1422
 
1450
1423
  ptr1 = ptr2;
1451
1424
  }
1452
1425
 
1453
- //we couldn't find a match for any substrings
1426
+ /* we couldn't find a match for any substrings */
1454
1427
  return 0;
1455
1428
  }
1456
1429
 
@@ -27,12 +27,11 @@ void tearDown(void);
27
27
  * - Unity attempts to automatically discover your integer sizes
28
28
  * - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h>
29
29
  * - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h>
30
- * - define UNITY_EXCLUDE_SIZEOF to stop attempting to use sizeof in macros
31
30
  * - If you cannot use the automatic methods above, you can force Unity by using these options:
32
31
  * - define UNITY_SUPPORT_64
33
- * - define UNITY_INT_WIDTH
34
- * - UNITY_LONG_WIDTH
35
- * - UNITY_POINTER_WIDTH
32
+ * - set UNITY_INT_WIDTH
33
+ * - set UNITY_LONG_WIDTH
34
+ * - set UNITY_POINTER_WIDTH
36
35
 
37
36
  * Floats
38
37
  * - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons
@@ -13,10 +13,15 @@
13
13
 
14
14
  #include <setjmp.h>
15
15
 
16
+ #ifndef UNITY_EXCLUDE_MATH_H
17
+ #include <math.h>
18
+ #endif
19
+
16
20
  /* Unity Attempts to Auto-Detect Integer Types
17
- * Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h>
18
- * Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h>
19
- * Attempt 3: Deduced from sizeof() macros */
21
+ * Attempt 1: UINT_MAX, ULONG_MAX in <limits.h>, or default to 32 bits
22
+ * Attempt 2: UINTPTR_MAX in <stdint.h>, or default to same size as long
23
+ * The user may override any of these derived constants:
24
+ * UNITY_INT_WIDTH, UNITY_LONG_WIDTH, UNITY_POINTER_WIDTH */
20
25
  #ifndef UNITY_EXCLUDE_STDINT_H
21
26
  #include <stdint.h>
22
27
  #endif
@@ -25,29 +30,13 @@
25
30
  #include <limits.h>
26
31
  #endif
27
32
 
28
- #ifndef UNITY_EXCLUDE_SIZEOF
29
- #ifndef UINT_MAX
30
- #define UINT_MAX (sizeof(unsigned int) * 256 - 1)
31
- #endif
32
- #ifndef ULONG_MAX
33
- #define ULONG_MAX (sizeof(unsigned long) * 256 - 1)
34
- #endif
35
- #ifndef UINTPTR_MAX
36
- /* apparently this is not a constant expression: (sizeof(unsigned int *) * 256 - 1) so we have to just let this fall through */
37
- #endif
38
- #endif
39
-
40
- #ifndef UNITY_EXCLUDE_MATH_H
41
- #include <math.h>
42
- #endif
43
-
44
33
  /*-------------------------------------------------------
45
34
  * Guess Widths If Not Specified
46
35
  *-------------------------------------------------------*/
47
36
 
48
- /* Determine the size of an int, if not already specificied.
37
+ /* Determine the size of an int, if not already specified.
49
38
  * We cannot use sizeof(int), because it is not yet defined
50
- * at this stage in the trnslation of the C program.
39
+ * at this stage in the translation of the C program.
51
40
  * Therefore, infer it from UINT_MAX if possible. */
52
41
  #ifndef UNITY_INT_WIDTH
53
42
  #ifdef UINT_MAX
@@ -58,15 +47,12 @@
58
47
  #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF)
59
48
  #define UNITY_INT_WIDTH (64)
60
49
  #endif
61
- #endif
62
- #endif
63
- #ifndef UNITY_INT_WIDTH
64
- #define UNITY_INT_WIDTH (32)
50
+ #else /* Set to default */
51
+ #define UNITY_INT_WIDTH (32)
52
+ #endif /* UINT_MAX */
65
53
  #endif
66
54
 
67
- /* Determine the size of a long, if not already specified,
68
- * by following the process used above to define
69
- * UNITY_INT_WIDTH. */
55
+ /* Determine the size of a long, if not already specified. */
70
56
  #ifndef UNITY_LONG_WIDTH
71
57
  #ifdef ULONG_MAX
72
58
  #if (ULONG_MAX == 0xFFFF)
@@ -76,39 +62,24 @@
76
62
  #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF)
77
63
  #define UNITY_LONG_WIDTH (64)
78
64
  #endif
79
- #endif
80
- #endif
81
- #ifndef UNITY_LONG_WIDTH
82
- #define UNITY_LONG_WIDTH (32)
65
+ #else /* Set to default */
66
+ #define UNITY_LONG_WIDTH (32)
67
+ #endif /* ULONG_MAX */
83
68
  #endif
84
69
 
85
- /* Determine the size of a pointer, if not already specified,
86
- * by following the process used above to define
87
- * UNITY_INT_WIDTH. */
70
+ /* Determine the size of a pointer, if not already specified. */
88
71
  #ifndef UNITY_POINTER_WIDTH
89
72
  #ifdef UINTPTR_MAX
90
- #if (UINTPTR_MAX+0 <= 0xFFFF)
91
- #define UNITY_POINTER_WIDTH (16)
92
- #elif (UINTPTR_MAX+0 <= 0xFFFFFFFF)
93
- #define UNITY_POINTER_WIDTH (32)
94
- #elif (UINTPTR_MAX+0 <= 0xFFFFFFFFFFFFFFFF)
95
- #define UNITY_POINTER_WIDTH (64)
96
- #endif
97
- #endif
98
- #endif
99
- #ifndef UNITY_POINTER_WIDTH
100
- #ifdef INTPTR_MAX
101
- #if (INTPTR_MAX+0 <= 0x7FFF)
73
+ #if (UINTPTR_MAX <= 0xFFFF)
102
74
  #define UNITY_POINTER_WIDTH (16)
103
- #elif (INTPTR_MAX+0 <= 0x7FFFFFFF)
75
+ #elif (UINTPTR_MAX <= 0xFFFFFFFF)
104
76
  #define UNITY_POINTER_WIDTH (32)
105
- #elif (INTPTR_MAX+0 <= 0x7FFFFFFFFFFFFFFF)
77
+ #elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF)
106
78
  #define UNITY_POINTER_WIDTH (64)
107
79
  #endif
108
- #endif
109
- #endif
110
- #ifndef UNITY_POINTER_WIDTH
111
- #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH
80
+ #else /* Set to default */
81
+ #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH
82
+ #endif /* UINTPTR_MAX */
112
83
  #endif
113
84
 
114
85
  /*-------------------------------------------------------
@@ -138,36 +109,29 @@
138
109
  *-------------------------------------------------------*/
139
110
 
140
111
  #ifndef UNITY_SUPPORT_64
141
- #if UNITY_LONG_WIDTH > 32
142
- #define UNITY_SUPPORT_64
143
- #endif
144
- #endif
145
- #ifndef UNITY_SUPPORT_64
146
- #if UNITY_POINTER_WIDTH > 32
147
- #define UNITY_SUPPORT_64
148
- #endif
112
+ #if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64
113
+ #define UNITY_SUPPORT_64
114
+ #endif
149
115
  #endif
150
116
 
151
117
  #ifndef UNITY_SUPPORT_64
152
-
153
- /* No 64-bit Support */
154
- typedef _UU32 _U_UINT;
155
- typedef _US32 _U_SINT;
156
-
118
+ /* No 64-bit Support */
119
+ typedef _UU32 _U_UINT;
120
+ typedef _US32 _U_SINT;
157
121
  #else
158
122
 
159
- /* 64-bit Support */
160
- #if (UNITY_LONG_WIDTH == 32)
123
+ /* 64-bit Support */
124
+ #if (UNITY_LONG_WIDTH == 32)
161
125
  typedef unsigned long long _UU64;
162
126
  typedef signed long long _US64;
163
- #elif (UNITY_LONG_WIDTH == 64)
127
+ #elif (UNITY_LONG_WIDTH == 64)
164
128
  typedef unsigned long _UU64;
165
129
  typedef signed long _US64;
166
- #else
130
+ #else
167
131
  #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported)
168
- #endif
169
- typedef _UU64 _U_UINT;
170
- typedef _US64 _U_SINT;
132
+ #endif
133
+ typedef _UU64 _U_UINT;
134
+ typedef _US64 _U_SINT;
171
135
 
172
136
  #endif
173
137
 
@@ -225,11 +189,13 @@ typedef _US64 _U_SINT;
225
189
  typedef UNITY_FLOAT_TYPE _UF;
226
190
 
227
191
  #ifndef isinf
228
- #define isinf(n) (((1.0f / f_zero) == n) ? 1 : 0) || (((-1.0f / f_zero) == n) ? 1 : 0)
229
- #define UNITY_FLOAT_NEEDS_ZERO
192
+ /* The value of Inf - Inf is NaN */
193
+ #define isinf(n) (isnan((n) - (n)) && !isnan(n))
230
194
  #endif
231
195
 
232
196
  #ifndef isnan
197
+ /* NaN is the only floating point value that does NOT equal itself.
198
+ * Therefore if n != n, then it is NaN. */
233
199
  #define isnan(n) ((n != n) ? 1 : 0)
234
200
  #endif
235
201
 
@@ -249,32 +215,38 @@ typedef UNITY_FLOAT_TYPE _UF;
249
215
 
250
216
  /* unlike FLOAT, we DON'T include by default */
251
217
  #ifndef UNITY_EXCLUDE_DOUBLE
252
- #ifndef UNITY_INCLUDE_DOUBLE
253
- #define UNITY_EXCLUDE_DOUBLE
254
- #endif
218
+ #ifndef UNITY_INCLUDE_DOUBLE
219
+ #define UNITY_EXCLUDE_DOUBLE
220
+ #endif
255
221
  #endif
256
222
 
257
223
  #ifdef UNITY_EXCLUDE_DOUBLE
258
224
 
259
- /* No Floating Point Support */
260
- #undef UNITY_DOUBLE_PRECISION
261
- #undef UNITY_DOUBLE_TYPE
262
- #undef UNITY_DOUBLE_VERBOSE
225
+ /* No Floating Point Support */
226
+ #undef UNITY_DOUBLE_PRECISION
227
+ #undef UNITY_DOUBLE_TYPE
228
+ #undef UNITY_DOUBLE_VERBOSE
263
229
 
264
- #ifdef UNITY_INCLUDE_DOUBLE
265
- #undef UNITY_INCLUDE_DOUBLE
266
- #endif
230
+ #ifdef UNITY_INCLUDE_DOUBLE
231
+ #undef UNITY_INCLUDE_DOUBLE
232
+ #endif
233
+
234
+ #ifdef UNITY_FLOAT_VERBOSE
235
+ typedef _UF _UD;
236
+ /* For parameter in UnityPrintFloat, double promotion required */
237
+ #endif
267
238
 
268
239
  #else
269
240
 
270
- /* Double Floating Point Support */
271
- #ifndef UNITY_DOUBLE_PRECISION
272
- #define UNITY_DOUBLE_PRECISION (1e-12f)
273
- #endif
274
- #ifndef UNITY_DOUBLE_TYPE
275
- #define UNITY_DOUBLE_TYPE double
276
- #endif
277
- typedef UNITY_DOUBLE_TYPE _UD;
241
+ /* Double Floating Point Support */
242
+ #ifndef UNITY_DOUBLE_PRECISION
243
+ #define UNITY_DOUBLE_PRECISION (1e-12f)
244
+ #endif
245
+
246
+ #ifndef UNITY_DOUBLE_TYPE
247
+ #define UNITY_DOUBLE_TYPE double
248
+ #endif
249
+ typedef UNITY_DOUBLE_TYPE _UD;
278
250
 
279
251
  #endif
280
252
 
@@ -369,13 +341,7 @@ typedef void (*UnityTestFunction)(void);
369
341
 
370
342
  typedef enum
371
343
  {
372
- #if (UNITY_INT_WIDTH == 16)
373
- UNITY_DISPLAY_STYLE_INT = 2 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
374
- #elif (UNITY_INT_WIDTH == 32)
375
- UNITY_DISPLAY_STYLE_INT = 4 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
376
- #elif (UNITY_INT_WIDTH == 64)
377
- UNITY_DISPLAY_STYLE_INT = 8 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
378
- #endif
344
+ UNITY_DISPLAY_STYLE_INT = sizeof(int)+ UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
379
345
  UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT,
380
346
  UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT,
381
347
  UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT,
@@ -383,25 +349,21 @@ typedef enum
383
349
  UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT,
384
350
  #endif
385
351
 
386
- #if (UNITY_INT_WIDTH == 16)
387
- UNITY_DISPLAY_STYLE_UINT = 2 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
388
- #elif (UNITY_INT_WIDTH == 32)
389
- UNITY_DISPLAY_STYLE_UINT = 4 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
390
- #elif (UNITY_INT_WIDTH == 64)
391
- UNITY_DISPLAY_STYLE_UINT = 8 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
392
- #endif
352
+ UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
393
353
  UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT,
394
354
  UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT,
395
355
  UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT,
396
356
  #ifdef UNITY_SUPPORT_64
397
357
  UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT,
398
358
  #endif
359
+
399
360
  UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX,
400
361
  UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX,
401
362
  UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX,
402
363
  #ifdef UNITY_SUPPORT_64
403
364
  UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX,
404
365
  #endif
366
+
405
367
  UNITY_DISPLAY_STYLE_UNKNOWN
406
368
  } UNITY_DISPLAY_STYLE_T;
407
369
 
@@ -482,11 +444,11 @@ void UnityPrintNumberUnsigned(const _U_UINT number);
482
444
  void UnityPrintNumberHex(const _U_UINT number, const char nibbles);
483
445
 
484
446
  #ifdef UNITY_FLOAT_VERBOSE
485
- void UnityPrintFloat(const _UF number);
447
+ void UnityPrintFloat(const _UD number);
486
448
  #endif
487
449
 
488
450
  /*-------------------------------------------------------
489
- * Test Assertion Fuctions
451
+ * Test Assertion Functions
490
452
  *-------------------------------------------------------
491
453
  * Use the macros below this section instead of calling
492
454
  * these directly. The macros have a consistent naming