diff --git a/CHN-18-测试框架.md b/CHN-18-测试框架.md index 491c087..08cdeb5 100644 --- a/CHN-18-测试框架.md +++ b/CHN-18-测试框架.md @@ -148,7 +148,7 @@ int main() // Start the main loop on another thread std::thread thr([&]() { // Queues the promis to be fulfilled after starting the loop - app().getLoop()->queueInLoop([]() { p1.set_value(); }); + app().getLoop()->queueInLoop([&p1]() { p1.set_value(); }); app().run(); }); @@ -165,13 +165,13 @@ int main() ### CMake 集成 -与大多数测试框架一样,DrgonTest 可以将自身集成到 CMake 中。 `ParseAndAddDrogonTest` 函数将它在源文件中看到的测试添加到 CMake 的 CTest 框架中。 +与大多数测试框架一样,DrgonTest 可以将自身集成到 CMake 中。 `ParseAndAddDrogonTests` 函数将它在源文件中看到的测试添加到 CMake 的 CTest 框架中。 ```cmake -include(ParseAndAddDrogonTest) +include(ParseAndAddDrogonTest) # Also loads ParseAndAddDrogonTests add_executable(mytest main.cpp) -target_link_libraries(mytest PRIVATE drogon) -ParseAndAddDrogonTest(mytest) +target_link_libraries(mytest PRIVATE Drogon::Drogon) +ParseAndAddDrogonTests(mytest) ``` 现在可以通过构建系统(在本例中为 Makefile)运行测试。 @@ -182,4 +182,4 @@ Running tests... Test project path/to/your/test/build/ Start 1: Sum 1/1 Test #1: Sum .................................... Passed 0.00 sec -``` \ No newline at end of file +``` diff --git a/ENG-18-Testing-Framework.md b/ENG-18-Testing-Framework.md index c4938ab..b9e6568 100644 --- a/ENG-18-Testing-Framework.md +++ b/ENG-18-Testing-Framework.md @@ -148,7 +148,7 @@ int main() // Start the main loop on another thread std::thread thr([&]() { // Queues the promis to be fulfilled after starting the loop - app().getLoop()->queueInLoop([]() { p1.set_value(); }); + app().getLoop()->queueInLoop([&p1]() { p1.set_value(); }); app().run(); }); @@ -165,13 +165,13 @@ int main() ### CMake integration -Like most testing frmaeworks, DrogonTest can integrate itself into CMake. The `ParseAndAddDrogonTest` function adds tests it sees in the source file to CMake's CTest framework. +Like most testing frmaeworks, DrogonTest can integrate itself into CMake. The `ParseAndAddDrogonTests` function adds tests it sees in the source file to CMake's CTest framework. ```cmake -include(ParseAndAddDrogonTest) +find_package(Drogon REQUIRED) # also loads ParseAndAddDrogonTests add_executable(mytest main.cpp) -target_link_libraries(mytest PRIVATE drogon) -ParseAndAddDrogonTest(mytest) +target_link_libraries(mytest PRIVATE Drogon::Drogon) +ParseAndAddDrogonTests(mytest) ``` Now the test could be ran through build system (Makefile in this case). @@ -182,4 +182,4 @@ Running tests... Test project path/to/your/test/build/ Start 1: Sum 1/1 Test #1: Sum .................................... Passed 0.00 sec -``` \ No newline at end of file +```