Skip to content

Commit

Permalink
add qtest framework
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfengzzz committed Jan 27, 2024
1 parent 002ba38 commit a16770f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ if (APPLE)
endif ()

find_package(Qt6 COMPONENTS
Core Widgets
Core Widgets Test
REQUIRED)
find_package(fmt CONFIG REQUIRED)

add_subdirectory(third_party)
add_subdirectory(editor)
add_subdirectory(app)
add_subdirectory(tests)
21 changes: 21 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024 Feng Yang
#
# I am making my contributions/submissions to this project solely in my
# personal capacity and am not conveying any rights to any intellectual
# property of any third parties.

cmake_minimum_required(VERSION 3.16)
project(tests LANGUAGES CXX)

qt_standard_project_setup()

qt_add_executable(${PROJECT_NAME}
main.cpp
test_qstring.cpp
)

target_link_libraries(${PROJECT_NAME} PRIVATE
Qt6::Core
Qt6::Test
Qt6::Widgets
)
16 changes: 16 additions & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024 Feng Yang
//
// I am making my contributions/submissions to this project solely in my
// personal capacity and am not conveying any rights to any intellectual
// property of any third parties.

#include <Qtest>

#include "test_qstring.h"

int main(int argc, char *argv[]) {
int status = 0;
status |= QTest::qExec(new TestQString, argc, argv);

return status;
}
12 changes: 12 additions & 0 deletions tests/test_qstring.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2024 Feng Yang
//
// I am making my contributions/submissions to this project solely in my
// personal capacity and am not conveying any rights to any intellectual
// property of any third parties.

#include "test_qstring.h"

void TestQString::toUpper() {
QString str = "Hello";
QVERIFY(str.toUpper() == "HELLO");
}
15 changes: 15 additions & 0 deletions tests/test_qstring.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2024 Feng Yang
//
// I am making my contributions/submissions to this project solely in my
// personal capacity and am not conveying any rights to any intellectual
// property of any third parties.

#pragma once

#include <QTest>

class TestQString : public QObject {
Q_OBJECT
private slots:
void toUpper();
};
3 changes: 0 additions & 3 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
"dependencies" : [ {
"name" : "fmt",
"version>=" : "10.1.1"
}, {
"name" : "gtest",
"version>=" : "1.14.0"
}, {
"name" : "vcpkg-cmake-config",
"version>=" : "2022-02-06#1"
Expand Down

0 comments on commit a16770f

Please sign in to comment.