mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-26 18:01:35 +01:00
- tweaked parameterized tests to be C99 standards compliant
- fixed a few bugs in fixtures to get it to pass against our standard compilers - added extern of OUTPUT_CHAR method to keep compilers from complaining git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@107 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
@@ -203,6 +203,7 @@ class UnityTestRunnerGenerator
|
||||
va_args1 = @options[:use_param_tests] ? ', ...' : ''
|
||||
va_args2 = @options[:use_param_tests] ? '__VA_ARGS__' : ''
|
||||
output.puts("\n//=======Test Runner Used To Run Each Test Below=====")
|
||||
output.puts("#define RUN_TEST_NO_ARGS") if @options[:use_param_tests]
|
||||
output.puts("#define RUN_TEST(TestFunc, TestLineNum#{va_args1}) \\")
|
||||
output.puts("{ \\")
|
||||
output.puts(" Unity.CurrentTestName = #TestFunc; \\")
|
||||
@@ -246,12 +247,16 @@ class UnityTestRunnerGenerator
|
||||
output.puts(" suite_setup();") unless @options[:suite_setup].nil?
|
||||
output.puts(" Unity.TestFile = \"#{filename}\";")
|
||||
output.puts(" UnityBegin();")
|
||||
tests.each do |test|
|
||||
if ((test[:args].nil?) or (test[:args].empty?))
|
||||
output.puts(" RUN_TEST(#{test[:name]}, #{test[:line_number]});")
|
||||
else
|
||||
test[:args].each {|args| output.puts(" RUN_TEST(#{test[:name]}, #{test[:line_number]}, #{args});")}
|
||||
if (@options[:use_param_tests])
|
||||
tests.each do |test|
|
||||
if ((test[:args].nil?) or (test[:args].empty?))
|
||||
output.puts(" RUN_TEST(#{test[:name]}, #{test[:line_number]}, RUN_TEST_NO_ARGS);")
|
||||
else
|
||||
test[:args].each {|args| output.puts(" RUN_TEST(#{test[:name]}, #{test[:line_number]}, #{args});")}
|
||||
end
|
||||
end
|
||||
else
|
||||
tests.each { |test| output.puts(" RUN_TEST(#{test[:name]}, #{test[:line_number]});") }
|
||||
end
|
||||
output.puts()
|
||||
output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());")
|
||||
|
||||
@@ -8,16 +8,19 @@ require 'yaml'
|
||||
require 'fileutils'
|
||||
require HERE+'../../auto/unity_test_summary'
|
||||
require HERE+'../../auto/generate_test_runner'
|
||||
require HERE+'../../auto/colour_reporter'
|
||||
require HERE+'../../auto/colour_reporter'
|
||||
|
||||
module RakefileHelpers
|
||||
|
||||
C_EXTENSION = '.c'
|
||||
|
||||
def load_configuration(config_file)
|
||||
$cfg_file = HERE+"../../targets/#{config_file}" unless $cfg_file =~ /[\\|\/]/
|
||||
$cfg = YAML.load(File.read($cfg_file))
|
||||
$colour_output = false unless $cfg['colour']
|
||||
unless ($configured)
|
||||
$cfg_file = HERE+"../../targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
|
||||
$cfg = YAML.load(File.read($cfg_file))
|
||||
$colour_output = false unless $cfg['colour']
|
||||
$configured = true if (config_file != DEFAULT_CONFIG_FILE)
|
||||
end
|
||||
end
|
||||
|
||||
def configure_clean
|
||||
@@ -159,7 +162,7 @@ module RakefileHelpers
|
||||
simulator = build_simulator_fields
|
||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||
if simulator.nil?
|
||||
cmd_str = executable + " -v -r 8"
|
||||
cmd_str = executable + " -v -r"
|
||||
else
|
||||
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||
end
|
||||
@@ -171,6 +174,5 @@ module RakefileHelpers
|
||||
test_results += '.testpass'
|
||||
end
|
||||
File.open(test_results, 'w') { |f| f.print output }
|
||||
puts output
|
||||
end
|
||||
end
|
||||
|
||||
@@ -297,7 +297,7 @@ TEST(LeakDetection, BufferOverrunFoundDuringFree)
|
||||
{
|
||||
void* m = malloc(10);
|
||||
char* s = (char*)m;
|
||||
s[10] = -1;
|
||||
s[10] = (char)0xFF;
|
||||
UnityOutputCharSpy_Enable(1);
|
||||
EXPECT_ABORT_BEGIN
|
||||
free(m);
|
||||
@@ -312,7 +312,7 @@ TEST(LeakDetection, BufferOverrunFoundDuringRealloc)
|
||||
{
|
||||
void* m = malloc(10);
|
||||
char* s = (char*)m;
|
||||
s[10] = -1;
|
||||
s[10] = (char)0xFF;
|
||||
UnityOutputCharSpy_Enable(1);
|
||||
EXPECT_ABORT_BEGIN
|
||||
m = realloc(m, 100);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include "unity_output_Spy.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -15,9 +15,12 @@ module RakefileHelpers
|
||||
C_EXTENSION = '.c'
|
||||
|
||||
def load_configuration(config_file)
|
||||
$cfg_file = "targets/#{config_file}" unless $cfg_file =~ /[\\|\/]/
|
||||
$cfg = YAML.load(File.read($cfg_file))
|
||||
$colour_output = false unless $cfg['colour']
|
||||
unless ($configured)
|
||||
$cfg_file = "targets/#{config_file}" unless (config_file =~ /[\\|\/]/)
|
||||
$cfg = YAML.load(File.read($cfg_file))
|
||||
$colour_output = false unless $cfg['colour']
|
||||
$configured = true if (config_file != DEFAULT_CONFIG_FILE)
|
||||
end
|
||||
end
|
||||
|
||||
def configure_clean
|
||||
|
||||
@@ -120,6 +120,8 @@ typedef UNITY_FLOAT_TYPE _UF;
|
||||
#define UNITY_OUTPUT_CHAR(a) putchar(a)
|
||||
#endif
|
||||
|
||||
extern int UNITY_OUTPUT_CHAR(int);
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Footprint
|
||||
//-------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
|
||||
//=======Test Runner Used To Run Each Test Below=====
|
||||
#define RUN_TEST_NO_ARGS
|
||||
#define RUN_TEST(TestFunc, TestLineNum, ...) \
|
||||
{ \
|
||||
Unity.CurrentTestName = #TestFunc; \
|
||||
@@ -65,8 +66,8 @@ int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/mocksample.c";
|
||||
UnityBegin();
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
|
||||
//=======Test Runner Used To Run Each Test Below=====
|
||||
#define RUN_TEST_NO_ARGS
|
||||
#define RUN_TEST(TestFunc, TestLineNum, ...) \
|
||||
{ \
|
||||
Unity.CurrentTestName = #TestFunc; \
|
||||
@@ -43,8 +44,8 @@ int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/testsample.c";
|
||||
UnityBegin();
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user