From 25fe7f3b23cae4489e162c5c0789565860a03c24 Mon Sep 17 00:00:00 2001 From: FeignClaims Date: Wed, 14 Feb 2024 14:49:46 +0800 Subject: [PATCH] Add an executable test with args in tests --- tests/myproj/CMakeLists.txt | 3 +++ tests/myproj/src/main/main.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/myproj/CMakeLists.txt b/tests/myproj/CMakeLists.txt index 0c9be882..f33676a5 100644 --- a/tests/myproj/CMakeLists.txt +++ b/tests/myproj/CMakeLists.txt @@ -98,6 +98,9 @@ add_subdirectory(libs) ## tests enable_testing() add_executable_test(main no_arg) +add_executable_test(main with_arg + EXECUTE_ARGS hello world +) # Header-only library add_library(lib INTERFACE) diff --git a/tests/myproj/src/main/main.cpp b/tests/myproj/src/main/main.cpp index 65c8ad70..b97e16cb 100644 --- a/tests/myproj/src/main/main.cpp +++ b/tests/myproj/src/main/main.cpp @@ -15,7 +15,11 @@ #include #include -int main() { +int main(int argc, char* argv[]) { + if (argc > 1) { + fmt::print("[{}]", fmt::join(argv + 1, argv + argc, ", ")); + } + fmt::print("Hello from fmt{}", "!"); Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3);