Last active
          June 22, 2018 13:44 
        
      - 
      
- 
        Save NorbertFenk/42be159c451b41c374092da23ca82921 to your computer and use it in GitHub Desktop. 
    QtTest benchmark with CMake
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | https://stackoverflow.com/a/23560316/5789008 | |
| ------------------ CMakeLists.txt ------------------ | |
| cmake_minimum_required(VERSION 3.9) | |
| project(qt_perf_test_with_cmake) | |
| enable_testing() | |
| set(CMAKE_AUTOMOC ON) | |
| set(CMAKE_INCLUDE_CURRENT_DIR ON) | |
| find_package(Qt5Test REQUIRED) | |
| set(CMAKE_CXX_STANDARD 11) | |
| add_executable(tst_qt_with_perftest test.cpp) | |
| add_test(tst_qt_with_perftest test) | |
| target_link_libraries(tst_qt_with_perftest Qt5::Test) | |
| ------------------ test.cpp ------------------ | |
| #include <QString> | |
| #include <QtTest> | |
| class TestBenchmark: public QObject | |
| { | |
| Q_OBJECT | |
| private slots: | |
| void simple(); | |
| }; | |
| void TestBenchmark::simple() | |
| { | |
| QString str1 = QLatin1String("This is a test string"); | |
| QString str2 = QLatin1String("This is a test string"); | |
| QCOMPARE(str1.localeAwareCompare(str2), 0); | |
| QBENCHMARK { | |
| str1.localeAwareCompare(str2); | |
| } | |
| } | |
| QTEST_MAIN(TestBenchmark) | |
| #include "test.moc" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment