mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-10-17 20:34:05 +08:00
- added tests for generate_test_runner. other script tests to come
git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@97 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
47
test/expectdata/testsample_cmd.c
Normal file
47
test/expectdata/testsample_cmd.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "CException.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/testsample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
43
test/expectdata/testsample_def.c
Normal file
43
test/expectdata/testsample_def.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/testsample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
67
test/expectdata/testsample_mock_cmd.c
Normal file
67
test/expectdata/testsample_mock_cmd.c
Normal file
@ -0,0 +1,67 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "CException.h"
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/mocksample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
63
test/expectdata/testsample_mock_def.c
Normal file
63
test/expectdata/testsample_mock_def.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/mocksample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
75
test/expectdata/testsample_mock_new1.c
Normal file
75
test/expectdata/testsample_mock_new1.c
Normal file
@ -0,0 +1,75 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include "one.h"
|
||||
#include "two.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "CException.h"
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
int GlobalExpectCount;
|
||||
int GlobalVerifyOrder;
|
||||
char* GlobalOrderError;
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
GlobalExpectCount = 0;
|
||||
GlobalVerifyOrder = 0;
|
||||
GlobalOrderError = NULL;
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/mocksample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
72
test/expectdata/testsample_mock_new2.c
Normal file
72
test/expectdata/testsample_mock_new2.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
static void CMock_Destroy(void)
|
||||
{
|
||||
Mockstanky_Destroy();
|
||||
}
|
||||
static int suite_setup(void)
|
||||
{
|
||||
a_custom_setup();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return suite_teardown(UnityEnd());
|
||||
}
|
75
test/expectdata/testsample_mock_run1.c
Normal file
75
test/expectdata/testsample_mock_run1.c
Normal file
@ -0,0 +1,75 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include "one.h"
|
||||
#include "two.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "CException.h"
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
int GlobalExpectCount;
|
||||
int GlobalVerifyOrder;
|
||||
char* GlobalOrderError;
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
GlobalExpectCount = 0;
|
||||
GlobalVerifyOrder = 0;
|
||||
GlobalOrderError = NULL;
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/mocksample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
72
test/expectdata/testsample_mock_run2.c
Normal file
72
test/expectdata/testsample_mock_run2.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
static void CMock_Destroy(void)
|
||||
{
|
||||
Mockstanky_Destroy();
|
||||
}
|
||||
static int suite_setup(void)
|
||||
{
|
||||
a_custom_setup();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return suite_teardown(UnityEnd());
|
||||
}
|
68
test/expectdata/testsample_mock_yaml.c
Normal file
68
test/expectdata/testsample_mock_yaml.c
Normal file
@ -0,0 +1,68 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "Mockstanky.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static void CMock_Init(void)
|
||||
{
|
||||
Mockstanky_Init();
|
||||
}
|
||||
static void CMock_Verify(void)
|
||||
{
|
||||
Mockstanky_Verify();
|
||||
}
|
||||
static void CMock_Destroy(void)
|
||||
{
|
||||
Mockstanky_Destroy();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
CMock_Verify();
|
||||
CMock_Destroy();
|
||||
tearDown();
|
||||
CMock_Init();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
52
test/expectdata/testsample_new1.c
Normal file
52
test/expectdata/testsample_new1.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "one.h"
|
||||
#include "two.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "CException.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
int GlobalExpectCount;
|
||||
int GlobalVerifyOrder;
|
||||
char* GlobalOrderError;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/testsample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
52
test/expectdata/testsample_new2.c
Normal file
52
test/expectdata/testsample_new2.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static int suite_setup(void)
|
||||
{
|
||||
a_custom_setup();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return suite_teardown(UnityEnd());
|
||||
}
|
52
test/expectdata/testsample_run1.c
Normal file
52
test/expectdata/testsample_run1.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include "one.h"
|
||||
#include "two.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include "CException.h"
|
||||
|
||||
char MessageBuffer[50];
|
||||
int GlobalExpectCount;
|
||||
int GlobalVerifyOrder;
|
||||
char* GlobalOrderError;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Unity.TestFile = "test/testdata/testsample.c";
|
||||
UnityBegin();
|
||||
|
||||
// RUN_TEST calls runTest
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
52
test/expectdata/testsample_run2.c
Normal file
52
test/expectdata/testsample_run2.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
static int suite_setup(void)
|
||||
{
|
||||
a_custom_setup();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return suite_teardown(UnityEnd());
|
||||
}
|
48
test/expectdata/testsample_yaml.c
Normal file
48
test/expectdata/testsample_yaml.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#include "unity.h"
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char MessageBuffer[50];
|
||||
|
||||
extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
void resetTest()
|
||||
{
|
||||
tearDown();
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
82
test/test_generate_test_runner.rb
Normal file
82
test/test_generate_test_runner.rb
Normal file
@ -0,0 +1,82 @@
|
||||
# ==========================================
|
||||
# CMock Project - Automatic Mock Generation for C
|
||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
|
||||
ruby_version = RUBY_VERSION.split('.')
|
||||
if (ruby_version[1].to_i == 9) and (ruby_version[2].to_i > 1)
|
||||
require 'gems'
|
||||
gem 'test-unit'
|
||||
end
|
||||
require 'test/unit'
|
||||
require 'auto/generate_test_runner.rb'
|
||||
|
||||
TEST_FILE = 'test/testdata/testsample.c'
|
||||
TEST_MOCK = 'test/testdata/mocksample.c'
|
||||
OUT_FILE = 'build/testsample_'
|
||||
EXP_FILE = 'test/expectdata/testsample_'
|
||||
|
||||
class TestGenerateTestRunner < Test::Unit::TestCase
|
||||
def setup
|
||||
end
|
||||
|
||||
def teardown
|
||||
end
|
||||
|
||||
def verify_output_equal(subtest)
|
||||
expected = File.read(EXP_FILE + subtest + '.c').gsub(/\r\n/,"\n")
|
||||
actual = File.read(OUT_FILE + subtest + '.c').gsub(/\r\n/,"\n")
|
||||
assert_equal(expected, actual, "Generated File Sub-Test '#{subtest}' Failed")
|
||||
end
|
||||
|
||||
def test_ShouldGenerateARunnerByCreatingRunnerWithOptions
|
||||
sets = { 'def' => nil,
|
||||
'new1' => { :plugins => [:cexception], :includes => ['one.h', 'two.h'], :enforce_strict_ordering => true },
|
||||
'new2' => { :plugins => [:ignore], :suite_setup => "a_custom_setup();", :suite_teardown => "a_custom_teardown();" }
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
def test_ShouldGenerateARunnerByRunningRunnerWithOptions
|
||||
sets = { 'run1' => { :plugins => [:cexception], :includes => ['one.h', 'two.h'], :enforce_strict_ordering => true },
|
||||
'run2' => { :plugins => [:ignore], :suite_setup => "a_custom_setup();", :suite_teardown => "a_custom_teardown();" }
|
||||
}
|
||||
|
||||
sets.each_pair do |subtest, options|
|
||||
UnityTestRunnerGenerator.new.run(TEST_FILE, OUT_FILE + subtest + '.c', options)
|
||||
verify_output_equal(subtest)
|
||||
UnityTestRunnerGenerator.new.run(TEST_MOCK, OUT_FILE + 'mock_' + subtest + '.c', options)
|
||||
verify_output_equal('mock_' + subtest)
|
||||
end
|
||||
end
|
||||
|
||||
def test_ShouldGenerateARunnerByPullingYamlOptions
|
||||
subtest = 'yaml'
|
||||
cmdstr = "ruby auto/generate_test_runner.rb test/testdata/sample.yml \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
|
||||
`#{cmdstr}`
|
||||
verify_output_equal(subtest)
|
||||
|
||||
cmdstr = "ruby auto/generate_test_runner.rb test/testdata/sample.yml \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
|
||||
`#{cmdstr}`
|
||||
verify_output_equal('mock_' + subtest)
|
||||
end
|
||||
|
||||
def test_ShouldGenerateARunnerByPullingCommandlineOptions
|
||||
subtest = 'cmd'
|
||||
cmdstr = "ruby auto/generate_test_runner.rb -cexception \"#{TEST_FILE}\" \"#{OUT_FILE + subtest + '.c'}\""
|
||||
`#{cmdstr}`
|
||||
verify_output_equal(subtest)
|
||||
|
||||
cmdstr = "ruby auto/generate_test_runner.rb -cexception \"#{TEST_MOCK}\" \"#{OUT_FILE + 'mock_' + subtest + '.c'}\""
|
||||
`#{cmdstr}`
|
||||
verify_output_equal('mock_' + subtest)
|
||||
end
|
||||
|
||||
end
|
51
test/testdata/mocksample.c
vendored
Normal file
51
test/testdata/mocksample.c
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// This is just a sample test file to be used to test the generator script
|
||||
#ifndef TEST_SAMPLE_H
|
||||
#define TEST_SAMPLE_H
|
||||
|
||||
#include <setjmp.h>
|
||||
#include "unity.h"
|
||||
#include "funky.h"
|
||||
#include "Mockstanky.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
CustomSetupStuff();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
CustomTeardownStuff
|
||||
}
|
||||
|
||||
//Yup, nice comment
|
||||
void test_TheFirstThingToTest(void)
|
||||
{
|
||||
TEST_ASSERT(1);
|
||||
|
||||
TEST_ASSERT_TRUE(1);
|
||||
}
|
||||
|
||||
/*
|
||||
void test_ShouldBeIgnored(void)
|
||||
{
|
||||
DoesStuff();
|
||||
}
|
||||
*/
|
||||
|
||||
//void test_ShouldAlsoNotBeTested(void)
|
||||
//{
|
||||
// Call_An_Expect();
|
||||
//
|
||||
// CallAFunction();
|
||||
// test_CallAFunctionThatLooksLikeATest();
|
||||
//}
|
||||
|
||||
void test_TheSecondThingToTest(void)
|
||||
{
|
||||
Call_An_Expect();
|
||||
|
||||
CallAFunction();
|
||||
test_CallAFunctionThatLooksLikeATest();
|
||||
}
|
||||
|
||||
#endif //TEST_SAMPLE_H
|
8
test/testdata/sample.yml
vendored
Normal file
8
test/testdata/sample.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
:unity:
|
||||
:includes
|
||||
- two.h
|
||||
- three.h
|
||||
:plugins:
|
||||
- :cexception
|
||||
:suite_setup: |
|
||||
a_yaml_setup();
|
51
test/testdata/testsample.c
vendored
Normal file
51
test/testdata/testsample.c
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// This is just a sample test file to be used to test the generator script
|
||||
#ifndef TEST_SAMPLE_H
|
||||
#define TEST_SAMPLE_H
|
||||
|
||||
#include <setjmp.h>
|
||||
#include "unity.h"
|
||||
#include "funky.h"
|
||||
#include "stanky.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
CustomSetupStuff();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
CustomTeardownStuff
|
||||
}
|
||||
|
||||
//Yup, nice comment
|
||||
void test_TheFirstThingToTest(void)
|
||||
{
|
||||
TEST_ASSERT(1);
|
||||
|
||||
TEST_ASSERT_TRUE(1);
|
||||
}
|
||||
|
||||
/*
|
||||
void test_ShouldBeIgnored(void)
|
||||
{
|
||||
DoesStuff();
|
||||
}
|
||||
*/
|
||||
|
||||
//void test_ShouldAlsoNotBeTested(void)
|
||||
//{
|
||||
// Call_An_Expect();
|
||||
//
|
||||
// CallAFunction();
|
||||
// test_CallAFunctionThatLooksLikeATest();
|
||||
//}
|
||||
|
||||
void test_TheSecondThingToTest(void)
|
||||
{
|
||||
Call_An_Expect();
|
||||
|
||||
CallAFunction();
|
||||
test_CallAFunctionThatLooksLikeATest();
|
||||
}
|
||||
|
||||
#endif //TEST_SAMPLE_H
|
Reference in New Issue
Block a user