Skip to content

Commit a2e2225

Browse files
committed
Try to fix Unit tests
1 parent 1ea03ce commit a2e2225

8 files changed

Lines changed: 107 additions & 105 deletions

File tree

tests/unit/sources/plugins/Linky/TestLinkyReceiveBufferHandler.cpp

Lines changed: 41 additions & 41 deletions
Large diffs are not rendered by default.

tests/unit/sources/plugins/TeleInfo/TestTeleInfoReceiveBufferHandler.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Includes needed to compile the test
1212
#include "../../testCommon/serialTeleInfoMessage.h"
1313

14-
using namespace testCommon;
14+
using namespace test_common;
1515

1616
class BufferLoggerMock : public shared::communication::IBufferLogger
1717
{
@@ -66,28 +66,28 @@ BOOST_AUTO_TEST_SUITE(TestTeleInfoReceiveBufferHandler)
6666
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk("12"), false);
6767
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk("123"), false);
6868
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk("123"), false);
69-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(std::string{ testCommon::kStartMessage, ' ', testCommon::kEndMessage }), false);
69+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(std::string{ test_common::kStartMessage, ' ', test_common::kEndMessage }), false);
7070

7171
// Empty message
72-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(std::string{ testCommon::kStartMessage, ' ', 0x20, testCommon::kEndMessage }), true);
73-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(std::string{ testCommon::kStartMessage, ' ', 0x21, testCommon::kEndMessage }), false);
72+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(std::string{ test_common::kStartMessage, ' ', 0x20, test_common::kEndMessage }), true);
73+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(std::string{ test_common::kStartMessage, ' ', 0x21, test_common::kEndMessage }), false);
7474

7575
// Message OK
76-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("OPTARIF BASE 0")), true);
77-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("MOTDETAT 000000 B")), true);
78-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("ADCO 031428097115 @")), true);
79-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("PTEC TH.. $")), true);
76+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("OPTARIF BASE 0")), true);
77+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("MOTDETAT 000000 B")), true);
78+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("ADCO 031428097115 @")), true);
79+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("PTEC TH.. $")), true);
8080

8181
// Wrong CRC
82-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("OPTARIF BASE 1")), false);
83-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("MOTDETAT 000000 Z")), false);
84-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("ADCO 031428097115 5")), false);
85-
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(testCommon::serialTeleInfoMessage::toMessage("PTEC TH.. @")), false);
82+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("OPTARIF BASE 1")), false);
83+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("MOTDETAT 000000 Z")), false);
84+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("ADCO 031428097115 5")), false);
85+
BOOST_CHECK_EQUAL(bufferHandler.isCheckSumOk(test_common::serialTeleInfoMessage::toMessage("PTEC TH.. @")), false);
8686
}
8787

8888
BOOST_AUTO_TEST_CASE(getMessages)
8989
{
90-
const boost::shared_ptr<const std::vector<unsigned char>> frame = boost::make_shared<const std::vector<unsigned char>>(testCommon::serialTeleInfoMessage::normalizeFrame("5 F<cr><lf>PAPP 00490 .<cr><lf>MOTDETAT 000000 B<cr><etx><stx><lf>ADCO 031428097115 @<cr><lf>OPTARIF BASE 0<cr><lf>ISOUSC 30 9<cr><lf>BASE 006251693 +<cr><lf>PTEC TH.. $<cr><lf>IINST 002 Y<cr><lf>IMAX 025 F<cr><lf>PAPP 00490 .<cr><lf>MOTDETAT 000000 B<cr><etx>"));
90+
const boost::shared_ptr<const std::vector<unsigned char>> frame = boost::make_shared<const std::vector<unsigned char>>(test_common::serialTeleInfoMessage::normalizeFrame("5 F<cr><lf>PAPP 00490 .<cr><lf>MOTDETAT 000000 B<cr><etx><stx><lf>ADCO 031428097115 @<cr><lf>OPTARIF BASE 0<cr><lf>ISOUSC 30 9<cr><lf>BASE 006251693 +<cr><lf>PTEC TH.. $<cr><lf>IINST 002 Y<cr><lf>IMAX 025 F<cr><lf>PAPP 00490 .<cr><lf>MOTDETAT 000000 B<cr><etx>"));
9191
const std::map<std::string, std::string> expectedMap = {
9292
{ "ADCO", "031428097115" },
9393
{ "OPTARIF", "BASE" },

tests/unit/sources/server/pluginSystem/information/TestPluginInformation.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ class CTestPackageFile
103103
:m_packagePath(DefaultPackagePath / std::filesystem::path("package.json"))
104104
{
105105
// Create the package.json file
106-
testCommon::filesystem::writeFile(m_packagePath, content);
106+
test_common::Filesystem::writeFile(m_packagePath, content);
107107
}
108108
virtual ~CTestPackageFile()
109109
{
110110
// Clean-up
111-
testCommon::filesystem::removeFile(m_packagePath, false);
111+
test_common::Filesystem::removeFile(m_packagePath, false);
112112
}
113113
private:
114114
const std::filesystem::path m_packagePath;
@@ -117,7 +117,7 @@ class CTestPackageFile
117117
BOOST_AUTO_TEST_CASE(ReadDefaultInformation)
118118
{
119119
CTestPackageFile packageFile(DefaultPackageFileContent);
120-
pluginSystem::CInformation info(testCommon::filesystem::toBoost(DefaultPackagePath));
120+
pluginSystem::CInformation info(test_common::Filesystem::toBoost(DefaultPackagePath));
121121

122122
BOOST_CHECK_EQUAL(info.getType(), "FakePackage");
123123
BOOST_CHECK_EQUAL(info.getVersion().toString(), "0.0.1-beta");
@@ -137,8 +137,8 @@ BOOST_AUTO_TEST_CASE(WrongPackageFileJsonFormat)
137137
" \"author\": \"yadoms-team\","
138138
" \"url\": \"https://github.com/Yadoms/yadoms/\","); // Closing brace is missing
139139

140-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContent);
141-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
140+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContent);
141+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
142142
}
143143

144144
BOOST_AUTO_TEST_CASE(NullOrEmptyPluginName)
@@ -152,8 +152,8 @@ BOOST_AUTO_TEST_CASE(NullOrEmptyPluginName)
152152
" \"author\": \"yadoms-team\","
153153
" \"url\": \"https://github.com/Yadoms/yadoms/\""
154154
"}");
155-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyName);
156-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
155+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyName);
156+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
157157

158158
const std::string fileContentWithoutName(
159159
"{"
@@ -162,8 +162,8 @@ BOOST_AUTO_TEST_CASE(NullOrEmptyPluginName)
162162
" \"author\": \"yadoms-team\","
163163
" \"url\": \"https://github.com/Yadoms/yadoms/\""
164164
"}");
165-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutName);
166-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
165+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutName);
166+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
167167
}
168168

169169
BOOST_AUTO_TEST_CASE(NullOrEmptyPluginDescription)
@@ -176,8 +176,8 @@ BOOST_AUTO_TEST_CASE(NullOrEmptyPluginDescription)
176176
" \"author\": \"yadoms-team\","
177177
" \"url\": \"https://github.com/Yadoms/yadoms/\""
178178
"}");
179-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyDescription);
180-
BOOST_REQUIRE_NO_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")));
179+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyDescription);
180+
BOOST_REQUIRE_NO_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")));
181181

182182
const std::string fileContentWithoutDescription(
183183
"{"
@@ -186,8 +186,8 @@ BOOST_AUTO_TEST_CASE(NullOrEmptyPluginDescription)
186186
" \"author\": \"yadoms-team\","
187187
" \"url\": \"https://github.com/Yadoms/yadoms/\""
188188
"}");
189-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutDescription);
190-
BOOST_REQUIRE_NO_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")));
189+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutDescription);
190+
BOOST_REQUIRE_NO_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")));
191191
}
192192

193193
BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
@@ -200,8 +200,8 @@ BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
200200
" \"author\": \"yadoms-team\","
201201
" \"url\": \"https://github.com/Yadoms/yadoms/\""
202202
"}");
203-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyVersion);
204-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
203+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyVersion);
204+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
205205

206206
const std::string fileContentWithoutVersion(
207207
"{"
@@ -210,8 +210,8 @@ BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
210210
" \"author\": \"yadoms-team\","
211211
" \"url\": \"https://github.com/Yadoms/yadoms/\""
212212
"}");
213-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutVersion);
214-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
213+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutVersion);
214+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
215215

216216
const std::string fileContentWithBadVersion1(
217217
"{"
@@ -221,8 +221,8 @@ BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
221221
" \"author\": \"yadoms-team\","
222222
" \"url\": \"https://github.com/Yadoms/yadoms/\""
223223
"}");
224-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion1);
225-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
224+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion1);
225+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
226226

227227
const std::string fileContentWithBadVersion2(
228228
"{"
@@ -232,8 +232,8 @@ BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
232232
" \"author\": \"yadoms-team\","
233233
" \"url\": \"https://github.com/Yadoms/yadoms/\""
234234
"}");
235-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion2);
236-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
235+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion2);
236+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
237237

238238
const std::string fileContentWithBadVersion3(
239239
"{"
@@ -243,8 +243,8 @@ BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
243243
" \"author\": \"yadoms-team\","
244244
" \"url\": \"https://github.com/Yadoms/yadoms/\""
245245
"}");
246-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion3);
247-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
246+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion3);
247+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
248248

249249
const std::string fileContentWithBadVersion4(
250250
"{"
@@ -254,8 +254,8 @@ BOOST_AUTO_TEST_CASE(BadPluginVersionFormat)
254254
" \"author\": \"yadoms-team\","
255255
" \"url\": \"https://github.com/Yadoms/yadoms/\""
256256
"}");
257-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion4);
258-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
257+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithBadVersion4);
258+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
259259
}
260260

261261
BOOST_AUTO_TEST_CASE(NullOrEmptyPluginAuthor)
@@ -268,8 +268,8 @@ BOOST_AUTO_TEST_CASE(NullOrEmptyPluginAuthor)
268268
" \"author\": \"\","
269269
" \"url\": \"https://github.com/Yadoms/yadoms/\""
270270
"}");
271-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyAuthor);
272-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
271+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithEmptyAuthor);
272+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
273273

274274
const std::string fileContentWithoutAuthor(
275275
"{"
@@ -278,8 +278,8 @@ BOOST_AUTO_TEST_CASE(NullOrEmptyPluginAuthor)
278278
" \"version\": \"0.1.0-beta\","
279279
" \"url\": \"https://github.com/Yadoms/yadoms/\""
280280
"}");
281-
testCommon::filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutAuthor);
282-
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(testCommon::filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
281+
test_common::Filesystem::createFile(std::filesystem::temp_directory_path() / "FakePackage" / "package.json", fileContentWithoutAuthor);
282+
BOOST_REQUIRE_THROW(pluginSystem::CInformation info(test_common::Filesystem::toBoost(std::filesystem::temp_directory_path() / "FakePackage")), shared::exception::CInvalidParameter);
283283
}
284284

285285
BOOST_AUTO_TEST_SUITE_END()

tests/unit/sources/server/startupOptions/TestLoader.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@ class CTestPath final
1818
// Ensure TestDirectory is empty
1919
try
2020
{
21-
testCommon::filesystem::removeDirectory(m_testDirectory);
21+
test_common::Filesystem::removeDirectory(m_testDirectory);
2222
}
2323
catch (boost::filesystem::filesystem_error&)
2424
{
2525
// Under Windows, directory can be locked for a little duration after directory creation
2626
// So wait a bit and re-try
2727
boost::this_thread::sleep(boost::posix_time::millisec(500));
28-
testCommon::filesystem::removeDirectory(m_testDirectory);
28+
test_common::Filesystem::removeDirectory(m_testDirectory);
2929
}
3030

3131
// Create directory
32-
testCommon::filesystem::createDirectory(m_testDirectory);
32+
test_common::Filesystem::createDirectory(m_testDirectory);
3333
}
3434

3535
~CTestPath()
3636
{
3737
// Clean-up TestDirectory
3838
try
3939
{
40-
testCommon::filesystem::removeDirectory(m_testDirectory);
40+
test_common::Filesystem::removeDirectory(m_testDirectory);
4141
}
4242
catch (boost::filesystem::filesystem_error&)
4343
{
4444
// Under Windows, directory can be locked for a little duration after directory creation
4545
// So wait a bit and re-try
4646
boost::this_thread::sleep(boost::posix_time::millisec(500));
47-
testCommon::filesystem::removeDirectory(m_testDirectory);
47+
test_common::Filesystem::removeDirectory(m_testDirectory);
4848
}
4949
}
5050

0 commit comments

Comments
 (0)