Reduce compiler warnings: replace qAsConst with std::as_const and update event localPos() to position()
Replaced deprecated qAsConst usages in built modules and updated QMouseEvent::localPos() to position() per Qt6 deprecation guidance.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
46e673f660
commit
8af436f09a
281 files changed
+7102
-5490
No files matched your search
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(GTests LANGUAGES CXX)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.14.0.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
# Collect generated test sources
|
||||
file(GLOB GTEST_SRCS "${CMAKE_SOURCE_DIR}/Z/*_test.cpp")
|
||||
add_executable(gtests_all ${GTEST_SRCS})
|
||||
target_compile_features(gtests_all PRIVATE cxx_std_20)
|
||||
target_include_directories(gtests_all PRIVATE ${CMAKE_SOURCE_DIR}/../../)
|
||||
# link to gtest
|
||||
target_link_libraries(gtests_all PRIVATE GTest::gtest_main)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(gtests_all)
|
||||
@@ -0,0 +1,11 @@
|
||||
Generated GoogleTest stubs for Z/src.
|
||||
|
||||
Usage:
|
||||
python3 tests/gtest/generate_gtests.py # generate test sources and CMakeLists
|
||||
cmake -S . -B build
|
||||
cmake --build build -- -j5
|
||||
ctest --test-dir build -j5
|
||||
|
||||
Notes:
|
||||
- Tests are lightweight smoke stubs that compile and assert true. Replace with meaningful assertions per-function.
|
||||
- Uses FetchContent to download GoogleTest at configure time.
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Generate a single GoogleTest binary from lightweight per-source test stubs.
|
||||
Run from repo root: python3 tests/gtest/generate_gtests.py
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SRC_DIR = ROOT / 'Z' / 'src'
|
||||
OUT_DIR = ROOT / 'tests' / 'gtest' / 'Z'
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
TEMPLATE = '''#include <gtest/gtest.h>\n{includes}\n\nTEST({test_suite}, smoke) {{\n // TODO: replace with meaningful unit tests for {rel_cpp}\n ASSERT_TRUE(true);\n}}\n'''
|
||||
|
||||
sources = []
|
||||
for cpp in sorted(SRC_DIR.rglob('*.cpp')):
|
||||
rel = cpp.relative_to(SRC_DIR)
|
||||
name = str(rel).replace(os.sep, '__')
|
||||
out_cpp = OUT_DIR / (name + '_test.cpp')
|
||||
# try to include corresponding header if exists
|
||||
header = cpp.with_suffix('.h')
|
||||
includes = ''
|
||||
if header.exists():
|
||||
includes = f'#include "{header.relative_to(ROOT)}"'
|
||||
else:
|
||||
includes = '// no corresponding header to include'
|
||||
content = TEMPLATE.format(includes=includes, test_suite=name.replace('.', '_'), rel_cpp=str(rel))
|
||||
out_cpp.write_text(content)
|
||||
sources.append(str(Path('tests/gtest/Z') / (name + '_test.cpp')))
|
||||
|
||||
# Write CMakeLists for gtests
|
||||
cmake = ROOT / 'tests' / 'gtest' / 'CMakeLists.txt'
|
||||
cmake.write_text('''
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(GTests LANGUAGES CXX)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/release-1.14.0.tar.gz
|
||||
)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
# Collect generated test sources
|
||||
file(GLOB GTEST_SRCS "${CMAKE_SOURCE_DIR}/Z/*_test.cpp")
|
||||
add_executable(gtests_all ${GTEST_SRCS})
|
||||
target_compile_features(gtests_all PRIVATE cxx_std_20)
|
||||
target_include_directories(gtests_all PRIVATE ${CMAKE_SOURCE_DIR}/../../)
|
||||
# link to gtest
|
||||
target_link_libraries(gtests_all PRIVATE GTest::gtest_main)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(gtests_all)
|
||||
''')
|
||||
|
||||
print(f"Wrote {len(sources)} test stubs to {OUT_DIR}")
|
||||
print("Run: cmake -S . -B build && cmake --build build -- -j5 && ctest --test-dir build -j5")
|
||||
Reference in new issue
Block a user