Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions autotests/dfm-io-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ endif()

message(STATUS "Adding unit tests for ${IO_TEST_LIB}")

# Collect test source files
file(GLOB_RECURSE TEST_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/*.h
# 共享的测试入口点
set(TEST_COMMON_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/test_main.cpp
)

# 各测试类源文件(不含 main)
set(TEST_CLASS_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/tst_dfm_io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tst_dfilesorter.cpp
)

# Create the test executable
add_executable(dfm-io-test
${TEST_SRCS}
${TEST_COMMON_SRCS}
${TEST_CLASS_SRCS}
)

# Link against the dfm-io library and Qt Test
Expand All @@ -27,17 +33,11 @@ target_link_libraries(dfm-io-test
)

# Add include directories
if(DFM_BUILD_WITH_QT6)
target_include_directories(dfm-io-test
PRIVATE
${CMAKE_SOURCE_DIR}/src/dfm-io/dfm-io
)
else()
target_include_directories(dfm-io-test
PRIVATE
${CMAKE_SOURCE_DIR}/src/dfm-io/dfm-io
)
endif()
target_include_directories(dfm-io-test
PRIVATE
${CMAKE_SOURCE_DIR}/src/dfm-io/dfm-io
${CMAKE_SOURCE_DIR}/src/dfm-io/dfm-io/sort
)

# Register the test with CTest
add_test(NAME dfm-io-test COMMAND dfm-io-test)
23 changes: 23 additions & 0 deletions autotests/dfm-io-tests/test_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <QTest>

Check warning on line 5 in autotests/dfm-io-tests/test_main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTest> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 5 in autotests/dfm-io-tests/test_main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QTest> not found. Please note: Cppcheck does not need standard library headers to get proper results.

// 前置声明测试类
class tst_DfmIO;
class tst_DFileSorter;

int main(int argc, char *argv[])
{
int status = 0;

// 运行各测试类
extern int run_tst_DfmIO(int argc, char *argv[]);
extern int run_tst_DFileSorter(int argc, char *argv[]);

status |= run_tst_DfmIO(argc, argv);
status |= run_tst_DFileSorter(argc, argv);

return status;
}
Loading
Loading