acpc_dealer 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -2
  3. data/lib/acpc_dealer.rb +6 -2
  4. data/lib/acpc_dealer/version.rb +1 -1
  5. data/vendor/project_acpc_server/Makefile +12 -2
  6. data/vendor/project_acpc_server/README +1 -0
  7. data/vendor/project_acpc_server/example_player.limit.2p.sh +2 -1
  8. data/vendor/project_acpc_server/example_player.limit.3p.sh +2 -1
  9. data/vendor/project_acpc_server/example_player.nolimit.2p.sh +2 -1
  10. data/vendor/project_acpc_server/example_player.nolimit.3p.sh +2 -1
  11. data/vendor/project_acpc_server/kuhn.limit.3p.game +14 -0
  12. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf1.sh +3 -0
  13. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf2.sh +3 -0
  14. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf3.sh +3 -0
  15. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/LICENCE +23 -0
  16. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/Makefile +128 -0
  17. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/README.md +35 -0
  18. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/CExceptionConfig.h +12 -0
  19. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.c +49 -0
  20. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.h +22 -0
  21. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.c +483 -0
  22. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.h +107 -0
  23. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/main.c +84 -0
  24. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.c +252 -0
  25. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.h +21 -0
  26. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.c +45 -0
  27. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.h +27 -0
  28. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player.c +698 -0
  29. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_1.c +324 -0
  30. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_2.c +262 -0
  31. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_3.c +177 -0
  32. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/CExceptionSummary.odt +0 -0
  33. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/CExceptionSummary.pdf +0 -0
  34. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/license.txt +30 -0
  35. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/readme.txt +242 -0
  36. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.c +43 -0
  37. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.h +86 -0
  38. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/build.info +2 -0
  39. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/version.info +2 -0
  40. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/config/production_environment.rb +14 -0
  41. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/config/test_environment.rb +16 -0
  42. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock Summary.odt +0 -0
  43. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock Summary.pdf +0 -0
  44. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock_Summary.md +356 -0
  45. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/license.txt +31 -0
  46. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_FLASH.mac +71 -0
  47. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_RAM.mac +94 -0
  48. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_SIM.mac +67 -0
  49. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_FLASH.xcl +185 -0
  50. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_RAM.xcl +185 -0
  51. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/ioat91sam7x256.ddf +2259 -0
  52. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.dep +3691 -0
  53. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.ewd +1696 -0
  54. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.ewp +2581 -0
  55. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.eww +10 -0
  56. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X-EK.h +61 -0
  57. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.inc +2314 -0
  58. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.rdf +4704 -0
  59. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.tcl +3407 -0
  60. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256_inc.h +2268 -0
  61. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/ioat91sam7x256.h +4380 -0
  62. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/lib_AT91SAM7X256.h +4211 -0
  63. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.cspy.bat +32 -0
  64. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.dbgdt +86 -0
  65. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.dni +42 -0
  66. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.wsdt +76 -0
  67. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/srcIAR/Cstartup.s79 +266 -0
  68. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/srcIAR/Cstartup_SAM7.c +98 -0
  69. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_FLASH.mac +71 -0
  70. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_RAM.mac +94 -0
  71. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_SIM.mac +67 -0
  72. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_FLASH.icf +43 -0
  73. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_RAM.icf +42 -0
  74. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.dep +4204 -0
  75. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.ewd +1906 -0
  76. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.ewp +2426 -0
  77. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.eww +26 -0
  78. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X-EK.h +61 -0
  79. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X256_inc.h +2268 -0
  80. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/lib_AT91SAM7X256.h +4211 -0
  81. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/project.h +30 -0
  82. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +33 -0
  83. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.dbgdt +5 -0
  84. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.dni +18 -0
  85. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.wsdt +74 -0
  86. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +12 -0
  87. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.cspy.bat +33 -0
  88. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.dbgdt +85 -0
  89. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.dni +44 -0
  90. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.wsdt +73 -0
  91. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_Binary.jlink +12 -0
  92. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +12 -0
  93. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_RAM_Debug.jlink +12 -0
  94. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/srcIAR/Cstartup.s +299 -0
  95. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/srcIAR/Cstartup_SAM7.c +98 -0
  96. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock.rb +65 -0
  97. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_config.rb +129 -0
  98. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_file_writer.rb +33 -0
  99. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator.rb +195 -0
  100. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_array.rb +57 -0
  101. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_callback.rb +78 -0
  102. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_cexception.rb +51 -0
  103. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_expect.rb +86 -0
  104. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_ignore.rb +95 -0
  105. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +44 -0
  106. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +74 -0
  107. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_utils.rb +202 -0
  108. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_header_parser.rb +277 -0
  109. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_plugin_manager.rb +40 -0
  110. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_unityhelper_parser.rb +75 -0
  111. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/release/build.info +2 -0
  112. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/release/version.info +2 -0
  113. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock.c +176 -0
  114. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock.h +31 -0
  115. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock_internals.h +43 -0
  116. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/gcc.yml +53 -0
  117. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/iar_arm_v4.yml +108 -0
  118. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/iar_arm_v5.yml +93 -0
  119. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/History.md +27 -0
  120. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Makefile +8 -0
  121. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Readme.md +103 -0
  122. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/package.json +9 -0
  123. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.c +250 -0
  124. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.h +88 -0
  125. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/test.c +34 -0
  126. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_prompt.rb +94 -0
  127. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_reporter.rb +39 -0
  128. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_config.yml +36 -0
  129. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_module.rb +202 -0
  130. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_test_runner.rb +316 -0
  131. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/test_file_filter.rb +23 -0
  132. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/unity_test_summary.rb +139 -0
  133. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.odt +0 -0
  134. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.pdf +0 -0
  135. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.txt +216 -0
  136. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/license.txt +31 -0
  137. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/build.info +2 -0
  138. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/version.info +2 -0
  139. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.c +1146 -0
  140. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.h +245 -0
  141. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity_internals.h +546 -0
  142. data/vendor/project_acpc_server/net.c +0 -0
  143. data/vendor/project_acpc_server/net.h +1 -0
  144. data/vendor/project_acpc_server/tags +298 -0
  145. metadata +158 -26
@@ -0,0 +1,23 @@
1
+ # ==========================================
2
+ # Unity Project - A Test Framework for C
3
+ # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
+ # [Released under MIT License. Please refer to license.txt for details]
5
+ # ==========================================
6
+
7
+ require'yaml'
8
+
9
+ module RakefileHelpers
10
+ class TestFileFilter
11
+ def initialize(all_files = false)
12
+ @all_files = all_files
13
+ if not @all_files == true
14
+ if File.exist?('test_file_filter.yml')
15
+ filters = YAML.load_file( 'test_file_filter.yml' )
16
+ @all_files, @only_files, @exclude_files =
17
+ filters[:all_files], filters[:only_files], filters[:exclude_files]
18
+ end
19
+ end
20
+ end
21
+ attr_accessor :all_files, :only_files, :exclude_files
22
+ end
23
+ end
@@ -0,0 +1,139 @@
1
+ # ==========================================
2
+ # Unity Project - A Test Framework for C
3
+ # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
+ # [Released under MIT License. Please refer to license.txt for details]
5
+ # ==========================================
6
+
7
+ #!/usr/bin/ruby
8
+ #
9
+ # unity_test_summary.rb
10
+ #
11
+ require 'fileutils'
12
+ require 'set'
13
+
14
+ class UnityTestSummary
15
+ include FileUtils::Verbose
16
+
17
+ attr_reader :report, :total_tests, :failures, :ignored
18
+
19
+ def initialize
20
+ @report = ''
21
+ @total_tests = 0
22
+ @failures = 0
23
+ @ignored = 0
24
+ end
25
+
26
+ def run
27
+ # Clean up result file names
28
+ results = @targets.map {|target| target.gsub(/\\/,'/')}
29
+
30
+ # Dig through each result file, looking for details on pass/fail:
31
+ failure_output = []
32
+ ignore_output = []
33
+
34
+ results.each do |result_file|
35
+ lines = File.readlines(result_file).map { |line| line.chomp }
36
+ if lines.length == 0
37
+ raise "Empty test result file: #{result_file}"
38
+ else
39
+ output = get_details(result_file, lines)
40
+ failure_output << output[:failures] unless output[:failures].empty?
41
+ ignore_output << output[:ignores] unless output[:ignores].empty?
42
+ tests,failures,ignored = parse_test_summary(lines)
43
+ @total_tests += tests
44
+ @failures += failures
45
+ @ignored += ignored
46
+ end
47
+ end
48
+
49
+ if @ignored > 0
50
+ @report += "\n"
51
+ @report += "--------------------------\n"
52
+ @report += "UNITY IGNORED TEST SUMMARY\n"
53
+ @report += "--------------------------\n"
54
+ @report += ignore_output.flatten.join("\n")
55
+ end
56
+
57
+ if @failures > 0
58
+ @report += "\n"
59
+ @report += "--------------------------\n"
60
+ @report += "UNITY FAILED TEST SUMMARY\n"
61
+ @report += "--------------------------\n"
62
+ @report += failure_output.flatten.join("\n")
63
+ end
64
+
65
+ @report += "\n"
66
+ @report += "--------------------------\n"
67
+ @report += "OVERALL UNITY TEST SUMMARY\n"
68
+ @report += "--------------------------\n"
69
+ @report += "#{@total_tests} TOTAL TESTS #{@failures} TOTAL FAILURES #{@ignored} IGNORED\n"
70
+ @report += "\n"
71
+ end
72
+
73
+ def set_targets(target_array)
74
+ @targets = target_array
75
+ end
76
+
77
+ def set_root_path(path)
78
+ @root = path
79
+ end
80
+
81
+ def usage(err_msg=nil)
82
+ puts "\nERROR: "
83
+ puts err_msg if err_msg
84
+ puts "\nUsage: unity_test_summary.rb result_file_directory/ root_path/"
85
+ puts " result_file_directory - The location of your results files."
86
+ puts " Defaults to current directory if not specified."
87
+ puts " Should end in / if specified."
88
+ puts " root_path - Helpful for producing more verbose output if using relative paths."
89
+ exit 1
90
+ end
91
+
92
+ protected
93
+
94
+ def get_details(result_file, lines)
95
+ results = { :failures => [], :ignores => [], :successes => [] }
96
+ lines.each do |line|
97
+ src_file,src_line,test_name,status,msg = line.split(/:/)
98
+ line_out = ((@root and (@root != 0)) ? "#{@root}#{line}" : line ).gsub(/\//, "\\")
99
+ case(status)
100
+ when 'IGNORE' then results[:ignores] << line_out
101
+ when 'FAIL' then results[:failures] << line_out
102
+ when 'PASS' then results[:successes] << line_out
103
+ end
104
+ end
105
+ return results
106
+ end
107
+
108
+ def parse_test_summary(summary)
109
+ if summary.find { |v| v =~ /(\d+) Tests (\d+) Failures (\d+) Ignored/ }
110
+ [$1.to_i,$2.to_i,$3.to_i]
111
+ else
112
+ raise "Couldn't parse test results: #{summary}"
113
+ end
114
+ end
115
+
116
+ def here; File.expand_path(File.dirname(__FILE__)); end
117
+
118
+ end
119
+
120
+ if $0 == __FILE__
121
+ uts = UnityTestSummary.new
122
+ begin
123
+ #look in the specified or current directory for result files
124
+ ARGV[0] ||= './'
125
+ targets = "#{ARGV[0].gsub(/\\/, '/')}*.test*"
126
+ results = Dir[targets]
127
+ raise "No *.testpass or *.testfail files found in '#{targets}'" if results.empty?
128
+ uts.set_targets(results)
129
+
130
+ #set the root path
131
+ ARGV[1] ||= File.expand_path(File.dirname(__FILE__)) + '/'
132
+ uts.set_root_path(ARGV[1])
133
+
134
+ #run the summarizer
135
+ puts uts.run
136
+ rescue Exception => e
137
+ uts.usage e.message
138
+ end
139
+ end
@@ -0,0 +1,216 @@
1
+ ==============
2
+ Unity Test API
3
+ ==============
4
+
5
+ [Copyright (c) 2007 - 2012 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams]
6
+
7
+ -------------
8
+ Running Tests
9
+ -------------
10
+
11
+ RUN_TEST(func, linenum)
12
+
13
+ Each Test is run within the macro RUN_TEST. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards.
14
+
15
+ --------------
16
+ Ignoring Tests
17
+ --------------
18
+
19
+ There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned.
20
+
21
+ TEST_IGNORE()
22
+
23
+ Ignore this test and return immediately
24
+
25
+ TEST_IGNORE_MESSAGE (message)
26
+
27
+ Ignore this test and return immediately. Output a message stating why the test was ignored.
28
+
29
+ --------------
30
+ Aborting Tests
31
+ --------------
32
+
33
+ There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first (TEST_PROTECT) sets up the feature, and handles emergency abort cases. TEST_ABORT can then be used at any time within the tests to return to the last TEST_PROTECT call.
34
+
35
+ TEST_PROTECT()
36
+
37
+ Setup and Catch macro
38
+
39
+ TEST_ABORT()
40
+
41
+ Abort Test macro
42
+
43
+ Example:
44
+
45
+ main()
46
+ {
47
+ if (TEST_PROTECT() == 0)
48
+ {
49
+ MyTest();
50
+ }
51
+ }
52
+
53
+ If MyTest calls TEST_ABORT, program control will immediately return to TEST_PROTECT with a non-zero return value.
54
+
55
+
56
+ =======================
57
+ Unity Assertion Summary
58
+ =======================
59
+
60
+ --------------------
61
+ Basic Validity Tests
62
+ --------------------
63
+
64
+ TEST_ASSERT_TRUE(condition)
65
+
66
+ Evaluates whatever code is in condition and fails if it evaluates to false
67
+
68
+ TEST_ASSERT_FALSE(condition)
69
+
70
+ Evaluates whatever code is in condition and fails if it evaluates to true
71
+
72
+ TEST_ASSERT(condition)
73
+
74
+ Another way of calling TEST_ASSERT_TRUE
75
+
76
+ TEST_ASSERT_UNLESS(condition)
77
+
78
+ Another way of calling TEST_ASSERT_FALSE
79
+
80
+ TEST_FAIL()
81
+ TEST_FAIL_MESSAGE(message)
82
+
83
+ This test is automatically marked as a failure. The message is output stating why.
84
+
85
+ ------------------------------
86
+ Numerical Assertions: Integers
87
+ ------------------------------
88
+
89
+ TEST_ASSERT_EQUAL_INT(expected, actual)
90
+ TEST_ASSERT_EQUAL_INT8(expected, actual)
91
+ TEST_ASSERT_EQUAL_INT16(expected, actual)
92
+ TEST_ASSERT_EQUAL_INT32(expected, actual)
93
+ TEST_ASSERT_EQUAL_INT64(expected, actual)
94
+
95
+ Compare two integers for equality and display errors as signed integers. A cast will be performed
96
+ to your natural integer size so often this can just be used. When you need to specify the exact size,
97
+ like when comparing arrays, you can use a specific version:
98
+
99
+ TEST_ASSERT_EQUAL_UINT(expected, actual)
100
+ TEST_ASSERT_EQUAL_UINT8(expected, actual)
101
+ TEST_ASSERT_EQUAL_UINT16(expected, actual)
102
+ TEST_ASSERT_EQUAL_UINT32(expected, actual)
103
+ TEST_ASSERT_EQUAL_UINT64(expected, actual)
104
+
105
+ Compare two integers for equality and display errors as unsigned integers. Like INT, there are
106
+ variants for different sizes also.
107
+
108
+ TEST_ASSERT_EQUAL_HEX(expected, actual)
109
+ TEST_ASSERT_EQUAL_HEX8(expected, actual)
110
+ TEST_ASSERT_EQUAL_HEX16(expected, actual)
111
+ TEST_ASSERT_EQUAL_HEX32(expected, actual)
112
+ TEST_ASSERT_EQUAL_HEX64(expected, actual)
113
+
114
+ Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
115
+ you can specify the size... here the size will also effect how many nibbles are shown (for example, HEX16
116
+ will show 4 nibbles).
117
+
118
+ _ARRAY
119
+
120
+ You can append _ARRAY to any of these macros to make an array comparison of that type. Here you will
121
+ need to care a bit more about the actual size of the value being checked. You will also specify an
122
+ additional argument which is the number of elements to compare. For example:
123
+
124
+ TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)
125
+
126
+ TEST_ASSERT_EQUAL(expected, actual)
127
+
128
+ Another way of calling TEST_ASSERT_EQUAL_INT
129
+
130
+ TEST_ASSERT_INT_WITHIN(delta, expected, actual)
131
+
132
+ Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
133
+ size specific variants.
134
+
135
+
136
+ -----------------------------
137
+ Numerical Assertions: Bitwise
138
+ -----------------------------
139
+
140
+ TEST_ASSERT_BITS(mask, expected, actual)
141
+
142
+ Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored.
143
+
144
+ TEST_ASSERT_BITS_HIGH(mask, actual)
145
+
146
+ Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored.
147
+
148
+ TEST_ASSERT_BITS_LOW(mask, actual)
149
+
150
+ Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored.
151
+
152
+ TEST_ASSERT_BIT_HIGH(bit, actual)
153
+
154
+ Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer.
155
+
156
+ TEST_ASSERT_BIT_LOW(bit, actual)
157
+
158
+ Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer.
159
+
160
+ ----------------------------
161
+ Numerical Assertions: Floats
162
+ ----------------------------
163
+
164
+ TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)
165
+
166
+ Asserts that the actual value is within plus or minus delta of the expected value.
167
+
168
+ TEST_ASSERT_EQUAL_FLOAT(expected, actual)
169
+ TEST_ASSERT_EQUAL_DOUBLE(expected, actual)
170
+
171
+ Asserts that two floating point values are "equal" within a small % delta of the expected value.
172
+
173
+ -----------------
174
+ String Assertions
175
+ -----------------
176
+
177
+ TEST_ASSERT_EQUAL_STRING(expected, actual)
178
+
179
+ Compare two null-terminate strings. Fail if any character is different or if the lengths are different.
180
+
181
+ TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)
182
+
183
+ Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure.
184
+
185
+ ------------------
186
+ Pointer Assertions
187
+ ------------------
188
+
189
+ Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity.
190
+
191
+ TEST_ASSERT_NULL(pointer)
192
+
193
+ Fails if the pointer is not equal to NULL
194
+
195
+ TEST_ASSERT_NOT_NULL(pointer)
196
+
197
+ Fails if the pointer is equal to NULL
198
+
199
+
200
+ -----------------
201
+ Memory Assertions
202
+ -----------------
203
+
204
+ TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
205
+
206
+ Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
207
+ standard types... but since it's a memory compare, you have to be careful that your data types are packed.
208
+
209
+ --------
210
+ _MESSAGE
211
+ --------
212
+
213
+ you can append _MESSAGE to any of the macros to make them take an additional argument. This argument
214
+ is a string that will be printed at the end of the failure strings. This is useful for specifying more
215
+ information about the problem.
216
+
@@ -0,0 +1,31 @@
1
+ Copyright (c) 2007-2010 Mike Karlesky, Mark VanderVoord, Greg Williams
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ The end-user documentation included with the redistribution, if
16
+ any, must include the following acknowledgment: "This product
17
+ includes software developed for the Unity Project, by Mike Karlesky,
18
+ Mark VanderVoord, and Greg Williams and other contributors", in
19
+ the same place and form as other third-party acknowledgments.
20
+ Alternately, this acknowledgment may appear in the software
21
+ itself, in the same form and location as other such third-party
22
+ acknowledgments.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
26
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,1146 @@
1
+ /* ==========================================
2
+ Unity Project - A Test Framework for C
3
+ Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
+ [Released under MIT License. Please refer to license.txt for details]
5
+ ========================================== */
6
+
7
+ #include "unity.h"
8
+ #include <stdio.h>
9
+ #include <string.h>
10
+
11
+ #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_CHAR('\n'); longjmp(Unity.AbortFrame, 1); }
12
+ #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_CHAR('\n'); longjmp(Unity.AbortFrame, 1); }
13
+ /// return prematurely if we are already in failure or ignore state
14
+ #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} }
15
+ #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); }
16
+
17
+ struct _Unity Unity = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , { 0 } };
18
+
19
+ const char* UnityStrNull = "NULL";
20
+ const char* UnityStrSpacer = ". ";
21
+ const char* UnityStrExpected = " Expected ";
22
+ const char* UnityStrWas = " Was ";
23
+ const char* UnityStrTo = " To ";
24
+ const char* UnityStrElement = " Element ";
25
+ const char* UnityStrByte = " Byte ";
26
+ const char* UnityStrMemory = " Memory Mismatch.";
27
+ const char* UnityStrDelta = " Values Not Within Delta ";
28
+ const char* UnityStrPointless= " You Asked Me To Compare Nothing, Which Was Pointless.";
29
+ const char* UnityStrNullPointerForExpected= " Expected pointer to be NULL";
30
+ const char* UnityStrNullPointerForActual = " Actual pointer was NULL";
31
+ const char* UnityStrInf = "Infinity";
32
+ const char* UnityStrNegInf = "Negative Infinity";
33
+ const char* UnityStrNaN = "NaN";
34
+
35
+ #ifndef UNITY_EXCLUDE_FLOAT
36
+ // Dividing by these constants produces +/- infinity.
37
+ // The rationale is given in UnityAssertFloatIsInf's body.
38
+ static const _UF f_zero = 0.0f;
39
+ #ifndef UNITY_EXCLUDE_DOUBLE
40
+ static const _UD d_zero = 0.0;
41
+ #endif
42
+ #endif
43
+
44
+ // compiler-generic print formatting masks
45
+ const _U_UINT UnitySizeMask[] =
46
+ {
47
+ 255u, // 0xFF
48
+ 65535u, // 0xFFFF
49
+ 65535u,
50
+ 4294967295u, // 0xFFFFFFFF
51
+ 4294967295u,
52
+ 4294967295u,
53
+ 4294967295u
54
+ #ifdef UNITY_SUPPORT_64
55
+ ,0xFFFFFFFFFFFFFFFF
56
+ #endif
57
+ };
58
+
59
+ void UnityPrintFail(void);
60
+ void UnityPrintOk(void);
61
+
62
+ //-----------------------------------------------
63
+ // Pretty Printers & Test Result Output Handlers
64
+ //-----------------------------------------------
65
+
66
+ void UnityPrint(const char* string)
67
+ {
68
+ const char* pch = string;
69
+
70
+ if (pch != NULL)
71
+ {
72
+ while (*pch)
73
+ {
74
+ // printable characters plus CR & LF are printed
75
+ if ((*pch <= 126) && (*pch >= 32))
76
+ {
77
+ UNITY_OUTPUT_CHAR(*pch);
78
+ }
79
+ //write escaped carriage returns
80
+ else if (*pch == 13)
81
+ {
82
+ UNITY_OUTPUT_CHAR('\\');
83
+ UNITY_OUTPUT_CHAR('r');
84
+ }
85
+ //write escaped line feeds
86
+ else if (*pch == 10)
87
+ {
88
+ UNITY_OUTPUT_CHAR('\\');
89
+ UNITY_OUTPUT_CHAR('n');
90
+ }
91
+ // unprintable characters are shown as codes
92
+ else
93
+ {
94
+ UNITY_OUTPUT_CHAR('\\');
95
+ UnityPrintNumberHex((_U_SINT)*pch, 2);
96
+ }
97
+ pch++;
98
+ }
99
+ }
100
+ }
101
+
102
+ //-----------------------------------------------
103
+ void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style)
104
+ {
105
+ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
106
+ {
107
+ UnityPrintNumber(number);
108
+ }
109
+ else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT)
110
+ {
111
+ UnityPrintNumberUnsigned( (_U_UINT)number & UnitySizeMask[((_U_UINT)style & (_U_UINT)0x0F) - 1] );
112
+ }
113
+ else
114
+ {
115
+ UnityPrintNumberHex((_U_UINT)number, (style & 0x000F) << 1);
116
+ }
117
+ }
118
+
119
+ //-----------------------------------------------
120
+ /// basically do an itoa using as little ram as possible
121
+ void UnityPrintNumber(const _U_SINT number_to_print)
122
+ {
123
+ _U_SINT divisor = 1;
124
+ _U_SINT next_divisor;
125
+ _U_SINT number = number_to_print;
126
+
127
+ if (number < 0)
128
+ {
129
+ UNITY_OUTPUT_CHAR('-');
130
+ number = -number;
131
+ }
132
+
133
+ // figure out initial divisor
134
+ while (number / divisor > 9)
135
+ {
136
+ next_divisor = divisor * 10;
137
+ if (next_divisor > divisor)
138
+ divisor = next_divisor;
139
+ else
140
+ break;
141
+ }
142
+
143
+ // now mod and print, then divide divisor
144
+ do
145
+ {
146
+ UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
147
+ divisor /= 10;
148
+ }
149
+ while (divisor > 0);
150
+ }
151
+
152
+ //-----------------------------------------------
153
+ /// basically do an itoa using as little ram as possible
154
+ void UnityPrintNumberUnsigned(const _U_UINT number)
155
+ {
156
+ _U_UINT divisor = 1;
157
+ _U_UINT next_divisor;
158
+
159
+ // figure out initial divisor
160
+ while (number / divisor > 9)
161
+ {
162
+ next_divisor = divisor * 10;
163
+ if (next_divisor > divisor)
164
+ divisor = next_divisor;
165
+ else
166
+ break;
167
+ }
168
+
169
+ // now mod and print, then divide divisor
170
+ do
171
+ {
172
+ UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10)));
173
+ divisor /= 10;
174
+ }
175
+ while (divisor > 0);
176
+ }
177
+
178
+ //-----------------------------------------------
179
+ void UnityPrintNumberHex(const _U_UINT number, const char nibbles_to_print)
180
+ {
181
+ _U_UINT nibble;
182
+ char nibbles = nibbles_to_print;
183
+ UNITY_OUTPUT_CHAR('0');
184
+ UNITY_OUTPUT_CHAR('x');
185
+
186
+ while (nibbles > 0)
187
+ {
188
+ nibble = (number >> (--nibbles << 2)) & 0x0000000F;
189
+ if (nibble <= 9)
190
+ {
191
+ UNITY_OUTPUT_CHAR((char)('0' + nibble));
192
+ }
193
+ else
194
+ {
195
+ UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble));
196
+ }
197
+ }
198
+ }
199
+
200
+ //-----------------------------------------------
201
+ void UnityPrintMask(const _U_UINT mask, const _U_UINT number)
202
+ {
203
+ _U_UINT current_bit = (_U_UINT)1 << (UNITY_INT_WIDTH - 1);
204
+ _US32 i;
205
+
206
+ for (i = 0; i < UNITY_INT_WIDTH; i++)
207
+ {
208
+ if (current_bit & mask)
209
+ {
210
+ if (current_bit & number)
211
+ {
212
+ UNITY_OUTPUT_CHAR('1');
213
+ }
214
+ else
215
+ {
216
+ UNITY_OUTPUT_CHAR('0');
217
+ }
218
+ }
219
+ else
220
+ {
221
+ UNITY_OUTPUT_CHAR('X');
222
+ }
223
+ current_bit = current_bit >> 1;
224
+ }
225
+ }
226
+
227
+ //-----------------------------------------------
228
+ #ifdef UNITY_FLOAT_VERBOSE
229
+ void UnityPrintFloat(_UF number)
230
+ {
231
+ char TempBuffer[32];
232
+ sprintf(TempBuffer, "%.6f", number);
233
+ UnityPrint(TempBuffer);
234
+ }
235
+ #endif
236
+
237
+ //-----------------------------------------------
238
+
239
+ void UnityPrintFail(void)
240
+ {
241
+ UnityPrint("FAIL");
242
+ }
243
+
244
+ void UnityPrintOk(void)
245
+ {
246
+ UnityPrint("OK");
247
+ }
248
+
249
+ //-----------------------------------------------
250
+ void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
251
+ {
252
+ UnityPrint(file);
253
+ UNITY_OUTPUT_CHAR(':');
254
+ UnityPrintNumber(line);
255
+ UNITY_OUTPUT_CHAR(':');
256
+ UnityPrint(Unity.CurrentTestName);
257
+ UNITY_OUTPUT_CHAR(':');
258
+ }
259
+
260
+ //-----------------------------------------------
261
+ void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
262
+ {
263
+ UnityTestResultsBegin(Unity.TestFile, line);
264
+ UnityPrint("FAIL:");
265
+ }
266
+
267
+ //-----------------------------------------------
268
+ void UnityConcludeTest(void)
269
+ {
270
+ if (Unity.CurrentTestIgnored)
271
+ {
272
+ Unity.TestIgnores++;
273
+ }
274
+ else if (!Unity.CurrentTestFailed)
275
+ {
276
+ UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber);
277
+ UnityPrint("PASS");
278
+ UNITY_PRINT_EOL;
279
+ }
280
+ else
281
+ {
282
+ Unity.TestFailures++;
283
+ }
284
+
285
+ Unity.CurrentTestFailed = 0;
286
+ Unity.CurrentTestIgnored = 0;
287
+ }
288
+
289
+ //-----------------------------------------------
290
+ void UnityAddMsgIfSpecified(const char* msg)
291
+ {
292
+ if (msg)
293
+ {
294
+ UnityPrint(UnityStrSpacer);
295
+ UnityPrint(msg);
296
+ }
297
+ }
298
+
299
+ //-----------------------------------------------
300
+ void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
301
+ {
302
+ UnityPrint(UnityStrExpected);
303
+ if (expected != NULL)
304
+ {
305
+ UNITY_OUTPUT_CHAR('\'');
306
+ UnityPrint(expected);
307
+ UNITY_OUTPUT_CHAR('\'');
308
+ }
309
+ else
310
+ {
311
+ UnityPrint(UnityStrNull);
312
+ }
313
+ UnityPrint(UnityStrWas);
314
+ if (actual != NULL)
315
+ {
316
+ UNITY_OUTPUT_CHAR('\'');
317
+ UnityPrint(actual);
318
+ UNITY_OUTPUT_CHAR('\'');
319
+ }
320
+ else
321
+ {
322
+ UnityPrint(UnityStrNull);
323
+ }
324
+ }
325
+
326
+ //-----------------------------------------------
327
+ // Assertion & Control Helpers
328
+ //-----------------------------------------------
329
+
330
+ int UnityCheckArraysForNull(const void* expected, const void* actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
331
+ {
332
+ //return true if they are both NULL
333
+ if ((expected == NULL) && (actual == NULL))
334
+ return 1;
335
+
336
+ //throw error if just expected is NULL
337
+ if (expected == NULL)
338
+ {
339
+ UnityTestResultsFailBegin(lineNumber);
340
+ UnityPrint(UnityStrNullPointerForExpected);
341
+ UnityAddMsgIfSpecified(msg);
342
+ UNITY_FAIL_AND_BAIL;
343
+ }
344
+
345
+ //throw error if just actual is NULL
346
+ if (actual == NULL)
347
+ {
348
+ UnityTestResultsFailBegin(lineNumber);
349
+ UnityPrint(UnityStrNullPointerForActual);
350
+ UnityAddMsgIfSpecified(msg);
351
+ UNITY_FAIL_AND_BAIL;
352
+ }
353
+
354
+ //return false if neither is NULL
355
+ return 0;
356
+ }
357
+
358
+ //-----------------------------------------------
359
+ // Assertion Functions
360
+ //-----------------------------------------------
361
+
362
+ void UnityAssertBits(const _U_SINT mask,
363
+ const _U_SINT expected,
364
+ const _U_SINT actual,
365
+ const char* msg,
366
+ const UNITY_LINE_TYPE lineNumber)
367
+ {
368
+ UNITY_SKIP_EXECUTION;
369
+
370
+ if ((mask & expected) != (mask & actual))
371
+ {
372
+ UnityTestResultsFailBegin(lineNumber);
373
+ UnityPrint(UnityStrExpected);
374
+ UnityPrintMask(mask, expected);
375
+ UnityPrint(UnityStrWas);
376
+ UnityPrintMask(mask, actual);
377
+ UnityAddMsgIfSpecified(msg);
378
+ UNITY_FAIL_AND_BAIL;
379
+ }
380
+ }
381
+
382
+ //-----------------------------------------------
383
+ void UnityAssertEqualNumber(const _U_SINT expected,
384
+ const _U_SINT actual,
385
+ const char* msg,
386
+ const UNITY_LINE_TYPE lineNumber,
387
+ const UNITY_DISPLAY_STYLE_T style)
388
+ {
389
+ UNITY_SKIP_EXECUTION;
390
+
391
+ if (expected != actual)
392
+ {
393
+ UnityTestResultsFailBegin(lineNumber);
394
+ UnityPrint(UnityStrExpected);
395
+ UnityPrintNumberByStyle(expected, style);
396
+ UnityPrint(UnityStrWas);
397
+ UnityPrintNumberByStyle(actual, style);
398
+ UnityAddMsgIfSpecified(msg);
399
+ UNITY_FAIL_AND_BAIL;
400
+ }
401
+ }
402
+
403
+ //-----------------------------------------------
404
+ void UnityAssertEqualIntArray(const _U_SINT* expected,
405
+ const _U_SINT* actual,
406
+ const _UU32 num_elements,
407
+ const char* msg,
408
+ const UNITY_LINE_TYPE lineNumber,
409
+ const UNITY_DISPLAY_STYLE_T style)
410
+ {
411
+ _UU32 elements = num_elements;
412
+ const _US8* ptr_exp = (_US8*)expected;
413
+ const _US8* ptr_act = (_US8*)actual;
414
+
415
+ UNITY_SKIP_EXECUTION;
416
+
417
+ if (elements == 0)
418
+ {
419
+ UnityTestResultsFailBegin(lineNumber);
420
+ UnityPrint(UnityStrPointless);
421
+ UnityAddMsgIfSpecified(msg);
422
+ UNITY_FAIL_AND_BAIL;
423
+ }
424
+
425
+ if (UnityCheckArraysForNull((void*)expected, (void*)actual, lineNumber, msg) == 1)
426
+ return;
427
+
428
+ // If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
429
+ // as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
430
+ // variants do not. Therefore remove this flag.
431
+ switch(style & ~UNITY_DISPLAY_RANGE_AUTO)
432
+ {
433
+ case UNITY_DISPLAY_STYLE_HEX8:
434
+ case UNITY_DISPLAY_STYLE_INT8:
435
+ case UNITY_DISPLAY_STYLE_UINT8:
436
+ while (elements--)
437
+ {
438
+ if (*ptr_exp != *ptr_act)
439
+ {
440
+ UnityTestResultsFailBegin(lineNumber);
441
+ UnityPrint(UnityStrElement);
442
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
443
+ UnityPrint(UnityStrExpected);
444
+ UnityPrintNumberByStyle(*ptr_exp, style);
445
+ UnityPrint(UnityStrWas);
446
+ UnityPrintNumberByStyle(*ptr_act, style);
447
+ UnityAddMsgIfSpecified(msg);
448
+ UNITY_FAIL_AND_BAIL;
449
+ }
450
+ ptr_exp += 1;
451
+ ptr_act += 1;
452
+ }
453
+ break;
454
+ case UNITY_DISPLAY_STYLE_HEX16:
455
+ case UNITY_DISPLAY_STYLE_INT16:
456
+ case UNITY_DISPLAY_STYLE_UINT16:
457
+ while (elements--)
458
+ {
459
+ if (*(_US16*)ptr_exp != *(_US16*)ptr_act)
460
+ {
461
+ UnityTestResultsFailBegin(lineNumber);
462
+ UnityPrint(UnityStrElement);
463
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
464
+ UnityPrint(UnityStrExpected);
465
+ UnityPrintNumberByStyle(*(_US16*)ptr_exp, style);
466
+ UnityPrint(UnityStrWas);
467
+ UnityPrintNumberByStyle(*(_US16*)ptr_act, style);
468
+ UnityAddMsgIfSpecified(msg);
469
+ UNITY_FAIL_AND_BAIL;
470
+ }
471
+ ptr_exp += 2;
472
+ ptr_act += 2;
473
+ }
474
+ break;
475
+ #ifdef UNITY_SUPPORT_64
476
+ case UNITY_DISPLAY_STYLE_HEX64:
477
+ case UNITY_DISPLAY_STYLE_INT64:
478
+ case UNITY_DISPLAY_STYLE_UINT64:
479
+ while (elements--)
480
+ {
481
+ if (*(_US64*)ptr_exp != *(_US64*)ptr_act)
482
+ {
483
+ UnityTestResultsFailBegin(lineNumber);
484
+ UnityPrint(UnityStrElement);
485
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
486
+ UnityPrint(UnityStrExpected);
487
+ UnityPrintNumberByStyle(*(_US64*)ptr_exp, style);
488
+ UnityPrint(UnityStrWas);
489
+ UnityPrintNumberByStyle(*(_US64*)ptr_act, style);
490
+ UnityAddMsgIfSpecified(msg);
491
+ UNITY_FAIL_AND_BAIL;
492
+ }
493
+ ptr_exp += 8;
494
+ ptr_act += 8;
495
+ }
496
+ break;
497
+ #endif
498
+ default:
499
+ while (elements--)
500
+ {
501
+ if (*(_US32*)ptr_exp != *(_US32*)ptr_act)
502
+ {
503
+ UnityTestResultsFailBegin(lineNumber);
504
+ UnityPrint(UnityStrElement);
505
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
506
+ UnityPrint(UnityStrExpected);
507
+ UnityPrintNumberByStyle(*(_US32*)ptr_exp, style);
508
+ UnityPrint(UnityStrWas);
509
+ UnityPrintNumberByStyle(*(_US32*)ptr_act, style);
510
+ UnityAddMsgIfSpecified(msg);
511
+ UNITY_FAIL_AND_BAIL;
512
+ }
513
+ ptr_exp += 4;
514
+ ptr_act += 4;
515
+ }
516
+ break;
517
+ }
518
+ }
519
+
520
+ //-----------------------------------------------
521
+ #ifndef UNITY_EXCLUDE_FLOAT
522
+ void UnityAssertEqualFloatArray(const _UF* expected,
523
+ const _UF* actual,
524
+ const _UU32 num_elements,
525
+ const char* msg,
526
+ const UNITY_LINE_TYPE lineNumber)
527
+ {
528
+ _UU32 elements = num_elements;
529
+ const _UF* ptr_expected = expected;
530
+ const _UF* ptr_actual = actual;
531
+ _UF diff, tol;
532
+
533
+ UNITY_SKIP_EXECUTION;
534
+
535
+ if (elements == 0)
536
+ {
537
+ UnityTestResultsFailBegin(lineNumber);
538
+ UnityPrint(UnityStrPointless);
539
+ UnityAddMsgIfSpecified(msg);
540
+ UNITY_FAIL_AND_BAIL;
541
+ }
542
+
543
+ if (UnityCheckArraysForNull((void*)expected, (void*)actual, lineNumber, msg) == 1)
544
+ return;
545
+
546
+ while (elements--)
547
+ {
548
+ diff = *ptr_expected - *ptr_actual;
549
+ if (diff < 0.0f)
550
+ diff = 0.0f - diff;
551
+ tol = UNITY_FLOAT_PRECISION * *ptr_expected;
552
+ if (tol < 0.0f)
553
+ tol = 0.0f - tol;
554
+
555
+ //This first part of this condition will catch any NaN or Infinite values
556
+ if ((diff * 0.0f != 0.0f) || (diff > tol))
557
+ {
558
+ UnityTestResultsFailBegin(lineNumber);
559
+ UnityPrint(UnityStrElement);
560
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
561
+ #ifdef UNITY_FLOAT_VERBOSE
562
+ UnityPrint(UnityStrExpected);
563
+ UnityPrintFloat(*ptr_expected);
564
+ UnityPrint(UnityStrWas);
565
+ UnityPrintFloat(*ptr_actual);
566
+ #else
567
+ UnityPrint(UnityStrDelta);
568
+ #endif
569
+ UnityAddMsgIfSpecified(msg);
570
+ UNITY_FAIL_AND_BAIL;
571
+ }
572
+ ptr_expected++;
573
+ ptr_actual++;
574
+ }
575
+ }
576
+
577
+ //-----------------------------------------------
578
+ void UnityAssertFloatsWithin(const _UF delta,
579
+ const _UF expected,
580
+ const _UF actual,
581
+ const char* msg,
582
+ const UNITY_LINE_TYPE lineNumber)
583
+ {
584
+ _UF diff = actual - expected;
585
+ _UF pos_delta = delta;
586
+
587
+ UNITY_SKIP_EXECUTION;
588
+
589
+ if (diff < 0.0f)
590
+ {
591
+ diff = 0.0f - diff;
592
+ }
593
+ if (pos_delta < 0.0f)
594
+ {
595
+ pos_delta = 0.0f - pos_delta;
596
+ }
597
+
598
+ //This first part of this condition will catch any NaN or Infinite values
599
+ if ((diff * 0.0f != 0.0f) || (pos_delta < diff))
600
+ {
601
+ UnityTestResultsFailBegin(lineNumber);
602
+ #ifdef UNITY_FLOAT_VERBOSE
603
+ UnityPrint(UnityStrExpected);
604
+ UnityPrintFloat(expected);
605
+ UnityPrint(UnityStrWas);
606
+ UnityPrintFloat(actual);
607
+ #else
608
+ UnityPrint(UnityStrDelta);
609
+ #endif
610
+ UnityAddMsgIfSpecified(msg);
611
+ UNITY_FAIL_AND_BAIL;
612
+ }
613
+ }
614
+
615
+ //-----------------------------------------------
616
+ void UnityAssertFloatIsInf(const _UF actual,
617
+ const char* msg,
618
+ const UNITY_LINE_TYPE lineNumber)
619
+ {
620
+ UNITY_SKIP_EXECUTION;
621
+
622
+ // In Microsoft Visual C++ Express Edition 2008,
623
+ // if ((1.0f / f_zero) != actual)
624
+ // produces
625
+ // error C2124: divide or mod by zero
626
+ // As a workaround, place 0 into a variable.
627
+ if ((1.0f / f_zero) != actual)
628
+ {
629
+ UnityTestResultsFailBegin(lineNumber);
630
+ #ifdef UNITY_FLOAT_VERBOSE
631
+ UnityPrint(UnityStrExpected);
632
+ UnityPrint(UnityStrInf);
633
+ UnityPrint(UnityStrWas);
634
+ UnityPrintFloat(actual);
635
+ #else
636
+ UnityPrint(UnityStrDelta);
637
+ #endif
638
+ UnityAddMsgIfSpecified(msg);
639
+ UNITY_FAIL_AND_BAIL;
640
+ }
641
+ }
642
+
643
+ //-----------------------------------------------
644
+ void UnityAssertFloatIsNegInf(const _UF actual,
645
+ const char* msg,
646
+ const UNITY_LINE_TYPE lineNumber)
647
+ {
648
+ UNITY_SKIP_EXECUTION;
649
+
650
+ // The rationale for not using 1.0f/0.0f is given in UnityAssertFloatIsInf's body.
651
+ if ((-1.0f / f_zero) != actual)
652
+ {
653
+ UnityTestResultsFailBegin(lineNumber);
654
+ #ifdef UNITY_FLOAT_VERBOSE
655
+ UnityPrint(UnityStrExpected);
656
+ UnityPrint(UnityStrNegInf);
657
+ UnityPrint(UnityStrWas);
658
+ UnityPrintFloat(actual);
659
+ #else
660
+ UnityPrint(UnityStrDelta);
661
+ #endif
662
+ UnityAddMsgIfSpecified(msg);
663
+ UNITY_FAIL_AND_BAIL;
664
+ }
665
+ }
666
+
667
+ //-----------------------------------------------
668
+ void UnityAssertFloatIsNaN(const _UF actual,
669
+ const char* msg,
670
+ const UNITY_LINE_TYPE lineNumber)
671
+ {
672
+ UNITY_SKIP_EXECUTION;
673
+
674
+ if (actual == actual)
675
+ {
676
+ UnityTestResultsFailBegin(lineNumber);
677
+ #ifdef UNITY_FLOAT_VERBOSE
678
+ UnityPrint(UnityStrExpected);
679
+ UnityPrint(UnityStrNaN);
680
+ UnityPrint(UnityStrWas);
681
+ UnityPrintFloat(actual);
682
+ #else
683
+ UnityPrint(UnityStrDelta);
684
+ #endif
685
+ UnityAddMsgIfSpecified(msg);
686
+ UNITY_FAIL_AND_BAIL;
687
+ }
688
+ }
689
+
690
+ #endif //not UNITY_EXCLUDE_FLOAT
691
+
692
+ //-----------------------------------------------
693
+ #ifndef UNITY_EXCLUDE_DOUBLE
694
+ void UnityAssertEqualDoubleArray(const _UD* expected,
695
+ const _UD* actual,
696
+ const _UU32 num_elements,
697
+ const char* msg,
698
+ const UNITY_LINE_TYPE lineNumber)
699
+ {
700
+ _UU32 elements = num_elements;
701
+ const _UD* ptr_expected = expected;
702
+ const _UD* ptr_actual = actual;
703
+ _UD diff, tol;
704
+
705
+ UNITY_SKIP_EXECUTION;
706
+
707
+ if (elements == 0)
708
+ {
709
+ UnityTestResultsFailBegin(lineNumber);
710
+ UnityPrint(UnityStrPointless);
711
+ UnityAddMsgIfSpecified(msg);
712
+ UNITY_FAIL_AND_BAIL;
713
+ }
714
+
715
+ if (UnityCheckArraysForNull((void*)expected, (void*)actual, lineNumber, msg) == 1)
716
+ return;
717
+
718
+ while (elements--)
719
+ {
720
+ diff = *ptr_expected - *ptr_actual;
721
+ if (diff < 0.0)
722
+ diff = 0.0 - diff;
723
+ tol = UNITY_DOUBLE_PRECISION * *ptr_expected;
724
+ if (tol < 0.0)
725
+ tol = 0.0 - tol;
726
+
727
+ //This first part of this condition will catch any NaN or Infinite values
728
+ if ((diff * 0.0 != 0.0) || (diff > tol))
729
+ {
730
+ UnityTestResultsFailBegin(lineNumber);
731
+ UnityPrint(UnityStrElement);
732
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
733
+ #ifdef UNITY_DOUBLE_VERBOSE
734
+ UnityPrint(UnityStrExpected);
735
+ UnityPrintFloat((float)(*ptr_expected));
736
+ UnityPrint(UnityStrWas);
737
+ UnityPrintFloat((float)(*ptr_actual));
738
+ #else
739
+ UnityPrint(UnityStrDelta);
740
+ #endif
741
+ UnityAddMsgIfSpecified(msg);
742
+ UNITY_FAIL_AND_BAIL;
743
+ }
744
+ ptr_expected++;
745
+ ptr_actual++;
746
+ }
747
+ }
748
+
749
+ //-----------------------------------------------
750
+ void UnityAssertDoublesWithin(const _UD delta,
751
+ const _UD expected,
752
+ const _UD actual,
753
+ const char* msg,
754
+ const UNITY_LINE_TYPE lineNumber)
755
+ {
756
+ _UD diff = actual - expected;
757
+ _UD pos_delta = delta;
758
+
759
+ UNITY_SKIP_EXECUTION;
760
+
761
+ if (diff < 0.0)
762
+ {
763
+ diff = 0.0 - diff;
764
+ }
765
+ if (pos_delta < 0.0)
766
+ {
767
+ pos_delta = 0.0 - pos_delta;
768
+ }
769
+
770
+ //This first part of this condition will catch any NaN or Infinite values
771
+ if ((diff * 0.0 != 0.0) || (pos_delta < diff))
772
+ {
773
+ UnityTestResultsFailBegin(lineNumber);
774
+ #ifdef UNITY_DOUBLE_VERBOSE
775
+ UnityPrint(UnityStrExpected);
776
+ UnityPrintFloat((float)expected);
777
+ UnityPrint(UnityStrWas);
778
+ UnityPrintFloat((float)actual);
779
+ #else
780
+ UnityPrint(UnityStrDelta);
781
+ #endif
782
+ UnityAddMsgIfSpecified(msg);
783
+ UNITY_FAIL_AND_BAIL;
784
+ }
785
+ }
786
+
787
+ //-----------------------------------------------
788
+ void UnityAssertDoubleIsInf(const _UD actual,
789
+ const char* msg,
790
+ const UNITY_LINE_TYPE lineNumber)
791
+ {
792
+ UNITY_SKIP_EXECUTION;
793
+
794
+ // The rationale for not using 1.0/0.0 is given in UnityAssertFloatIsInf's body.
795
+ if ((1.0 / d_zero) != actual)
796
+ {
797
+ UnityTestResultsFailBegin(lineNumber);
798
+ #ifdef UNITY_DOUBLE_VERBOSE
799
+ UnityPrint(UnityStrExpected);
800
+ UnityPrint(UnityStrInf);
801
+ UnityPrint(UnityStrWas);
802
+ UnityPrintFloat((float)actual);
803
+ #else
804
+ UnityPrint(UnityStrDelta);
805
+ #endif
806
+ UnityAddMsgIfSpecified(msg);
807
+ UNITY_FAIL_AND_BAIL;
808
+ }
809
+ }
810
+
811
+ //-----------------------------------------------
812
+ void UnityAssertDoubleIsNegInf(const _UD actual,
813
+ const char* msg,
814
+ const UNITY_LINE_TYPE lineNumber)
815
+ {
816
+ UNITY_SKIP_EXECUTION;
817
+
818
+ // The rationale for not using 1.0/0.0 is given in UnityAssertFloatIsInf's body.
819
+ if ((-1.0 / d_zero) != actual)
820
+ {
821
+ UnityTestResultsFailBegin(lineNumber);
822
+ #ifdef UNITY_DOUBLE_VERBOSE
823
+ UnityPrint(UnityStrExpected);
824
+ UnityPrint(UnityStrNegInf);
825
+ UnityPrint(UnityStrWas);
826
+ UnityPrintFloat((float)actual);
827
+ #else
828
+ UnityPrint(UnityStrDelta);
829
+ #endif
830
+ UnityAddMsgIfSpecified(msg);
831
+ UNITY_FAIL_AND_BAIL;
832
+ }
833
+ }
834
+
835
+ //-----------------------------------------------
836
+ void UnityAssertDoubleIsNaN(const _UD actual,
837
+ const char* msg,
838
+ const UNITY_LINE_TYPE lineNumber)
839
+ {
840
+ UNITY_SKIP_EXECUTION;
841
+
842
+ if (actual == actual)
843
+ {
844
+ UnityTestResultsFailBegin(lineNumber);
845
+ #ifdef UNITY_DOUBLE_VERBOSE
846
+ UnityPrint(UnityStrExpected);
847
+ UnityPrint(UnityStrNaN);
848
+ UnityPrint(UnityStrWas);
849
+ UnityPrintFloat((float)actual);
850
+ #else
851
+ UnityPrint(UnityStrDelta);
852
+ #endif
853
+ UnityAddMsgIfSpecified(msg);
854
+ UNITY_FAIL_AND_BAIL;
855
+ }
856
+ }
857
+
858
+ #endif // not UNITY_EXCLUDE_DOUBLE
859
+
860
+ //-----------------------------------------------
861
+ void UnityAssertNumbersWithin( const _U_SINT delta,
862
+ const _U_SINT expected,
863
+ const _U_SINT actual,
864
+ const char* msg,
865
+ const UNITY_LINE_TYPE lineNumber,
866
+ const UNITY_DISPLAY_STYLE_T style)
867
+ {
868
+ UNITY_SKIP_EXECUTION;
869
+
870
+ if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT)
871
+ {
872
+ if (actual > expected)
873
+ Unity.CurrentTestFailed = ((actual - expected) > delta);
874
+ else
875
+ Unity.CurrentTestFailed = ((expected - actual) > delta);
876
+ }
877
+ else
878
+ {
879
+ if ((_U_UINT)actual > (_U_UINT)expected)
880
+ Unity.CurrentTestFailed = ((_U_UINT)(actual - expected) > (_U_UINT)delta);
881
+ else
882
+ Unity.CurrentTestFailed = ((_U_UINT)(expected - actual) > (_U_UINT)delta);
883
+ }
884
+
885
+ if (Unity.CurrentTestFailed)
886
+ {
887
+ UnityTestResultsFailBegin(lineNumber);
888
+ UnityPrint(UnityStrDelta);
889
+ UnityPrintNumberByStyle(delta, style);
890
+ UnityPrint(UnityStrExpected);
891
+ UnityPrintNumberByStyle(expected, style);
892
+ UnityPrint(UnityStrWas);
893
+ UnityPrintNumberByStyle(actual, style);
894
+ UnityAddMsgIfSpecified(msg);
895
+ UNITY_FAIL_AND_BAIL;
896
+ }
897
+ }
898
+
899
+ //-----------------------------------------------
900
+ void UnityAssertEqualString(const char* expected,
901
+ const char* actual,
902
+ const char* msg,
903
+ const UNITY_LINE_TYPE lineNumber)
904
+ {
905
+ _UU32 i;
906
+
907
+ UNITY_SKIP_EXECUTION;
908
+
909
+ // if both pointers not null compare the strings
910
+ if (expected && actual)
911
+ {
912
+ for (i = 0; expected[i] || actual[i]; i++)
913
+ {
914
+ if (expected[i] != actual[i])
915
+ {
916
+ Unity.CurrentTestFailed = 1;
917
+ break;
918
+ }
919
+ }
920
+ }
921
+ else
922
+ { // handle case of one pointers being null (if both null, test should pass)
923
+ if (expected != actual)
924
+ {
925
+ Unity.CurrentTestFailed = 1;
926
+ }
927
+ }
928
+
929
+ if (Unity.CurrentTestFailed)
930
+ {
931
+ UnityTestResultsFailBegin(lineNumber);
932
+ UnityPrintExpectedAndActualStrings(expected, actual);
933
+ UnityAddMsgIfSpecified(msg);
934
+ UNITY_FAIL_AND_BAIL;
935
+ }
936
+ }
937
+
938
+ //-----------------------------------------------
939
+ void UnityAssertEqualStringArray( const char** expected,
940
+ const char** actual,
941
+ const _UU32 num_elements,
942
+ const char* msg,
943
+ const UNITY_LINE_TYPE lineNumber)
944
+ {
945
+ _UU32 i, j = 0;
946
+
947
+ UNITY_SKIP_EXECUTION;
948
+
949
+ // if no elements, it's an error
950
+ if (num_elements == 0)
951
+ {
952
+ UnityTestResultsFailBegin(lineNumber);
953
+ UnityPrint(UnityStrPointless);
954
+ UnityAddMsgIfSpecified(msg);
955
+ UNITY_FAIL_AND_BAIL;
956
+ }
957
+
958
+ if (UnityCheckArraysForNull((void*)expected, (void*)actual, lineNumber, msg) == 1)
959
+ return;
960
+
961
+ do
962
+ {
963
+ // if both pointers not null compare the strings
964
+ if (expected[j] && actual[j])
965
+ {
966
+ for (i = 0; expected[j][i] || actual[j][i]; i++)
967
+ {
968
+ if (expected[j][i] != actual[j][i])
969
+ {
970
+ Unity.CurrentTestFailed = 1;
971
+ break;
972
+ }
973
+ }
974
+ }
975
+ else
976
+ { // handle case of one pointers being null (if both null, test should pass)
977
+ if (expected[j] != actual[j])
978
+ {
979
+ Unity.CurrentTestFailed = 1;
980
+ }
981
+ }
982
+
983
+ if (Unity.CurrentTestFailed)
984
+ {
985
+ UnityTestResultsFailBegin(lineNumber);
986
+ if (num_elements > 1)
987
+ {
988
+ UnityPrint(UnityStrElement);
989
+ UnityPrintNumberByStyle((j), UNITY_DISPLAY_STYLE_UINT);
990
+ }
991
+ UnityPrintExpectedAndActualStrings((const char*)(expected[j]), (const char*)(actual[j]));
992
+ UnityAddMsgIfSpecified(msg);
993
+ UNITY_FAIL_AND_BAIL;
994
+ }
995
+ } while (++j < num_elements);
996
+ }
997
+
998
+ //-----------------------------------------------
999
+ void UnityAssertEqualMemory( const void* expected,
1000
+ const void* actual,
1001
+ const _UU32 length,
1002
+ const _UU32 num_elements,
1003
+ const char* msg,
1004
+ const UNITY_LINE_TYPE lineNumber)
1005
+ {
1006
+ unsigned char* ptr_exp = (unsigned char*)expected;
1007
+ unsigned char* ptr_act = (unsigned char*)actual;
1008
+ _UU32 elements = num_elements;
1009
+ _UU32 bytes;
1010
+
1011
+ UNITY_SKIP_EXECUTION;
1012
+
1013
+ if ((elements == 0) || (length == 0))
1014
+ {
1015
+ UnityTestResultsFailBegin(lineNumber);
1016
+ UnityPrint(UnityStrPointless);
1017
+ UnityAddMsgIfSpecified(msg);
1018
+ UNITY_FAIL_AND_BAIL;
1019
+ }
1020
+
1021
+ if (UnityCheckArraysForNull((void*)expected, (void*)actual, lineNumber, msg) == 1)
1022
+ return;
1023
+
1024
+ while (elements--)
1025
+ {
1026
+ /////////////////////////////////////
1027
+ bytes = length;
1028
+ while (bytes--)
1029
+ {
1030
+ if (*ptr_exp != *ptr_act)
1031
+ {
1032
+ UnityTestResultsFailBegin(lineNumber);
1033
+ UnityPrint(UnityStrMemory);
1034
+ if (num_elements > 1)
1035
+ {
1036
+ UnityPrint(UnityStrElement);
1037
+ UnityPrintNumberByStyle((num_elements - elements - 1), UNITY_DISPLAY_STYLE_UINT);
1038
+ }
1039
+ UnityPrint(UnityStrByte);
1040
+ UnityPrintNumberByStyle((length - bytes - 1), UNITY_DISPLAY_STYLE_UINT);
1041
+ UnityPrint(UnityStrExpected);
1042
+ UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8);
1043
+ UnityPrint(UnityStrWas);
1044
+ UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8);
1045
+ UnityAddMsgIfSpecified(msg);
1046
+ UNITY_FAIL_AND_BAIL;
1047
+ }
1048
+ ptr_exp += 1;
1049
+ ptr_act += 1;
1050
+ }
1051
+ /////////////////////////////////////
1052
+
1053
+ }
1054
+ }
1055
+
1056
+ //-----------------------------------------------
1057
+ // Control Functions
1058
+ //-----------------------------------------------
1059
+
1060
+ void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
1061
+ {
1062
+ UNITY_SKIP_EXECUTION;
1063
+
1064
+ UnityTestResultsBegin(Unity.TestFile, line);
1065
+ UnityPrintFail();
1066
+ if (msg != NULL)
1067
+ {
1068
+ UNITY_OUTPUT_CHAR(':');
1069
+ if (msg[0] != ' ')
1070
+ {
1071
+ UNITY_OUTPUT_CHAR(' ');
1072
+ }
1073
+ UnityPrint(msg);
1074
+ }
1075
+ UNITY_FAIL_AND_BAIL;
1076
+ }
1077
+
1078
+ //-----------------------------------------------
1079
+ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
1080
+ {
1081
+ UNITY_SKIP_EXECUTION;
1082
+
1083
+ UnityTestResultsBegin(Unity.TestFile, line);
1084
+ UnityPrint("IGNORE");
1085
+ if (msg != NULL)
1086
+ {
1087
+ UNITY_OUTPUT_CHAR(':');
1088
+ UNITY_OUTPUT_CHAR(' ');
1089
+ UnityPrint(msg);
1090
+ }
1091
+ UNITY_IGNORE_AND_BAIL;
1092
+ }
1093
+
1094
+ //-----------------------------------------------
1095
+ void setUp(void);
1096
+ void tearDown(void);
1097
+ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
1098
+ {
1099
+ Unity.CurrentTestName = FuncName;
1100
+ Unity.CurrentTestLineNumber = FuncLineNum;
1101
+ Unity.NumberOfTests++;
1102
+ if (TEST_PROTECT())
1103
+ {
1104
+ setUp();
1105
+ Func();
1106
+ }
1107
+ if (TEST_PROTECT() && !(Unity.CurrentTestIgnored))
1108
+ {
1109
+ tearDown();
1110
+ }
1111
+ UnityConcludeTest();
1112
+ }
1113
+
1114
+ //-----------------------------------------------
1115
+ void UnityBegin(void)
1116
+ {
1117
+ Unity.NumberOfTests = 0;
1118
+ Unity.TestFailures = 0;
1119
+ Unity.TestIgnores = 0;
1120
+ Unity.CurrentTestFailed = 0;
1121
+ Unity.CurrentTestIgnored = 0;
1122
+ }
1123
+
1124
+ //-----------------------------------------------
1125
+ int UnityEnd(void)
1126
+ {
1127
+ UnityPrint("-----------------------");
1128
+ UNITY_PRINT_EOL;
1129
+ UnityPrintNumber(Unity.NumberOfTests);
1130
+ UnityPrint(" Tests ");
1131
+ UnityPrintNumber(Unity.TestFailures);
1132
+ UnityPrint(" Failures ");
1133
+ UnityPrintNumber(Unity.TestIgnores);
1134
+ UnityPrint(" Ignored");
1135
+ UNITY_PRINT_EOL;
1136
+ if (Unity.TestFailures == 0U)
1137
+ {
1138
+ UnityPrintOk();
1139
+ }
1140
+ else
1141
+ {
1142
+ UnityPrintFail();
1143
+ }
1144
+ UNITY_PRINT_EOL;
1145
+ return Unity.TestFailures;
1146
+ }