mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-07-06 00:46:52 +08:00
Compare commits
No commits in common. "f87dc997ebc2ab891ba43a72e4d583b086d18520" and "383f9ffe4ba4dbb58534a59aa5a8573ce2f27e20" have entirely different histories.
f87dc997eb
...
383f9ffe4b
16
3rdparty/unicstl-unity/README.md
vendored
16
3rdparty/unicstl-unity/README.md
vendored
@ -1,16 +0,0 @@
|
||||
|
||||
# 问题和解决方案
|
||||
|
||||
## 1. 多文件打印测试文件路径不合理的问题
|
||||
新增宏定义,可放于unity_config.h中,用来让测试文件路径显示为当前测试文件,而不是主test.c文件。
|
||||
方便针对多文件测试,快速定位错误。
|
||||
```c
|
||||
#define RUN_TEST_WITH_CURRENT_FILE 1
|
||||
```
|
||||
|
||||
另外,修改了两个函数,新增文件路径参数。
|
||||
```c
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum, const char* FileName);
|
||||
|
||||
void UnityConcludeTest(const char *FileName);
|
||||
```
|
48
3rdparty/unicstl-unity/src/unity.c
vendored
48
3rdparty/unicstl-unity/src/unity.c
vendored
@ -543,7 +543,6 @@ static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
|
||||
}
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
#ifndef RUN_TEST_WITH_CURRENT_FILE
|
||||
void UnityConcludeTest(void)
|
||||
{
|
||||
if (Unity.CurrentTestIgnored)
|
||||
@ -566,31 +565,6 @@ void UnityConcludeTest(void)
|
||||
UNITY_PRINT_EOL();
|
||||
UNITY_FLUSH_CALL();
|
||||
}
|
||||
#else
|
||||
void UnityConcludeTest(const char *FileName)
|
||||
{
|
||||
if (Unity.CurrentTestIgnored)
|
||||
{
|
||||
Unity.TestIgnores++;
|
||||
}
|
||||
else if (!Unity.CurrentTestFailed)
|
||||
{
|
||||
UnityTestResultsBegin(FileName, Unity.CurrentTestLineNumber);
|
||||
UnityPrint(UnityStrPass);
|
||||
}
|
||||
else
|
||||
{
|
||||
Unity.TestFailures++;
|
||||
}
|
||||
|
||||
Unity.CurrentTestFailed = 0;
|
||||
Unity.CurrentTestIgnored = 0;
|
||||
UNITY_PRINT_EXEC_TIME();
|
||||
UNITY_PRINT_EOL();
|
||||
UNITY_FLUSH_CALL();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
static void UnityAddMsgIfSpecified(const char* msg)
|
||||
@ -2216,7 +2190,6 @@ void UnityMessage(const char* msg, const UNITY_LINE_TYPE line)
|
||||
/*-----------------------------------------------*/
|
||||
/* If we have not defined our own test runner, then include our default test runner to make life easier */
|
||||
#ifndef UNITY_SKIP_DEFAULT_RUNNER
|
||||
#ifndef RUN_TEST_WITH_CURRENT_FILE
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
|
||||
{
|
||||
Unity.CurrentTestName = FuncName;
|
||||
@ -2236,27 +2209,6 @@ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int
|
||||
UNITY_EXEC_TIME_STOP();
|
||||
UnityConcludeTest();
|
||||
}
|
||||
#else
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum, const char* FileName)
|
||||
{
|
||||
Unity.CurrentTestName = FuncName;
|
||||
Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
|
||||
Unity.NumberOfTests++;
|
||||
UNITY_CLR_DETAILS();
|
||||
UNITY_EXEC_TIME_START();
|
||||
if (TEST_PROTECT())
|
||||
{
|
||||
setUp();
|
||||
Func();
|
||||
}
|
||||
if (TEST_PROTECT())
|
||||
{
|
||||
tearDown();
|
||||
}
|
||||
UNITY_EXEC_TIME_STOP();
|
||||
UnityConcludeTest(FileName);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------*/
|
||||
|
2
3rdparty/unicstl-unity/src/unity_config.h
vendored
2
3rdparty/unicstl-unity/src/unity_config.h
vendored
@ -5,6 +5,4 @@
|
||||
#define UNITY_OUTPUT_COLOR 1
|
||||
#define UNITY_USE_FLUSH_STDOUT 1
|
||||
|
||||
#define RUN_TEST_WITH_CURRENT_FILE 1
|
||||
|
||||
#endif
|
||||
|
16
3rdparty/unicstl-unity/src/unity_internals.h
vendored
16
3rdparty/unicstl-unity/src/unity_internals.h
vendored
@ -546,19 +546,11 @@ extern struct UNITY_STORAGE_T Unity;
|
||||
void UnityBegin(const char* filename);
|
||||
int UnityEnd(void);
|
||||
void UnitySetTestFile(const char* filename);
|
||||
#ifndef RUN_TEST_WITH_CURRENT_FILE
|
||||
void UnityConcludeTest(void);
|
||||
#else
|
||||
void UnityConcludeTest(const char *FileName);
|
||||
#endif
|
||||
|
||||
#ifndef RUN_TEST
|
||||
#ifndef RUN_TEST_WITH_CURRENT_FILE
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
||||
#else
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum, const char* FileName);
|
||||
#endif
|
||||
#else
|
||||
#define UNITY_SKIP_DEFAULT_RUNNER
|
||||
#endif
|
||||
|
||||
@ -825,13 +817,9 @@ extern const char UnityStrErrShorthand[];
|
||||
#ifndef RUN_TEST
|
||||
#ifdef UNITY_SUPPORT_VARIADIC_MACROS
|
||||
#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway)
|
||||
#ifndef RUN_TEST_WITH_CURRENT_FILE
|
||||
#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line)
|
||||
#else
|
||||
#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line, __FILE__)
|
||||
#endif // RUN_TEST_WITH_CURRENT_FILE
|
||||
#endif // UNITY_SUPPORT_VARIADIC_MACROS
|
||||
#endif // RUN_TEST
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Enable default macros for masking param tests test cases */
|
||||
#ifdef UNITY_SUPPORT_TEST_CASES
|
||||
|
@ -70,7 +70,7 @@ void tearDown(void)
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
printf("----- Unicstl Unit Test -----\n");
|
||||
printf("----- 데禱꿎桿 -----\n");
|
||||
UNITY_BEGIN();
|
||||
|
||||
test_stack();
|
||||
|
@ -48,5 +48,9 @@ static void test_stack_num(void)
|
||||
|
||||
void test_stack(void)
|
||||
{
|
||||
// UNITY_BEGIN();
|
||||
|
||||
RUN_TEST(test_stack_num);
|
||||
|
||||
// UNITY_END();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user