diff --git a/rakefile.rb b/rakefile.rb index 2c3eebc..01f8336 100644 --- a/rakefile.rb +++ b/rakefile.rb @@ -32,7 +32,7 @@ task :summary do end desc "Build and test Unity" -task :all => [:clean, :unit, :summary] +task :all => [:clean, :scripts, :unit, :summary] task :default => [:clobber, :all] task :ci => [:no_color, :default] task :cruise => [:no_color, :default] diff --git a/test/expectdata/testsample_cmd.c b/test/expectdata/testsample_cmd.c index c8da747..a014d9e 100644 --- a/test/expectdata/testsample_cmd.c +++ b/test/expectdata/testsample_cmd.c @@ -1,32 +1,40 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include #include #include "CException.h" -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CEXCEPTION_T e; - Try { - setUp(); - test(); - } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -34,12 +42,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 de46feb..5c0bd3b 100644 --- a/test/expectdata/testsample_def.c +++ b/test/expectdata/testsample_def.c @@ -1,28 +1,36 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include #include -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - setUp(); - test(); - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -30,12 +38,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 125ccbb..b571d73 100644 --- a/test/expectdata/testsample_mock_cmd.c +++ b/test/expectdata/testsample_mock_cmd.c @@ -1,4 +1,30 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include @@ -6,14 +32,14 @@ #include "CException.h" #include "Mockstanky.h" -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { Mockstanky_Init(); @@ -26,24 +52,8 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CEXCEPTION_T e; - Try { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -54,12 +64,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 9b60a48..54060ce 100644 --- a/test/expectdata/testsample_mock_def.c +++ b/test/expectdata/testsample_mock_def.c @@ -1,18 +1,41 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include #include #include "Mockstanky.h" -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { Mockstanky_Init(); @@ -25,21 +48,8 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -50,12 +60,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 415da59..161e6f7 100644 --- a/test/expectdata/testsample_mock_new1.c +++ b/test/expectdata/testsample_mock_new1.c @@ -1,4 +1,30 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include "one.h" @@ -8,17 +34,18 @@ #include "CException.h" #include "Mockstanky.h" -char MessageBuffer[50]; int GlobalExpectCount; int GlobalVerifyOrder; char* GlobalOrderError; +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { GlobalExpectCount = 0; @@ -34,24 +61,8 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CEXCEPTION_T e; - Try { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -62,12 +73,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 0822ade..dc44775 100644 --- a/test/expectdata/testsample_mock_new2.c +++ b/test/expectdata/testsample_mock_new2.c @@ -1,18 +1,41 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include #include #include "Mockstanky.h" -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { Mockstanky_Init(); @@ -25,29 +48,20 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } + +//=======Suite Setup===== static int suite_setup(void) { a_custom_setup(); } + +//=======Suite Teardown===== static int suite_teardown(int num_failures) { a_custom_teardown(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -58,13 +72,12 @@ void resetTest() } +//=======MAIN===== int main(void) { suite_setup(); Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 new file mode 100644 index 0000000..4ea583e --- /dev/null +++ b/test/expectdata/testsample_mock_param.c @@ -0,0 +1,72 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum, ...) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CMock_Init(); \ + setUp(); \ + TestFunc(__VA_ARGS__); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include "cmock.h" +#include +#include +#include "Mockstanky.h" + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Mock Management===== +static void CMock_Init(void) +{ + Mockstanky_Init(); +} +static void CMock_Verify(void) +{ + Mockstanky_Verify(); +} +static void CMock_Destroy(void) +{ + Mockstanky_Destroy(); +} + +//=======Test Reset Option===== +void resetTest() +{ + CMock_Verify(); + CMock_Destroy(); + tearDown(); + CMock_Init(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + Unity.TestFile = "test/testdata/mocksample.c"; + UnityBegin(); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/test/expectdata/testsample_mock_run1.c b/test/expectdata/testsample_mock_run1.c index 415da59..161e6f7 100644 --- a/test/expectdata/testsample_mock_run1.c +++ b/test/expectdata/testsample_mock_run1.c @@ -1,4 +1,30 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include "one.h" @@ -8,17 +34,18 @@ #include "CException.h" #include "Mockstanky.h" -char MessageBuffer[50]; int GlobalExpectCount; int GlobalVerifyOrder; char* GlobalOrderError; +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { GlobalExpectCount = 0; @@ -34,24 +61,8 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CEXCEPTION_T e; - Try { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -62,12 +73,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 0822ade..dc44775 100644 --- a/test/expectdata/testsample_mock_run2.c +++ b/test/expectdata/testsample_mock_run2.c @@ -1,18 +1,41 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include #include #include "Mockstanky.h" -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { Mockstanky_Init(); @@ -25,29 +48,20 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } + +//=======Suite Setup===== static int suite_setup(void) { a_custom_setup(); } + +//=======Suite Teardown===== static int suite_teardown(int num_failures) { a_custom_teardown(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -58,13 +72,12 @@ void resetTest() } +//=======MAIN===== int main(void) { suite_setup(); Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 30e7744..3bedff4 100644 --- a/test/expectdata/testsample_mock_yaml.c +++ b/test/expectdata/testsample_mock_yaml.c @@ -1,18 +1,41 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CMock_Init(); \ + setUp(); \ + TestFunc(); \ + CMock_Verify(); \ + } \ + CMock_Destroy(); \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "cmock.h" #include #include #include "Mockstanky.h" -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Mock Management===== static void CMock_Init(void) { Mockstanky_Init(); @@ -25,25 +48,14 @@ static void CMock_Destroy(void) { Mockstanky_Destroy(); } + +//=======Suite Setup===== static int suite_setup(void) { a_yaml_setup(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CMock_Init(); - setUp(); - test(); - CMock_Verify(); - } - CMock_Destroy(); - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { CMock_Verify(); @@ -54,13 +66,12 @@ void resetTest() } +//=======MAIN===== int main(void) { suite_setup(); Unity.TestFile = "test/testdata/mocksample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 3aa48c9..ce0922d 100644 --- a/test/expectdata/testsample_new1.c +++ b/test/expectdata/testsample_new1.c @@ -1,4 +1,27 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "one.h" #include "two.h" @@ -6,32 +29,18 @@ #include #include "CException.h" -char MessageBuffer[50]; int GlobalExpectCount; int GlobalVerifyOrder; char* GlobalOrderError; +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CEXCEPTION_T e; - Try { - setUp(); - test(); - } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -39,12 +48,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 295bf88..fdbbef3 100644 --- a/test/expectdata/testsample_new2.c +++ b/test/expectdata/testsample_new2.c @@ -1,36 +1,48 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include #include -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Suite Setup===== static int suite_setup(void) { a_custom_setup(); } + +//=======Suite Teardown===== static int suite_teardown(int num_failures) { a_custom_teardown(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - setUp(); - test(); - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -38,13 +50,12 @@ void resetTest() } +//=======MAIN===== int main(void) { suite_setup(); Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/expectdata/testsample_param.c b/test/expectdata/testsample_param.c new file mode 100644 index 0000000..a367d50 --- /dev/null +++ b/test/expectdata/testsample_param.c @@ -0,0 +1,50 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum, ...) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(__VA_ARGS__); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== +#include "unity.h" +#include +#include + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +extern void test_TheFirstThingToTest(void); +extern void test_TheSecondThingToTest(void); + + +//=======Test Reset Option===== +void resetTest() +{ + tearDown(); + setUp(); +} + + +//=======MAIN===== +int main(void) +{ + Unity.TestFile = "test/testdata/testsample.c"; + UnityBegin(); + RUN_TEST(test_TheFirstThingToTest, 21); + RUN_TEST(test_TheSecondThingToTest, 43); + + return (UnityEnd()); +} diff --git a/test/expectdata/testsample_run1.c b/test/expectdata/testsample_run1.c index 3aa48c9..ce0922d 100644 --- a/test/expectdata/testsample_run1.c +++ b/test/expectdata/testsample_run1.c @@ -1,4 +1,27 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + CEXCEPTION_T e; \ + Try { \ + setUp(); \ + TestFunc(); \ + } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include "one.h" #include "two.h" @@ -6,32 +29,18 @@ #include #include "CException.h" -char MessageBuffer[50]; int GlobalExpectCount; int GlobalVerifyOrder; char* GlobalOrderError; +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - CEXCEPTION_T e; - Try { - setUp(); - test(); - } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -39,12 +48,11 @@ void resetTest() } +//=======MAIN===== int main(void) { Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 295bf88..fdbbef3 100644 --- a/test/expectdata/testsample_run2.c +++ b/test/expectdata/testsample_run2.c @@ -1,36 +1,48 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include #include -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Suite Setup===== static int suite_setup(void) { a_custom_setup(); } + +//=======Suite Teardown===== static int suite_teardown(int num_failures) { a_custom_teardown(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - setUp(); - test(); - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -38,13 +50,12 @@ void resetTest() } +//=======MAIN===== int main(void) { suite_setup(); Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest 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 76d5c94..dbb47f5 100644 --- a/test/expectdata/testsample_yaml.c +++ b/test/expectdata/testsample_yaml.c @@ -1,32 +1,42 @@ /* AUTOGENERATED FILE. DO NOT EDIT. */ + +//=======Test Runner Used To Run Each Test Below===== +#define RUN_TEST(TestFunc, TestLineNum) \ +{ \ + Unity.CurrentTestName = #TestFunc; \ + Unity.CurrentTestLineNumber = TestLineNum; \ + Unity.NumberOfTests++; \ + if (TEST_PROTECT()) \ + { \ + setUp(); \ + TestFunc(); \ + } \ + if (TEST_PROTECT() && !TEST_IS_IGNORED) \ + { \ + tearDown(); \ + } \ + UnityConcludeTest(); \ +} + +//=======Automagically Detected Files To Include===== #include "unity.h" #include #include -char MessageBuffer[50]; - +//=======External Functions This Runner Calls===== extern void setUp(void); extern void tearDown(void); - extern void test_TheFirstThingToTest(void); extern void test_TheSecondThingToTest(void); + +//=======Suite Setup===== static int suite_setup(void) { a_yaml_setup(); } -static void runTest(UnityTestFunction test) -{ - if (TEST_PROTECT()) - { - setUp(); - test(); - } - if (TEST_PROTECT() && !TEST_IS_IGNORED) - { - tearDown(); - } -} + +//=======Test Reset Option===== void resetTest() { tearDown(); @@ -34,13 +44,12 @@ void resetTest() } +//=======MAIN===== int main(void) { suite_setup(); Unity.TestFile = "test/testdata/testsample.c"; UnityBegin(); - - // RUN_TEST calls runTest RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); diff --git a/test/test_generate_test_runner.rb b/test/test_generate_test_runner.rb index 71ac589..953552f 100644 --- a/test/test_generate_test_runner.rb +++ b/test/test_generate_test_runner.rb @@ -6,11 +6,11 @@ ruby_version = RUBY_VERSION.split('.') if (ruby_version[1].to_i == 9) and (ruby_version[2].to_i > 1) - require 'gems' + require 'rubygems' gem 'test-unit' end require 'test/unit' -require 'auto/generate_test_runner.rb' +require './auto/generate_test_runner.rb' TEST_FILE = 'test/testdata/testsample.c' TEST_MOCK = 'test/testdata/mocksample.c' @@ -79,4 +79,16 @@ class TestGenerateTestRunner < Test::Unit::TestCase verify_output_equal('mock_' + subtest) end + def test_ShouldGenerateARunnerThatUsesParameterizedTests + sets = { 'param' => { :plugins => [:ignore], :use_param_tests => true } + } + + sets.each_pair do |subtest, options| + UnityTestRunnerGenerator.new(options).run(TEST_FILE, OUT_FILE + subtest + '.c') + verify_output_equal(subtest) + UnityTestRunnerGenerator.new(options).run(TEST_MOCK, OUT_FILE + 'mock_' + subtest + '.c') + verify_output_equal('mock_' + subtest) + end + end + end