-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Details: - Adding tests for the already implemented CMDP methods - Extracting the common parts from the MDP tests that can be used for the CMDP and future protocols and storing them into the test_protocol_common.h - Updating the MDP unit tests
- Loading branch information
Showing
4 changed files
with
159 additions
and
33 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
tests/sources/test_continous_measurement_data_protocol.cpp
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//==============================================================================// | ||
// // | ||
// RDB Diplomaterv Monitor // | ||
// A monitor program for the RDB Diplomaterv project // | ||
// Copyright (C) 2018 András Gergő Kocsis // | ||
// // | ||
// This program is free software: you can redistribute it and/or modify // | ||
// it under the terms of the GNU General Public License as published by // | ||
// the Free Software Foundation, either version 3 of the License, or // | ||
// (at your option) any later version. // | ||
// // | ||
// This program is distributed in the hope that it will be useful, // | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
// GNU General Public License for more details. // | ||
// // | ||
// You should have received a copy of the GNU General Public License // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. // | ||
// // | ||
//==============================================================================// | ||
|
||
|
||
|
||
#include <fstream> | ||
|
||
#include <gtest/gtest.h> | ||
#include <gmock/gmock-matchers.h> | ||
|
||
#include <QCoreApplication> | ||
#include <QString> | ||
#include <QDir> | ||
|
||
#include "../application/sources/global.hpp" | ||
#include "../application/sources/continous_measurement_data_protocol.hpp" | ||
#include "test_protocol_common.h" | ||
|
||
|
||
|
||
class TestContinousMeasurementDataProtocol : public ::testing::Test, | ||
public testing::WithParamInterface<TestProtocolParameter> | ||
{ | ||
protected: | ||
ContinousMeasurementDataProtocol test_cmdp_processor; | ||
std::string expected_protocol_name = "Continous Measurement Data Protocol CMDP"; | ||
std::vector<DiagramSpecialized> processed_diagrams; | ||
// Empty string as the CMDP does not support file handling | ||
std::string expected_file_type; | ||
}; | ||
|
||
TEST_F(TestContinousMeasurementDataProtocol, GetProtocolName) | ||
{ | ||
EXPECT_EQ(test_cmdp_processor.GetProtocolName(), expected_protocol_name); | ||
} | ||
|
||
TEST_F(TestContinousMeasurementDataProtocol, CanThisFileBeProcessed) | ||
{ | ||
std::string filename_to_test = std::string("myfile.") + expected_file_type; | ||
EXPECT_FALSE(test_cmdp_processor.CanThisFileBeProcessed(filename_to_test)); | ||
filename_to_test = std::string("mymdpfile.") + std::string("txt"); | ||
EXPECT_FALSE(test_cmdp_processor.CanThisFileBeProcessed(filename_to_test)); | ||
} | ||
|
||
TEST_F(TestContinousMeasurementDataProtocol, GetSupportedFileType) | ||
{ | ||
EXPECT_EQ(test_cmdp_processor.GetSupportedFileType(), expected_file_type); | ||
} | ||
|
||
TEST_F(TestContinousMeasurementDataProtocol, ProcessData_EmptyStream) | ||
{ | ||
std::ifstream empty_stream; | ||
processed_diagrams = test_cmdp_processor.ProcessData(empty_stream); | ||
EXPECT_EQ(processed_diagrams.size(), std::size_t(0)); | ||
} | ||
|
||
TEST_F(TestContinousMeasurementDataProtocol, ExportData) | ||
{ | ||
std::stringstream exported_data; | ||
EXPECT_ANY_THROW(exported_data = test_cmdp_processor.ExportData(std::vector<DiagramSpecialized>())); | ||
EXPECT_EQ(exported_data.str(), std::string()); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//==============================================================================// | ||
// // | ||
// RDB Diplomaterv Monitor // | ||
// A monitor program for the RDB Diplomaterv project // | ||
// Copyright (C) 2018 András Gergő Kocsis // | ||
// // | ||
// This program is free software: you can redistribute it and/or modify // | ||
// it under the terms of the GNU General Public License as published by // | ||
// the Free Software Foundation, either version 3 of the License, or // | ||
// (at your option) any later version. // | ||
// // | ||
// This program is distributed in the hope that it will be useful, // | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
// GNU General Public License for more details. // | ||
// // | ||
// You should have received a copy of the GNU General Public License // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. // | ||
// // | ||
//==============================================================================// | ||
|
||
|
||
|
||
#include <fstream> | ||
|
||
#include <gtest/gtest.h> | ||
#include <gmock/gmock-matchers.h> | ||
|
||
#include <QString> | ||
|
||
|
||
|
||
#ifndef TEST_PROTOCOL_COMMON_H | ||
#define TEST_PROTOCOL_COMMON_H | ||
|
||
|
||
|
||
struct TestProtocolParameter | ||
{ | ||
TestProtocolParameter(const QString& new_file_name, | ||
const int& new_expected_correct_diagrams) : file_name(new_file_name), | ||
expected_correct_diagrams(new_expected_correct_diagrams) {} | ||
QString file_name; | ||
int expected_correct_diagrams; | ||
}; | ||
|
||
#endif // TEST_PROTOCOL_COMMON_H |
This file contains 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