diff --git a/cmake/jkqtplotter_macros.cmake b/cmake/jkqtplotter_macros.cmake index af19d0fc62..4589f2ab12 100644 --- a/cmake/jkqtplotter_macros.cmake +++ b/cmake/jkqtplotter_macros.cmake @@ -62,29 +62,6 @@ endfunction() include(GNUInstallDirs) -function(jkqtplotter_installlibrary lib_name libIncludeSubdir BuildTypePart) - install(TARGETS ${lib_name} EXPORT ${lib_name}_TARGETS - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} - ) - if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600) AND (NOT CMAKE_VERSION VERSION_LESS "3.1") AND (NOT BuildTypePart STREQUAL "")) - install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) - endif() - set(JKQTP_CURRENT_TARGET_SHAREDPART "${BuildTypePart}") - set(JKQTP_CURRENT_TARGET_FILENAME "${lib_name}Targets.cmake") - configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake" @ONLY) - install(EXPORT ${lib_name}_TARGETS - FILE "${JKQTP_CURRENT_TARGET_FILENAME}" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake - ) - - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake ) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake ) -endfunction(jkqtplotter_installlibrary) @@ -132,3 +109,44 @@ function(jkqtplotter_installlibrary_new lib_name libIncludeSubdir libSrcDir) # install license install(FILES "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION ${CMAKE_INSTALL_DOCDIR}) # RENAME "${lib_name}_LICENSE.txt" ) endfunction(jkqtplotter_installlibrary_new) + + +function(jkqtplotter_add_test TEST_NAME) + + set(EXENAME ${TEST_NAME}) + + message( STATUS ".. Building Unit Test ${TEST_NAME}" ) + + add_executable(${EXENAME} WIN32) + target_include_directories(${EXENAME} PRIVATE ../../lib) + target_link_libraries(${EXENAME} PRIVATE Qt${QT_VERSION_MAJOR}::Test) + + target_sources(${EXENAME} PRIVATE ${TEST_NAME}.cpp) + + # Installation + install(TARGETS ${EXENAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + add_test(NAME ${TEST_NAME} COMMAND COMMAND $) + + #Installation of Qt DLLs on Windows + jkqtplotter_deployqt(${EXENAME}) +endfunction(jkqtplotter_add_test) + +function(jkqtplotter_add_jkqtcommmon_test TEST_NAME) + jkqtplotter_add_test(${TEST_NAME}) + target_link_libraries(${TEST_NAME} PRIVATE ${jkqtplotter_namespace}JKQTCommon${jkqtplotter_LIBNAME_VERSION_PART}) +endfunction(jkqtplotter_add_test) + +function(jkqtplotter_add_jkqtmath_test TEST_NAME) + jkqtplotter_add_test(${TEST_NAME}) + target_link_libraries(${TEST_NAME} PRIVATE ${jkqtplotter_namespace}JKQTMath${jkqtplotter_LIBNAME_VERSION_PART}) +endfunction(jkqtplotter_add_test) + +function(jkqtplotter_add_jkqtmathtext_test TEST_NAME) + jkqtplotter_add_test(${TEST_NAME}) + target_link_libraries(${TEST_NAME} PRIVATE ${jkqtplotter_namespace}JKQTMathText${jkqtplotter_LIBNAME_VERSION_PART}) +endfunction(jkqtplotter_add_test) + +function(jkqtplotter_add_jkqtplotter_test TEST_NAME) + jkqtplotter_add_test(${TEST_NAME}) + target_link_libraries(${TEST_NAME} PRIVATE ${jkqtplotter_namespace}JKQTPlotter${jkqtplotter_LIBNAME_VERSION_PART}) +endfunction(jkqtplotter_add_test) diff --git a/tests/jkqtcommmon/CMakeLists.txt b/tests/jkqtcommmon/CMakeLists.txt index eeaa9d83cd..ea8b34b814 100644 --- a/tests/jkqtcommmon/CMakeLists.txt +++ b/tests/jkqtcommmon/CMakeLists.txt @@ -1,28 +1,10 @@ cmake_minimum_required(VERSION 3.23) -set(TEST_NAME jkqtcommon_test) -set(EXENAME ${TEST_NAME}) - -message( STATUS ".. Building Unit Test ${TEST_NAME}" ) - set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -add_executable(${EXENAME} WIN32 ${SOURCES} ${HEADERS} ${RESOURCES} ${UIS}) -target_include_directories(${EXENAME} PRIVATE ../../lib) -target_link_libraries(${EXENAME} PRIVATE ${jkqtplotter_namespace}JKQTCommon${jkqtplotter_LIBNAME_VERSION_PART}) -target_link_libraries(${EXENAME} PRIVATE Qt${QT_VERSION_MAJOR}::Test) - -target_sources(${EXENAME} - PRIVATE - ${TEST_NAME}.cpp -) - -# Installation -install(TARGETS ${EXENAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_test(NAME ${TEST_NAME} COMMAND COMMAND $) - -#Installation of Qt DLLs on Windows -jkqtplotter_deployqt(${EXENAME}) - +jkqtplotter_add_jkqtcommmon_test(JKQTPStringTools_test) +jkqtplotter_add_jkqtcommmon_test(JKQTPCSSParser_test) +jkqtplotter_add_jkqtcommmon_test(JKQTPDataCache_test) +jkqtplotter_add_jkqtcommmon_test(JKQTPDataCache_benchmark) diff --git a/tests/jkqtcommmon/jkqtcommon_test.cpp b/tests/jkqtcommmon/JKQTPCSSParser_test.cpp similarity index 80% rename from tests/jkqtcommmon/jkqtcommon_test.cpp rename to tests/jkqtcommmon/JKQTPCSSParser_test.cpp index b29458204c..02105213f4 100644 --- a/tests/jkqtcommmon/jkqtcommon_test.cpp +++ b/tests/jkqtcommmon/JKQTPCSSParser_test.cpp @@ -25,15 +25,15 @@ namespace QTest { } -class testJKQTCommmon : public QObject +class JKQTPCSSParserTest : public QObject { Q_OBJECT public: - inline testJKQTCommmon() { + inline JKQTPCSSParserTest() { } - inline ~testJKQTCommmon() { + inline ~JKQTPCSSParserTest() { } private slots: @@ -240,76 +240,9 @@ private slots: } - inline void test_JKQTPCSSParser_JKQTPDataCache_ThreadSafe() { - JKQTPDataCache cache([](int key) { return QString::number(key);}, 100,0.8); - - QString sum; - for (int i=0; i<100; i++) { - sum+=cache.get(i); - } - qDebug()<<"sum.size()="< +#include +#include "jkqtcommon/jkqtpcachingtools.h" + +#ifndef QCOMPARE_EQ +#define QCOMPARE_EQ(A,B) if (!static_cast((A)==(B))) {qDebug()< +#include +#include "jkqtcommon/jkqtpcachingtools.h" + +#ifndef QCOMPARE_EQ +#define QCOMPARE_EQ(A,B) if (!static_cast((A)==(B))) {qDebug()< +#include +#include "jkqtcommon/jkqtpstringtools.h" + +#ifndef QCOMPARE_EQ +#define QCOMPARE_EQ(A,B) if (!static_cast((A)==(B))) {qDebug()<