Skip to content

Commit ea47d2d

Browse files
committed
#171 commented linux build
1 parent a1f59a5 commit ea47d2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+409
-629
lines changed

tests/unit/mocks.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,33 @@
22
#define UNIT_MOCKS_H
33

44
#include <gmock/gmock.h>
5+
56
#include "CmdLineBaseExecutor.h"
6-
#include "FVADataProcessor.h"
77
#include "CmdLineBaseTask.h"
8+
#include "FVADataProcessor.h"
89
#include "FvaConfiguration.h"
910
#include "fvacltcontext.h"
1011

11-
const char TEST_DIR[] = "D:/a/fva/fva/build"; // Set the directory to a test value, somewhere on your system
12+
const char TEST_DIR[] = "D:/a/fva/fva/build"; // Set the directory to a test value, somewhere on your system
1213

1314
// Mock implementation of CmdLineBaseTask for testing purposes
14-
class MockCmdLineBaseTask : public CmdLineBaseTask
15-
{
15+
class MockCmdLineBaseTask : public CmdLineBaseTask {
1616
public:
1717
MOCK_METHOD(FVA_EXIT_CODE, execute, (const CLTContext&), (override));
1818
};
1919

2020
// Mock implementation of CmdLineBaseExecutor for testing purposes
21-
class MockCmdLineBaseExecutor : public CmdLineBaseExecutor
22-
{
21+
class MockCmdLineBaseExecutor : public CmdLineBaseExecutor {
2322
public:
24-
std::unique_ptr<CmdLineBaseTask> createTaskByName(const CLTContext& context, const FvaConfiguration& cfg) override
25-
{
23+
std::unique_ptr<CmdLineBaseTask> createTaskByName(const CLTContext& context, const FvaConfiguration& cfg) override {
2624
return std::make_unique<MockCmdLineBaseTask>();
2725
}
2826
};
2927
// Mock implementation of CmdLineBaseExecutor for testing purposes
30-
class MockCmdLineBaseExecutorEmptyCmd : public CmdLineBaseExecutor
31-
{
28+
class MockCmdLineBaseExecutorEmptyCmd : public CmdLineBaseExecutor {
3229
public:
33-
std::unique_ptr<CmdLineBaseTask> createTaskByName(const CLTContext& context, const FvaConfiguration& cfg) override
34-
{
35-
return std::unique_ptr<CmdLineBaseTask>(); // Return null to simulate an unknown command
30+
std::unique_ptr<CmdLineBaseTask> createTaskByName(const CLTContext& context, const FvaConfiguration& cfg) override {
31+
return std::unique_ptr<CmdLineBaseTask>(); // Return null to simulate an unknown command
3632
}
3733
};
38-
#endif // UNIT_MOCKS_H
34+
#endif // UNIT_MOCKS_H

tests/unit/test_CLTAutoChecks1.cpp

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
#include <gtest/gtest.h>
21
#include <gmock/gmock.h>
2+
#include <gtest/gtest.h>
3+
34
#include "CLTAutoChecks1.h"
45

56
// Mocking the dependencies
6-
class MockQDir : public QDir
7-
{
7+
class MockQDir : public QDir {
88
public:
99
MOCK_CONST_METHOD1(entryInfoList, QList<QFileInfo>(QDir::Filters filters));
1010
};
1111

12-
class MockQFileInfo : public QFileInfo
13-
{
12+
class MockQFileInfo : public QFileInfo {
1413
public:
1514
MOCK_CONST_METHOD0(isDir, bool());
1615
MOCK_CONST_METHOD0(suffix, QString());
@@ -19,27 +18,22 @@ class MockQFileInfo : public QFileInfo
1918
MOCK_CONST_METHOD0(lastModified, QDateTime());
2019
};
2120

22-
class MockCLTContext : public CLTContext
23-
{
24-
};
21+
class MockCLTContext : public CLTContext {};
2522

2623
// Test fixture for CLTAutoChecks1 tests
27-
class CLTAutoChecks1Tests : public ::testing::Test
28-
{
24+
class CLTAutoChecks1Tests : public ::testing::Test {
2925
protected:
30-
void SetUp() override
31-
{
26+
void SetUp() override {
3227
// Set up any necessary objects or test data
3328
}
3429

35-
void TearDown() override
36-
{
30+
void TearDown() override {
3731
// Clean up any resources used by the tests
3832
}
3933

4034
// Helper function to create a mock QFileInfo object
41-
MockQFileInfo* CreateMockQFileInfo(bool isDir, const QString& suffix, const QString& fileName, const QString& absoluteFilePath, const QDateTime& lastModified)
42-
{
35+
MockQFileInfo* CreateMockQFileInfo(bool isDir, const QString& suffix, const QString& fileName,
36+
const QString& absoluteFilePath, const QDateTime& lastModified) {
4337
auto mockFileInfo = new MockQFileInfo();
4438
ON_CALL(*mockFileInfo, isDir()).WillByDefault(::testing::Return(isDir));
4539
ON_CALL(*mockFileInfo, suffix()).WillByDefault(::testing::Return(suffix));
@@ -50,16 +44,14 @@ class CLTAutoChecks1Tests : public ::testing::Test
5044
}
5145
};
5246

53-
5447
// Test case for CLTAutoChecks1::execute
55-
TEST_F(CLTAutoChecks1Tests, Execute)
56-
{
48+
TEST_F(CLTAutoChecks1Tests, Execute) {
5749
// Arrange
5850
MockQDir mockDir;
5951
MockCLTContext mockContext;
6052
FvaConfiguration cfg;
6153
CLTAutoChecks1 cltAutoChecks1(cfg);
62-
54+
6355
// Set up the necessary variables and objects
6456
/* TODo
6557
QList<MockQFileInfo*> mockFileInfos;
@@ -71,8 +63,10 @@ TEST_F(CLTAutoChecks1Tests, Execute)
7163
mockFileInfos.append(CreateMockQFileInfo(false, "MP3", "audio.mp3", "/path/to/audio.mp3", QDateTime()));
7264
mockFileInfos.append(CreateMockQFileInfo(false, "PNG", "image.png", "/path/to/image.png", QDateTime()));
7365
mockFileInfos.append(CreateMockQFileInfo(false, "STL", "panoram.stl", "/path/to/panoram.stl", QDateTime()));
74-
75-
ON_CALL(mockDir, entryInfoList(::testing::_)).WillByDefault(::testing::Return(QList<QFileInfo>::fromStdList(std::list<QFileInfo*>(mockFileInfos.begin(), mockFileInfos.end()))));
66+
67+
ON_CALL(mockDir,
68+
entryInfoList(::testing::_)).WillByDefault(::testing::Return(QList<QFileInfo>::fromStdList(std::list<QFileInfo*>(mockFileInfos.begin(),
69+
mockFileInfos.end()))));
7670
*/
7771
// Act
7872
FVA_EXIT_CODE result = cltAutoChecks1.execute(mockContext);
@@ -82,8 +76,7 @@ TEST_F(CLTAutoChecks1Tests, Execute)
8276
}
8377

8478
// Test case for execute function
85-
TEST_F(CLTAutoChecks1Tests, ExecuteSimple)
86-
{
79+
TEST_F(CLTAutoChecks1Tests, ExecuteSimple) {
8780
// Arrange
8881
FvaConfiguration cfg;
8982
CLTAutoChecks1 task(cfg);
@@ -98,8 +91,7 @@ TEST_F(CLTAutoChecks1Tests, ExecuteSimple)
9891
}
9992

10093
// Test case for supportReadOnly function
101-
TEST_F(CLTAutoChecks1Tests, SupportReadOnly)
102-
{
94+
TEST_F(CLTAutoChecks1Tests, SupportReadOnly) {
10395
// Arrange
10496
FvaConfiguration cfg;
10597
CLTAutoChecks1 task(cfg);
@@ -113,8 +105,7 @@ TEST_F(CLTAutoChecks1Tests, SupportReadOnly)
113105
}
114106

115107
// Test case for Name function
116-
TEST_F(CLTAutoChecks1Tests, Name)
117-
{
108+
TEST_F(CLTAutoChecks1Tests, Name) {
118109
// Act
119110
QString name = CLTAutoChecks1::Name();
120111

tests/unit/test_CLTAutoChecks2.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
11
#include <gtest/gtest.h>
2+
23
#include "CLTAutoChecks2.h"
34

45
// Test fixture for CLTAutoChecks2 tests
5-
class CLTAutoChecks2Tests : public ::testing::Test
6-
{
6+
class CLTAutoChecks2Tests : public ::testing::Test {
77
protected:
8-
void SetUp() override
9-
{
8+
void SetUp() override {
109
// Set up any necessary objects or test data
1110
}
1211

13-
void TearDown() override
14-
{
12+
void TearDown() override {
1513
// Clean up any resources used by the tests
1614
}
1715
};
1816

1917
// Test case for execute function
20-
TEST_F(CLTAutoChecks2Tests, Execute)
21-
{
18+
TEST_F(CLTAutoChecks2Tests, Execute) {
2219
// Arrange
2320
FvaConfiguration cfg;
2421
CLTAutoChecks2 cltAutoChecks2(cfg);
25-
CLTContext context; // Set up the necessary context for the test
22+
CLTContext context; // Set up the necessary context for the test
2623

2724
// Act
2825
FVA_EXIT_CODE result = cltAutoChecks2.execute(context);
2926

3027
// Assert
31-
EXPECT_EQ(FVA_ERROR_WRONG_FOLDER_NAME, result); // Verify that the function returns the expected error code
28+
EXPECT_EQ(FVA_ERROR_WRONG_FOLDER_NAME, result); // Verify that the function returns the expected error code
3229
// Add more assertions to verify the expected behavior and output
3330
}
3431

3532
// Test case for execute function with configuration
36-
TEST_F(CLTAutoChecks2Tests, ExecuteWithCfg)
37-
{
33+
TEST_F(CLTAutoChecks2Tests, ExecuteWithCfg) {
3834
// Arrange
3935
FvaConfiguration cfg;
4036
CLTAutoChecks2 task(cfg);
@@ -51,8 +47,7 @@ TEST_F(CLTAutoChecks2Tests, ExecuteWithCfg)
5147
}
5248

5349
// Test case for Name function
54-
TEST_F(CLTAutoChecks2Tests, Name)
55-
{
50+
TEST_F(CLTAutoChecks2Tests, Name) {
5651
// Arrange
5752

5853
// Act
@@ -64,8 +59,7 @@ TEST_F(CLTAutoChecks2Tests, Name)
6459
}
6560

6661
// Test case for supportReadOnly function
67-
TEST_F(CLTAutoChecks2Tests, SupportReadOnly)
68-
{
62+
TEST_F(CLTAutoChecks2Tests, SupportReadOnly) {
6963
// Arrange
7064
FvaConfiguration cfg;
7165
CLTAutoChecks2 task(cfg);

tests/unit/test_CLTAutoChecks3.cpp

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,121 @@
11
#include <gtest/gtest.h>
2+
23
#include "CLTAutoChecks3.h"
34

45
// Test fixture for CLTAutoChecks3 tests
5-
class CLTAutoChecks3Tests : public ::testing::Test
6-
{
6+
class CLTAutoChecks3Tests : public ::testing::Test {
77
protected:
8-
void SetUp() override
9-
{
8+
void SetUp() override {
109
// Set up any necessary objects or test data
1110
}
1211

13-
void TearDown() override
14-
{
12+
void TearDown() override {
1513
// Clean up any resources used by the tests
1614
}
1715
};
1816

1917
// Test case for execute function with missing device ID
20-
TEST_F(CLTAutoChecks3Tests, Execute_MissingDeviceID)
21-
{
18+
TEST_F(CLTAutoChecks3Tests, Execute_MissingDeviceID) {
2219
// Arrange
2320
FvaConfiguration config;
2421
CLTAutoChecks3 cltAutoChecks3(config);
25-
CLTContext context; // Set up the necessary context for the test
22+
CLTContext context; // Set up the necessary context for the test
2623
// Add a file to the directory that does not have a corresponding device ID in the CSV file
2724

2825
// Act
2926
FVA_EXIT_CODE result = cltAutoChecks3.execute(context);
3027

3128
// Assert
3229
// TODO shell be checned in the #logs#/issues3.csv
33-
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
30+
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
3431
// Add more assertions to verify the expected behavior and output
3532
}
3633

3734
// Test case for execute function with unknown device
38-
TEST_F(CLTAutoChecks3Tests, Execute_UnknownDevice)
39-
{
35+
TEST_F(CLTAutoChecks3Tests, Execute_UnknownDevice) {
4036
// Arrange
4137
FvaConfiguration config;
4238
CLTAutoChecks3 cltAutoChecks3(config);
43-
CLTContext context; // Set up the necessary context for the test
39+
CLTContext context; // Set up the necessary context for the test
4440
// Add a file to the directory with an unknown device name
4541

4642
// Act
4743
FVA_EXIT_CODE result = cltAutoChecks3.execute(context);
4844

4945
// Assert
50-
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
46+
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
5147
// Add more assertions to verify the expected behavior and output
5248
}
5349

5450
// Test case for execute function with empty device name
55-
TEST_F(CLTAutoChecks3Tests, Execute_EmptyDeviceName)
56-
{
51+
TEST_F(CLTAutoChecks3Tests, Execute_EmptyDeviceName) {
5752
// Arrange
5853
FvaConfiguration config;
5954
CLTAutoChecks3 cltAutoChecks3(config);
60-
CLTContext context; // Set up the necessary context for the test
55+
CLTContext context; // Set up the necessary context for the test
6156
// Add a file to the directory with an empty device name
6257

6358
// Act
6459
FVA_EXIT_CODE result = cltAutoChecks3.execute(context);
6560

6661
// Assert
6762
// TODO shell be checned in the #logs#/issues3.csv for FVA_ERROR_EMPTY_DEVICE_NAME
68-
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns
63+
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns
6964
// Add more assertions to verify the expected behavior and output
7065
}
7166

7267
// Test case for execute function with wrongly linked device ID
73-
TEST_F(CLTAutoChecks3Tests, Execute_WronglyLinkedDeviceID)
74-
{
68+
TEST_F(CLTAutoChecks3Tests, Execute_WronglyLinkedDeviceID) {
7569
// Arrange
7670
FvaConfiguration config;
7771
CLTAutoChecks3 cltAutoChecks3(config);
78-
CLTContext context; // Set up the necessary context for the test
72+
CLTContext context; // Set up the necessary context for the test
7973
// Add a file to the directory with a device ID that is linked wrongly
8074

8175
// Act
8276
FVA_EXIT_CODE result = cltAutoChecks3.execute(context);
8377

8478
// Assert
8579
// TODO shell be checned in the #logs#/issues3.csv for FVA_ERROR_LINKED_WRONG_DEVICE
86-
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
80+
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
8781
// Add more assertions to verify the expected behavior and output
8882
}
8983

9084
// Test case for execute function with missing GEO location
91-
TEST_F(CLTAutoChecks3Tests, Execute_MissingGeoLocation)
92-
{
85+
TEST_F(CLTAutoChecks3Tests, Execute_MissingGeoLocation) {
9386
// Arrange
9487
FvaConfiguration config;
9588
CLTAutoChecks3 cltAutoChecks3(config);
96-
CLTContext context; // Set up the necessary context for the test
89+
CLTContext context; // Set up the necessary context for the test
9790
// Add a file to the directory without GEO location data
9891

9992
// Act
10093
FVA_EXIT_CODE result = cltAutoChecks3.execute(context);
10194

10295
// Assert
10396
// TODO shell be checned in the #logs#/issues3.csv
104-
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_NO_GEO
97+
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_NO_GEO
10598
// Add more assertions to verify the expected behavior and output
10699
}
107100

108101
// Test case for execute function
109-
TEST_F(CLTAutoChecks3Tests, Execute)
110-
{
102+
TEST_F(CLTAutoChecks3Tests, Execute) {
111103
// Arrange
112104
FvaConfiguration config;
113105
CLTAutoChecks3 cltAutoChecks3(config);
114-
CLTContext context; // Set up the necessary context for the test
106+
CLTContext context; // Set up the necessary context for the test
115107

116108
// Act
117109
FVA_EXIT_CODE result = cltAutoChecks3.execute(context);
118110

119111
// Assert
120112
// TODO shell be checned in the #logs#/issues3.csv
121-
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
113+
EXPECT_EQ(FVA_ERROR_UNKNOWN_DEVICE, result); // Verify that the function returns FVA_ERROR_UNKNOWN_DEVICE
122114
// Add more assertions to verify the expected behavior and output
123115
}
124116

125117
// Test case for Name function
126-
TEST_F(CLTAutoChecks3Tests, Name)
127-
{
118+
TEST_F(CLTAutoChecks3Tests, Name) {
128119
// Arrange
129120

130121
// Act
@@ -136,8 +127,7 @@ TEST_F(CLTAutoChecks3Tests, Name)
136127
}
137128

138129
// Test case for supportReadOnly function
139-
TEST_F(CLTAutoChecks3Tests, SupportReadOnly)
140-
{
130+
TEST_F(CLTAutoChecks3Tests, SupportReadOnly) {
141131
// Arrange
142132
FvaConfiguration config;
143133
CLTAutoChecks3 task(config);

0 commit comments

Comments
 (0)