Skip to content

Commit ca37b6c

Browse files
committed
Renaming OTATestDataGenerator.h/.cpp into OTATestUtil.h/.cpp and encapsulating its methods into namespace OTA
1 parent ca3e6a1 commit ca37b6c

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

extras/test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ set(TEST_SRCS
4444
src/test_writeOnly.cpp
4545

4646
src/util/CBORTestUtil.cpp
47-
src/util/OTATestDataGenerator.cpp
47+
src/util/OTATestUtil.cpp
4848

4949
../../src/utility/ota/crc.cpp
5050
../../src/utility/ota/OTALogic.cpp

extras/test/include/util/OTATestDataGenerator.h renamed to extras/test/include/util/OTATestUtil.h

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
#include <stdint.h>
1313

14+
/**************************************************************************************
15+
NAMESPACE
16+
**************************************************************************************/
17+
18+
namespace ota
19+
{
20+
1421
/**************************************************************************************
1522
TYPEDEF
1623
**************************************************************************************/
@@ -33,5 +40,10 @@ union OTAData
3340
void generate_valid_ota_data(OTAData & ota_data);
3441
void generate_invalid_ota_data_crc_wrong(OTAData & ota_data);
3542

43+
/**************************************************************************************
44+
NAMESPACE
45+
**************************************************************************************/
46+
47+
} /* ota */
3648

3749
#endif /* OTA_TEST_DATA_GENERATOR_H_ */

extras/test/src/test_OTALogic.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <catch.hpp>
1313
#include <fakeit.hpp>
1414

15-
#include <util/OTATestDataGenerator.h>
15+
#include <util/OTATestUtil.h>
1616

1717
#include <OTALogic.h>
1818
#include <OTAStorage.h>
@@ -27,7 +27,7 @@ using namespace fakeit;
2727
TEST HELPER
2828
**************************************************************************************/
2929

30-
void simulateOTABinaryReception(OTALogic & ota_logic, OTAData const & ota_test_data)
30+
void simulateOTABinaryReception(OTALogic & ota_logic, ota::OTAData const & ota_test_data)
3131
{
3232
uint32_t bytes_written = 0;
3333
uint32_t const bytes_to_write = sizeof(uint32_t) + sizeof(uint32_t) + ota_test_data.data.len;
@@ -212,8 +212,8 @@ TEST_CASE("Valid OTA data is received ", "[OTALogic]")
212212

213213

214214
/* Generate test data */
215-
OTAData valid_ota_test_data;
216-
generate_valid_ota_data(valid_ota_test_data);
215+
ota::OTAData valid_ota_test_data;
216+
ota::generate_valid_ota_data(valid_ota_test_data);
217217

218218

219219
/* Perform test */
@@ -259,8 +259,8 @@ TEST_CASE("Invalid OTA data is received ", "[OTALogic - CRC wrong]")
259259

260260

261261
/* Generate test data */
262-
OTAData invalid_valid_ota_test_data_crc_wrong;
263-
generate_invalid_ota_data_crc_wrong(invalid_valid_ota_test_data_crc_wrong);
262+
ota::OTAData invalid_valid_ota_test_data_crc_wrong;
263+
ota::generate_invalid_ota_data_crc_wrong(invalid_valid_ota_test_data_crc_wrong);
264264

265265

266266
/* Perform test */

extras/test/src/util/OTATestDataGenerator.cpp renamed to extras/test/src/util/OTATestUtil.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
INCLUDE
77
**************************************************************************************/
88

9-
#include <util/OTATestDataGenerator.h>
9+
#include <util/OTATestUtil.h>
1010

1111
#include <algorithm>
1212

1313
#include <crc.h>
1414

15+
/**************************************************************************************
16+
NAMESPACE
17+
**************************************************************************************/
18+
19+
namespace ota
20+
{
21+
1522
/**************************************************************************************
1623
FUNCTION DEFINITION
1724
**************************************************************************************/
@@ -58,3 +65,9 @@ void generate_invalid_ota_data_crc_wrong(OTAData & ota_data)
5865
/* Generate CRC */
5966
ota_data.data.crc32 = 0xDEADBEEF;
6067
}
68+
69+
/**************************************************************************************
70+
NAMESPACE
71+
**************************************************************************************/
72+
73+
} /* ota */

0 commit comments

Comments
 (0)