Added two simple tests for the table model.
This commit is contained in:
@ -17,7 +17,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core LinguistTools)
|
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core LinguistTools)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools)
|
||||||
|
|
||||||
add_executable(${TARGET_APP} core_test.cpp)
|
add_executable(${TARGET_APP} core_test.cpp
|
||||||
|
model_test.cpp)
|
||||||
|
|
||||||
target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/include)
|
target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/include)
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ inline void PrintTo(const QString& qString, ::std::ostream* os) { *os << qUtf8Pr
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
TEST(CoreTests, TestEqualString) {
|
TEST(CoreTests, TestEqualString) {
|
||||||
const QString coreName("GenericCore");
|
const QString coreName("BeetRoundCore");
|
||||||
const QString coreVersion("0.1.0");
|
const QString coreVersion("0.1.0");
|
||||||
const auto expected = QString("%1 (Version %2)").arg(coreName).arg(coreVersion);
|
const auto expected = QString("%1 (Version %2)").arg(coreName).arg(coreVersion);
|
||||||
auto core = std::make_unique<GenericCore>();
|
auto core = std::make_unique<GenericCore>();
|
||||||
|
|||||||
34
tests/GenericCoreTests/model_test.cpp
Normal file
34
tests/GenericCoreTests/model_test.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include <QtGui/QUndoCommand>
|
||||||
|
|
||||||
|
#include "../../libs/BeetRoundCore/model/tablemodel.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
inline void PrintTo(const QString& qString, ::std::ostream* os) { *os << qUtf8Printable(qString); }
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
struct ModelTest : testing::Test {
|
||||||
|
std::shared_ptr<TableModel> model;
|
||||||
|
|
||||||
|
ModelTest() { model = make_shared<TableModel>(new QUndoStack()); }
|
||||||
|
|
||||||
|
~ModelTest() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(ModelTest, TestRowCount) {
|
||||||
|
const int expectedRowCount = 0;
|
||||||
|
|
||||||
|
const auto actualRowCount = model->rowCount();
|
||||||
|
|
||||||
|
ASSERT_EQ(expectedRowCount, actualRowCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ModelTest, TestBidding1Average) {
|
||||||
|
const int expected = 0;
|
||||||
|
const auto actualBidding1Average = model->biddingAverage1();
|
||||||
|
|
||||||
|
ASSERT_EQ(expected, actualBidding1Average);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user