File tree Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -90,8 +90,8 @@ static void testEntry(void)
9090int main(void)
9191{
9292 const emdevif_test_Callbacks callback = {.printfCallback = myPrintf,
93- .testEntryCallback = testEntry,
94- .testFinishCallback = testFinishHandler};
93+ .testEntryCallback = testEntry,
94+ .testFinishCallback = testFinishHandler};
9595
9696 emdevif_test_framework_main("\n", &callback, NULL);
9797
@@ -128,3 +128,28 @@ static void testEntry(void)
128128```
129129
130130* 支持测试夹具。使用方式参考[集成测试](./test/integration_test/classic_test/external_test.c)中的 FixtureTest。
131+
132+ ## 自定义配置
133+
134+ ### 预定义宏
135+
136+ 您可以通过预定义宏以配置 emdevif 的一些属性。
137+
138+ | 预定义宏 | 预定义宏的值的类型 | 预定义宏的含义 |
139+ |---------------------------------|-----------|-----------------------------------------------------|
140+ | EMDEVIF_TEST_VALUE_BUFFER_SIZE | size_t | 存储 ASSERT 与 EXPECT 宏的数值的字符串长度,默认为 64。 |
141+ | EMDEVIF_TEST_FLOAT_EQUAL_ERROR | double | 浮点数等于判定的误差值,即两个浮点类型数据之差的绝对值小于这个值即认为它们相等,默认为 0.0001。 |
142+
143+ 使用 CMake 预定义宏的示例:
144+ ```CMake
145+ add_subdirectory(
146+ # path to emdevif_test_framework
147+ )
148+ target_compile_definitions(emdevif_test_framework INTERFACE EMDEVIF_TEST_VALUE_BUFFER_SIZE=128) # example about how to set macro EMDEVIF_TEST_VALUE_BUFFER_SIZE to 128
149+
150+ target_link_libraries(
151+ # your project name
152+ # PUBLIC / PRIVATE / INTERFACE
153+ emdevif_test_framework
154+ )
155+ ```
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ static int test_suit_success_count = 0; ///< 成功计数
2727static int test_suit_fail_count = 0 ; ///< 失败计数
2828
2929#ifndef EMDEVIF_TEST_VALUE_BUFFER_SIZE
30- #define EMDEVIF_TEST_VALUE_BUFFER_SIZE 128
30+ #define EMDEVIF_TEST_VALUE_BUFFER_SIZE 64
3131#endif
3232
3333static char lhs_buffer [EMDEVIF_TEST_VALUE_BUFFER_SIZE ], rhs_buffer [EMDEVIF_TEST_VALUE_BUFFER_SIZE ];
@@ -144,10 +144,8 @@ const emdevif_test_CompareMsg* emdevif_test_strEqual(emdevif_test_CompareMsg* co
144144 const char * const lhs ,
145145 const char * const rhs )
146146{
147- sprintf (lhs_buffer , "%s" , lhs );
148- sprintf (rhs_buffer , "%s" , rhs );
149- msg -> lhs_value = lhs_buffer ;
150- msg -> rhs_value = rhs_buffer ;
147+ msg -> lhs_value = lhs ;
148+ msg -> rhs_value = rhs ;
151149
152150 setCompareName (msg , EMDEVIF_TEST_COMPARE_EQUAL );
153151
You can’t perform that action at this time.
0 commit comments