From f1c778e1004b6d96b6a791d4d5679fe75e08f645 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 7 Mar 2014 15:17:25 -0500 Subject: [PATCH] Fixed initialization of data structure by just doing it manually instead of statically (goodbye compiler warnings!) --- auto/generate_test_runner.rb | 2 +- src/unity.c | 5 ++++- test/expectdata/testsample_cmd.c | 2 +- test/expectdata/testsample_def.c | 2 +- test/expectdata/testsample_mock_cmd.c | 2 +- test/expectdata/testsample_mock_def.c | 2 +- test/expectdata/testsample_mock_new1.c | 2 +- test/expectdata/testsample_mock_new2.c | 2 +- test/expectdata/testsample_mock_param.c | 2 +- test/expectdata/testsample_mock_run1.c | 2 +- test/expectdata/testsample_mock_run2.c | 2 +- test/expectdata/testsample_mock_yaml.c | 2 +- test/expectdata/testsample_new1.c | 2 +- test/expectdata/testsample_new2.c | 2 +- test/expectdata/testsample_param.c | 2 +- test/expectdata/testsample_run1.c | 2 +- test/expectdata/testsample_run2.c | 2 +- test/expectdata/testsample_yaml.c | 2 +- 18 files changed, 21 insertions(+), 18 deletions(-) diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index 0eedb7d..b984960 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -266,8 +266,8 @@ class UnityTestRunnerGenerator output.puts("int main(void)") output.puts("{") output.puts(" suite_setup();") unless @options[:suite_setup].nil? - output.puts(" Unity.TestFile = \"#{filename}\";") output.puts(" UnityBegin();") + output.puts(" Unity.TestFile = \"#{filename}\";") if (@options[:use_param_tests]) tests.each do |test| if ((test[:args].nil?) or (test[:args].empty?)) diff --git a/src/unity.c b/src/unity.c index 392625e..3a6e290 100644 --- a/src/unity.c +++ b/src/unity.c @@ -14,7 +14,7 @@ #define UNITY_SKIP_EXECUTION { if ((Unity.CurrentTestFailed != 0) || (Unity.CurrentTestIgnored != 0)) {return;} } #define UNITY_PRINT_EOL { UNITY_OUTPUT_CHAR('\n'); } -struct _Unity Unity = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , {{{ 0 }}} }; +struct _Unity Unity; const char* UnityStrNull = "NULL"; const char* UnityStrSpacer = ". "; @@ -1115,6 +1115,9 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int //----------------------------------------------- void UnityBegin(void) { + Unity.TestFile = NULL; + Unity.CurrentTestName = NULL; + Unity.CurrentTestLineNumber = 0; Unity.NumberOfTests = 0; Unity.TestFailures = 0; Unity.TestIgnores = 0; diff --git a/test/expectdata/testsample_cmd.c b/test/expectdata/testsample_cmd.c index d426dde..ffcd895 100644 --- a/test/expectdata/testsample_cmd.c +++ b/test/expectdata/testsample_cmd.c @@ -48,8 +48,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_def.c b/test/expectdata/testsample_def.c index 8cdedde..e2c9c68 100644 --- a/test/expectdata/testsample_def.c +++ b/test/expectdata/testsample_def.c @@ -44,8 +44,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_cmd.c b/test/expectdata/testsample_mock_cmd.c index c62c3b5..6acb532 100644 --- a/test/expectdata/testsample_mock_cmd.c +++ b/test/expectdata/testsample_mock_cmd.c @@ -69,8 +69,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_def.c b/test/expectdata/testsample_mock_def.c index e971179..965f26f 100644 --- a/test/expectdata/testsample_mock_def.c +++ b/test/expectdata/testsample_mock_def.c @@ -65,8 +65,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_new1.c b/test/expectdata/testsample_mock_new1.c index 070927a..041499e 100644 --- a/test/expectdata/testsample_mock_new1.c +++ b/test/expectdata/testsample_mock_new1.c @@ -78,8 +78,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_new2.c b/test/expectdata/testsample_mock_new2.c index 6d786ba..56155c0 100644 --- a/test/expectdata/testsample_mock_new2.c +++ b/test/expectdata/testsample_mock_new2.c @@ -78,8 +78,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_param.c b/test/expectdata/testsample_mock_param.c index 39f6c91..bb445ac 100644 --- a/test/expectdata/testsample_mock_param.c +++ b/test/expectdata/testsample_mock_param.c @@ -66,8 +66,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); diff --git a/test/expectdata/testsample_mock_run1.c b/test/expectdata/testsample_mock_run1.c index 070927a..041499e 100644 --- a/test/expectdata/testsample_mock_run1.c +++ b/test/expectdata/testsample_mock_run1.c @@ -78,8 +78,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_run2.c b/test/expectdata/testsample_mock_run2.c index 6d786ba..56155c0 100644 --- a/test/expectdata/testsample_mock_run2.c +++ b/test/expectdata/testsample_mock_run2.c @@ -78,8 +78,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_mock_yaml.c b/test/expectdata/testsample_mock_yaml.c index cf680fd..32262f7 100644 --- a/test/expectdata/testsample_mock_yaml.c +++ b/test/expectdata/testsample_mock_yaml.c @@ -79,8 +79,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/mocksample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_new1.c b/test/expectdata/testsample_new1.c index 56b148b..bc726e5 100644 --- a/test/expectdata/testsample_new1.c +++ b/test/expectdata/testsample_new1.c @@ -54,8 +54,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_new2.c b/test/expectdata/testsample_new2.c index be591b3..884af51 100644 --- a/test/expectdata/testsample_new2.c +++ b/test/expectdata/testsample_new2.c @@ -57,8 +57,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_param.c b/test/expectdata/testsample_param.c index df4a693..b287401 100644 --- a/test/expectdata/testsample_param.c +++ b/test/expectdata/testsample_param.c @@ -45,8 +45,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); diff --git a/test/expectdata/testsample_run1.c b/test/expectdata/testsample_run1.c index 56b148b..bc726e5 100644 --- a/test/expectdata/testsample_run1.c +++ b/test/expectdata/testsample_run1.c @@ -54,8 +54,8 @@ void resetTest() //=======MAIN===== int main(void) { - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_run2.c b/test/expectdata/testsample_run2.c index be591b3..884af51 100644 --- a/test/expectdata/testsample_run2.c +++ b/test/expectdata/testsample_run2.c @@ -57,8 +57,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_yaml.c b/test/expectdata/testsample_yaml.c index 9198105..75882a6 100644 --- a/test/expectdata/testsample_yaml.c +++ b/test/expectdata/testsample_yaml.c @@ -58,8 +58,8 @@ void resetTest() int main(void) { suite_setup(); - Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); + Unity.TestFile = "test/testdata/testsample.c"; RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); -- GitLab