Skip to content

Commit

Permalink
Test to check version output
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kopp <[email protected]>
  • Loading branch information
vifactor committed Sep 23, 2024
1 parent bedfc52 commit 46991bf
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion qdlt/tests/test_dltoptmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@

#include <QCommandLineParser>


QString logMessageSink;

void messageHandler(QtMsgType type, const QMessageLogContext &,
const QString &msg) {
if (type == QtDebugMsg) {
logMessageSink.append(msg);
}
}

class OptManagerTest : public ::testing::Test {
protected:
static void SetUpTestSuite() {
m_manager = QDltOptManager::getInstance();
// TODO: redirect qDebug-output to string

qInstallMessageHandler(messageHandler);
}

void SetUp() override {
Expand Down Expand Up @@ -40,6 +51,10 @@ class OptManagerTest : public ::testing::Test {
});
}

void TearDown() override {
logMessageSink.clear();
}

static QDltOptManager* m_manager;
QCommandLineParser m_parser;

Expand Down Expand Up @@ -182,3 +197,15 @@ TEST_F(OptManagerTest, mf4Files) {
EXPECT_TRUE(m_manager->isCommandlineMode());
}

TEST_F(OptManagerTest, version) {
// impossible to check just version because there is a call to exit(0) in the qdltoptmanager
// but any output will be enough to check the version call because it is always printed
auto args = QStringList() << "executable" << "some.dlt";
m_parser.parse(args);

m_manager->parse(m_parser, "test");

EXPECT_TRUE(logMessageSink.contains("Executable Name:"));
EXPECT_TRUE(logMessageSink.contains("Build time:"));
EXPECT_TRUE(logMessageSink.contains("Version:"));
}

0 comments on commit 46991bf

Please sign in to comment.