commit
e5232aee9d
20 changed files with 219 additions and 48 deletions
|
@ -6,3 +6,4 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
conan_basic_setup()
|
conan_basic_setup()
|
||||||
|
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
[requires]
|
[requires]
|
||||||
protobuf/3.6.1@bincrafters/stable
|
protobuf/3.6.1@bincrafters/stable
|
||||||
|
catch2/2.4.2@bincrafters/stable
|
||||||
|
|
||||||
[generators]
|
[generators]
|
||||||
cmake
|
cmake
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
Age::Age(unsigned int years, unsigned int months)
|
Age::Age(unsigned int years, unsigned int months)
|
||||||
: m_years(years)
|
: m_years(years)
|
||||||
, m_months(months)
|
, m_months(months)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ Age::Age(const QDate &birth, const QDate &reference)
|
||||||
m_years = years;
|
m_years = years;
|
||||||
m_months = months;
|
m_months = months;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Age::operator<(const Age &cmp) const
|
bool Age::operator<(const Age &cmp) const
|
||||||
{
|
{
|
||||||
if (m_years == cmp.m_years)
|
if (m_years == cmp.m_years)
|
||||||
|
@ -47,7 +47,7 @@ bool Age::operator<(const Age &cmp) const
|
||||||
|
|
||||||
return m_years < cmp.m_years;
|
return m_years < cmp.m_years;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Age::years() const
|
unsigned int Age::years() const
|
||||||
{
|
{
|
||||||
return m_years;
|
return m_years;
|
||||||
|
@ -57,7 +57,7 @@ unsigned int Age::months() const
|
||||||
{
|
{
|
||||||
return m_months;
|
return m_months;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Age::toString() const
|
std::string Age::toString() const
|
||||||
{
|
{
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
23
source/Age/CMakeLists.txt
Normal file
23
source/Age/CMakeLists.txt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
cmake_minimum_required(VERSION 3.6)
|
||||||
|
|
||||||
|
project(Age LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME}
|
||||||
|
Age.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(${PROJECT_NAME}
|
||||||
|
PROPERTIES CXX_STANDARD 14
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
Qt5::Core
|
||||||
|
)
|
|
@ -34,10 +34,9 @@ protobuf_generate_cpp(DataModel_PROTO_SRCS DataModel_PROTO_HDRS
|
||||||
${DataModel_PROTO_FILES})
|
${DataModel_PROTO_FILES})
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} WIN32
|
add_executable(${PROJECT_NAME} WIN32
|
||||||
LogoTest.cpp
|
ESGRAF48.cpp
|
||||||
DataModel.cpp
|
DataModel.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
Age.cpp
|
|
||||||
${LOGO_TEST_UI}
|
${LOGO_TEST_UI}
|
||||||
${LOGO_TEST_QRC}
|
${LOGO_TEST_QRC}
|
||||||
${DataModel_PROTO_SRCS}
|
${DataModel_PROTO_SRCS}
|
||||||
|
@ -57,6 +56,7 @@ target_include_directories(${PROJECT_NAME}
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Age
|
||||||
CheckableItem
|
CheckableItem
|
||||||
CheckableTest
|
CheckableTest
|
||||||
CheckableTestModel
|
CheckableTestModel
|
||||||
|
@ -73,6 +73,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
${Protobuf_LIBRARIES}
|
${Protobuf_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory(Age)
|
||||||
add_subdirectory(CheckableItem)
|
add_subdirectory(CheckableItem)
|
||||||
add_subdirectory(CheckableTest)
|
add_subdirectory(CheckableTest)
|
||||||
add_subdirectory(CheckableTestModel)
|
add_subdirectory(CheckableTestModel)
|
||||||
|
|
21
source/ESGRAF48.cpp
Normal file
21
source/ESGRAF48.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
std::unique_ptr<MainWindow> mainWindow;
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
mainWindow = std::make_unique<MainWindow>(nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mainWindow = std::make_unique<MainWindow>(nullptr, argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindow->show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
#include "mainwindow.h"
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
MainWindow mainWindow;
|
|
||||||
mainWindow.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
|
@ -41,6 +41,7 @@ target_include_directories(${PROJECT_NAME}
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Age
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
${Protobuf_LIBRARIES}
|
${Protobuf_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Age.h"
|
#include "Age.h"
|
||||||
|
|
||||||
#include "MetaDataModel.pb.h"
|
#include "MetaDataModel.pb.h"
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,6 @@ target_include_directories(${PROJECT_NAME}
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Age
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Age.h"
|
#include "Age.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class PRMap
|
class PRMap
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Age.h"
|
#include "Age.h"
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
class TestResult
|
class TestResult
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
#include "DataModel.h"
|
|
||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -21,16 +19,46 @@
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
|
, m_dataModel(this)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
setupUi();
|
||||||
|
|
||||||
|
newFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent, const QString &filename)
|
||||||
|
: QMainWindow(parent)
|
||||||
|
, ui(new Ui::MainWindow)
|
||||||
|
, m_dataModel(this)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
setupUi();
|
||||||
|
|
||||||
|
openFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupUi()
|
||||||
|
{
|
||||||
|
ui->metaDataWidget->setModel(&m_dataModel.m_metaData);
|
||||||
|
ui->verbEndWidget->setModel(&m_dataModel.m_verbEnd);
|
||||||
|
ui->genusWidget->setModel(&m_dataModel.m_genus);
|
||||||
|
ui->pluralWidget->setModel(&m_dataModel.m_plural);
|
||||||
|
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel.m_akkusativ);
|
||||||
|
ui->akkusativDativWidget->setDativModel(&m_dataModel.m_dativ);
|
||||||
|
ui->v2SvkWidget->setV2SvkModel(&m_dataModel.m_v2Svk);
|
||||||
|
ui->lateSkillsWidget->setPassivModel(&m_dataModel.m_passiv);
|
||||||
|
ui->lateSkillsWidget->setGenitivModel(&m_dataModel.m_genitiv);
|
||||||
|
ui->resultWidget->setModel(&m_dataModel.m_results);
|
||||||
|
|
||||||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
||||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openFile);
|
connect(ui->actionOpen, &QAction::triggered, this, qOverload<>(&MainWindow::openFile));
|
||||||
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
|
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
|
||||||
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
||||||
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
|
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
|
||||||
|
connect(ui->actionExport_PDF, &QAction::triggered, this, qOverload<>(&MainWindow::savePdf));
|
||||||
|
|
||||||
newFile();
|
connect(&m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -42,21 +70,6 @@ void MainWindow::newFile()
|
||||||
{
|
{
|
||||||
closeFile();
|
closeFile();
|
||||||
|
|
||||||
m_dataModel = std::make_unique<DataModel>(this);
|
|
||||||
ui->metaDataWidget->setModel(&m_dataModel->m_metaData);
|
|
||||||
ui->verbEndWidget->setModel(&m_dataModel->m_verbEnd);
|
|
||||||
ui->genusWidget->setModel(&m_dataModel->m_genus);
|
|
||||||
ui->pluralWidget->setModel(&m_dataModel->m_plural);
|
|
||||||
ui->akkusativDativWidget->setAkkusativModel(&m_dataModel->m_akkusativ);
|
|
||||||
ui->akkusativDativWidget->setDativModel(&m_dataModel->m_dativ);
|
|
||||||
ui->v2SvkWidget->setV2SvkModel(&m_dataModel->m_v2Svk);
|
|
||||||
ui->lateSkillsWidget->setPassivModel(&m_dataModel->m_passiv);
|
|
||||||
ui->lateSkillsWidget->setGenitivModel(&m_dataModel->m_genitiv);
|
|
||||||
|
|
||||||
ui->resultWidget->setModel(&m_dataModel->m_results);
|
|
||||||
|
|
||||||
connect(&*m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
|
|
||||||
|
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
setWindowTitle("untitled[*]");
|
setWindowTitle("untitled[*]");
|
||||||
m_filename = "";
|
m_filename = "";
|
||||||
|
@ -72,10 +85,15 @@ void MainWindow::openFile()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::openFile(const QString &filename)
|
||||||
|
{
|
||||||
closeFile();
|
closeFile();
|
||||||
|
|
||||||
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
|
std::fstream protoInFile(filename.toStdString(), std::ios::in | std::ios::binary);
|
||||||
m_dataModel->read(protoInFile);
|
m_dataModel.read(protoInFile);
|
||||||
|
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
setWindowTitle(filename + "[*]");
|
setWindowTitle(filename + "[*]");
|
||||||
|
@ -133,7 +151,7 @@ void MainWindow::closeFile()
|
||||||
void MainWindow::print() const
|
void MainWindow::print() const
|
||||||
{
|
{
|
||||||
//std::ofstream htmlfile("print.html");
|
//std::ofstream htmlfile("print.html");
|
||||||
//htmlfile << m_dataModel->toHtml();
|
//htmlfile << m_dataModel.toHtml();
|
||||||
|
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
|
|
||||||
|
@ -144,7 +162,7 @@ void MainWindow::print() const
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextDocument printDoc;
|
QTextDocument printDoc;
|
||||||
printDoc.setHtml(QString::fromStdString(m_dataModel->toHtml()));
|
printDoc.setHtml(QString::fromStdString(m_dataModel.toHtml()));
|
||||||
|
|
||||||
printDoc.print(&printer);
|
printDoc.print(&printer);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +173,22 @@ void MainWindow::dataModelChanged()
|
||||||
setWindowModified(true);
|
setWindowModified(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::savePdf()
|
||||||
|
{
|
||||||
|
QFileDialog saveFilenameDialog(this);
|
||||||
|
saveFilenameDialog.setDefaultSuffix("pdf");
|
||||||
|
saveFilenameDialog.setFileMode(QFileDialog::AnyFile);
|
||||||
|
saveFilenameDialog.setNameFilter("PDF File (*.pdf)");
|
||||||
|
saveFilenameDialog.setWindowTitle("Save file");
|
||||||
|
|
||||||
|
if (!saveFilenameDialog.exec())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
savePdf(saveFilenameDialog.selectedFiles().first());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
closeFile();
|
closeFile();
|
||||||
|
@ -164,7 +198,7 @@ void MainWindow::saveFile(const QString &filename)
|
||||||
{
|
{
|
||||||
std::fstream protoOutFile(filename.toStdString(),
|
std::fstream protoOutFile(filename.toStdString(),
|
||||||
std::ios::out | std::ios::trunc | std::ios::binary);
|
std::ios::out | std::ios::trunc | std::ios::binary);
|
||||||
m_dataModel->write(protoOutFile);
|
m_dataModel.write(protoOutFile);
|
||||||
|
|
||||||
qDebug() << "Wrote" << filename;
|
qDebug() << "Wrote" << filename;
|
||||||
|
|
||||||
|
@ -173,3 +207,16 @@ void MainWindow::saveFile(const QString &filename)
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
m_saveOnClose = false;
|
m_saveOnClose = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::savePdf(const QString &filename)
|
||||||
|
{
|
||||||
|
QPrinter printer;
|
||||||
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||||
|
printer.setPaperSize(QPrinter::A4);
|
||||||
|
printer.setOutputFileName(filename);
|
||||||
|
|
||||||
|
QTextDocument printDoc;
|
||||||
|
printDoc.setHtml(QString::fromStdString(m_dataModel.toHtml()));
|
||||||
|
|
||||||
|
printDoc.print(&printer);
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include "DataModel.h"
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class DataModel;
|
class DataModel;
|
||||||
class QDataWidgetMapper;
|
class QDataWidgetMapper;
|
||||||
|
@ -17,26 +19,31 @@ class MainWindow : public QMainWindow
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
std::unique_ptr<DataModel> m_dataModel;
|
DataModel m_dataModel;
|
||||||
QString m_filename;
|
QString m_filename;
|
||||||
bool m_saveOnClose = false;
|
bool m_saveOnClose = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent);
|
||||||
|
MainWindow(QWidget *parent, const QString &filename);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newFile();
|
void newFile();
|
||||||
void openFile();
|
void openFile();
|
||||||
|
void openFile(const QString &filename);
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void saveFileAs();
|
void saveFileAs();
|
||||||
void closeFile();
|
void closeFile();
|
||||||
void print() const;
|
void print() const;
|
||||||
void dataModelChanged();
|
void dataModelChanged();
|
||||||
|
void savePdf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupUi();
|
||||||
void saveFile(const QString &filename);
|
void saveFile(const QString &filename);
|
||||||
|
void savePdf(const QString &filename);
|
||||||
};
|
};
|
||||||
|
|
|
@ -133,6 +133,7 @@
|
||||||
<addaction name="actionSave_as"/>
|
<addaction name="actionSave_as"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionPrint"/>
|
<addaction name="actionPrint"/>
|
||||||
|
<addaction name="actionExport_PDF"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -228,6 +229,14 @@
|
||||||
<string>Ctrl+P</string>
|
<string>Ctrl+P</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExport_PDF">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export PDF</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Export as PDF file</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
40
test/Age.cpp
Normal file
40
test/Age.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
#include "Age.h"
|
||||||
|
|
||||||
|
TEST_CASE("default initialization")
|
||||||
|
{
|
||||||
|
Age age;
|
||||||
|
REQUIRE(age.years() == 0);
|
||||||
|
REQUIRE(age.months() == 0);
|
||||||
|
REQUIRE(age.toString() == "0;0");
|
||||||
|
|
||||||
|
Age age2;
|
||||||
|
REQUIRE(!(age < age));
|
||||||
|
REQUIRE(!(age < age2));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("year/month initialization")
|
||||||
|
{
|
||||||
|
for (unsigned int year = 0; year <= 100; ++year)
|
||||||
|
{
|
||||||
|
for (unsigned int month = 0; month < 12; ++month)
|
||||||
|
{
|
||||||
|
Age age(year, month);
|
||||||
|
|
||||||
|
REQUIRE(age.years() == year);
|
||||||
|
REQUIRE(age.months() == month);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("age by reference")
|
||||||
|
{
|
||||||
|
QDate birth(1970, 1, 1);
|
||||||
|
QDate reference(1980, 1, 1);
|
||||||
|
|
||||||
|
Age age(birth, reference);
|
||||||
|
|
||||||
|
REQUIRE(age.years() == 10);
|
||||||
|
REQUIRE(age.months() == 0);
|
||||||
|
}
|
21
test/CMakeLists.txt
Normal file
21
test/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(run-tests)
|
||||||
|
|
||||||
|
find_package(Catch2 REQUIRED)
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}
|
||||||
|
main.cpp
|
||||||
|
dummy.cpp
|
||||||
|
Age.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
Catch2::Catch2
|
||||||
|
Age
|
||||||
|
)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
include(Catch)
|
||||||
|
catch_discover_tests(${PROJECT_NAME})
|
||||||
|
|
7
test/dummy.cpp
Normal file
7
test/dummy.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
TEST_CASE("Dummy")
|
||||||
|
{
|
||||||
|
REQUIRE(true == true);
|
||||||
|
}
|
||||||
|
|
2
test/main.cpp
Normal file
2
test/main.cpp
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include <catch2/catch.hpp>
|
Loading…
Reference in a new issue