mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
Protect test runner generator against characters in strings that look like comments or functions
This commit is contained in:
@@ -35,6 +35,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
@@ -52,6 +54,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
@@ -48,6 +50,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
@@ -46,6 +48,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#ifndef __B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___H_E_A_D_1__H_
|
||||
#define __B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___H_E_A_D_1__H_
|
||||
#ifndef _TESTSAMPLE_HEAD1_H
|
||||
#define _TESTSAMPLE_HEAD1_H
|
||||
|
||||
#include "unity.h"
|
||||
#include "funky.h"
|
||||
#include "stanky.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
void test_TheFirstThingToTest();
|
||||
void test_TheSecondThingToTest();
|
||||
void test_TheFirstThingToTest(void);
|
||||
void test_TheSecondThingToTest(void);
|
||||
void test_TheThirdThingToTest(void);
|
||||
void test_TheFourthThingToTest(void);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||
#ifndef __B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___M_O_C_K___H_E_A_D_1__H_
|
||||
#define __B_U_I_L_D__T_E_S_T_S_A_M_P_L_E___M_O_C_K___H_E_A_D_1__H_
|
||||
#ifndef _TESTSAMPLE_MOCK_HEAD1_H
|
||||
#define _TESTSAMPLE_MOCK_HEAD1_H
|
||||
|
||||
#include "unity.h"
|
||||
#include "cmock.h"
|
||||
#include "funky.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
void test_TheFirstThingToTest();
|
||||
void test_TheSecondThingToTest();
|
||||
void test_TheFirstThingToTest(void);
|
||||
void test_TheSecondThingToTest(void);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
@@ -58,6 +60,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Suite Setup=====
|
||||
@@ -61,6 +63,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return suite_teardown(UnityEnd());
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
@@ -49,6 +51,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53, RUN_TEST_NO_ARGS);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58, RUN_TEST_NO_ARGS);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Test Reset Option=====
|
||||
@@ -58,6 +60,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Suite Setup=====
|
||||
@@ -61,6 +63,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return suite_teardown(UnityEnd());
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ extern void setUp(void);
|
||||
extern void tearDown(void);
|
||||
extern void test_TheFirstThingToTest(void);
|
||||
extern void test_TheSecondThingToTest(void);
|
||||
extern void test_TheThirdThingToTest(void);
|
||||
extern void test_TheFourthThingToTest(void);
|
||||
|
||||
|
||||
//=======Suite Setup=====
|
||||
@@ -62,6 +64,8 @@ int main(void)
|
||||
UnityBegin("testdata/testsample.c");
|
||||
RUN_TEST(test_TheFirstThingToTest, 21);
|
||||
RUN_TEST(test_TheSecondThingToTest, 43);
|
||||
RUN_TEST(test_TheThirdThingToTest, 53);
|
||||
RUN_TEST(test_TheFourthThingToTest, 58);
|
||||
|
||||
return (UnityEnd());
|
||||
}
|
||||
|
||||
21
test/testdata/testsample.c
vendored
21
test/testdata/testsample.c
vendored
@@ -35,15 +35,32 @@ void test_ShouldBeIgnored(void)
|
||||
//void test_ShouldAlsoNotBeTested(void)
|
||||
//{
|
||||
// Call_An_Expect();
|
||||
//
|
||||
//
|
||||
// CallAFunction();
|
||||
// test_CallAFunctionThatLooksLikeATest();
|
||||
//}
|
||||
|
||||
void test_TheSecondThingToTest(void)
|
||||
{
|
||||
uint8_t* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
|
||||
|
||||
Call_An_Expect();
|
||||
|
||||
|
||||
CallAFunction();
|
||||
test_CallAFunctionThatLooksLikeATest();
|
||||
}
|
||||
|
||||
void test_TheThirdThingToTest(void)
|
||||
{
|
||||
CallAFunction();
|
||||
}
|
||||
|
||||
void test_TheFourthThingToTest(void)
|
||||
{
|
||||
uint8_t* anotherString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
|
||||
|
||||
Call_An_Expect();
|
||||
|
||||
CallAFunction();
|
||||
test_CallAFunctionThatLooksLikeATest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user