1
0

refactor: rename testbench to test.

- rename testbench to test.
- add benchmark for future development.
This commit is contained in:
2025-09-29 13:34:02 +08:00
parent 82c3ed5b32
commit e7a05b3488
44 changed files with 55 additions and 19 deletions

View File

@ -10,7 +10,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Provide options
option(YYCC_BUILD_TESTBENCH "Build testbench of YYCCommonplace." OFF)
option(YYCC_BUILD_TEST "Build test of YYCCommonplace." OFF)
option(YYCC_BUILD_BENCHMARK "Build benchmark of YYCCommonplace." OFF)
option(YYCC_BUILD_DOC "Build document of YYCCommonplace." OFF)
option(YYCC_ENFORCE_ICONV "Enforce iconv support for this library (e.g. in MSYS2 environment)." OFF)
@ -26,21 +27,28 @@ set(YYCC_INSTALL_DOC_PATH ${CMAKE_INSTALL_DOCDIR} CACHE PATH
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
# Include dependency.
# GTest is required if we build testbench
if (YYCC_BUILD_TESTBENCH)
# GTest is required if we build test
if (YYCC_BUILD_TEST)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
find_package(GTest REQUIRED)
endif ()
# Google Benchmark is required if we build benchmark
if (YYCC_BUILD_BENCHMARK)
find_package(benchmark REQUIRED)
endif ()
# Iconv is required if we are not in Windows or user request it
if (YYCC_ENFORCE_ICONV OR (NOT WIN32))
find_package(Iconv REQUIRED)
endif ()
# Import 3 build targets
# Import 4 build targets
add_subdirectory(src)
if (YYCC_BUILD_TESTBENCH)
add_subdirectory(testbench)
if (YYCC_BUILD_TEST)
add_subdirectory(test)
endif ()
if (YYCC_BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif ()
if (YYCC_BUILD_DOC)
add_subdirectory(doc)

View File

@ -11,7 +11,7 @@ It means that it is not stable and work in progress.
* CMake 3.23 at least.
* The common compiler supporting C++ 23 (GCC / Clang / MSVC).
* Iconv (Optional on Windows. Required on other systems).
* [GoogleTest](https://github.com/google/googletest) (Required if you build testbench).
* [GoogleTest](https://github.com/google/googletest) (Required if you build test).
* Doxygen (Required if you build documentation).
* Python and Astral UV (Required if you use "User Build" method)
@ -24,7 +24,7 @@ It means that it is not stable and work in progress.
### GoogleTest
GoogleTest is required if you need to build testbench.
GoogleTest is required if you need to build test.
If you don't need this please skip this chapter.
We use GoogleTest v1.17.0.
@ -89,7 +89,7 @@ TODO...
There is a list listing all variables you may configure during compiling.
* `YYCC_BUILD_TESTBENCH`: Set it to `ON` to build testbench. `OFF` in default.
* `YYCC_BUILD_TEST`: Set it to `ON` to build test. `OFF` in default.
It is useful for the developer of this project.
It also suit for the user who has runtime issues on their platforms to check whether this project works as expected.
* `YYCC_BUILD_DOC`: Set it to `ON` to build documentation. `OFF` in default.

24
benchmark/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
# Create executable benchmark
add_executable(YYCCBenchmark "")
# Setup test sources
target_sources(YYCCBenchmark
PRIVATE
main.cpp
)
# target_sources(YYCCBenchmark
# PRIVATE
# FILE_SET HEADERS
# FILES
# shared/literals.hpp
# )
# Setup headers
target_include_directories(YYCCBenchmark
PUBLIC
"${CMAKE_CURRENT_LIST_DIR}"
)
# Setup libraries
target_link_libraries(YYCCBenchmark
PRIVATE
YYCCommonplace
benchmark::benchmark
)

4
benchmark/main.cpp Normal file
View File

@ -0,0 +1,4 @@
int main(int argc, char* argv[]) {
return 0;
}

View File

@ -1031,7 +1031,7 @@ EXCLUDE_SYMBOLS =
# that contain example code fragments that are included (see the \include
# command).
EXAMPLE_PATH = @CMAKE_CURRENT_LIST_DIR@/../testbench
EXAMPLE_PATH = @CMAKE_CURRENT_LIST_DIR@/../test
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and

View File

@ -21,7 +21,7 @@ public:
m_StringArgument(YYCC_U8("string"), YYCC::ArgParser::AbstractArgument::NO_SHORT_NAME, nullptr, nullptr, true),
m_BoolArgument(nullptr, YYCC_U8_CHAR('b'), nullptr),
m_ClampedFloatArgument(YYCC_U8("clamped-float"), YYCC::ArgParser::AbstractArgument::NO_SHORT_NAME, nullptr, nullptr, true, YYCC::Constraints::GetMinMaxRangeConstraint<float>(-1.0f, 1.0f)),
m_OptionContext(YYCC_U8("TestArgParser"), YYCC_U8("This is the testbench of argument parser."), {
m_OptionContext(YYCC_U8("TestArgParser"), YYCC_U8("This is the test of argument parser."), {
&m_IntArgument, &m_FloatArgument, &m_StringArgument,
&m_BoolArgument, &m_ClampedFloatArgument
}) {}

View File

@ -1,7 +1,7 @@
# Create executable testbench
add_executable(YYCCTestbench "")
# Setup testbench sources
target_sources(YYCCTestbench
# Create executable test
add_executable(YYCCTest "")
# Setup test sources
target_sources(YYCCTest
PRIVATE
main.cpp
@ -42,19 +42,19 @@ PRIVATE
yycc/carton/tabulate.cpp
yycc/carton/clap.cpp
)
target_sources(YYCCTestbench
target_sources(YYCCTest
PRIVATE
FILE_SET HEADERS
FILES
shared/literals.hpp
)
# Setup headers
target_include_directories(YYCCTestbench
target_include_directories(YYCCTest
PUBLIC
"${CMAKE_CURRENT_LIST_DIR}"
)
# Setup libraries
target_link_libraries(YYCCTestbench
target_link_libraries(YYCCTest
PRIVATE
YYCCommonplace
GTest::gtest_main
@ -62,4 +62,4 @@ PRIVATE
# Discover all test
include(GoogleTest)
gtest_discover_tests(YYCCTestbench)
gtest_discover_tests(YYCCTest)