From 67ef2a52c3cdcc37538d77711bbcea2f0e5655e5 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 10 Oct 2019 13:29:02 +0100 Subject: IVGCVSW-3964 Change the type held by the Packet class to unsigned char * Updated the Packet class * Updated the pertinent code accordingly Signed-off-by: Matteo Martincigh Change-Id: I73eab5b1ead67a610cd17fd33f8a74f764ad8cc4 --- ...ProfilingConnectionDumpToFileDecoratorTests.cpp | 8 +++---- src/profiling/test/ProfilingTests.cpp | 26 +++++++++++----------- src/profiling/test/ProfilingTests.hpp | 6 ++--- 3 files changed, 19 insertions(+), 21 deletions(-) (limited to 'src/profiling/test') diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp index fac93c5ddf..a7acdd63cc 100644 --- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp +++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp @@ -32,7 +32,7 @@ class DummyProfilingConnection : public IProfilingConnection public: DummyProfilingConnection() : m_Open(true) - , m_PacketData(std::make_unique(g_DataLength)) + , m_PacketData(std::make_unique(g_DataLength)) { // populate packet data and construct packet std::memcpy(m_PacketData.get(), g_DataPtr, g_DataLength); @@ -65,8 +65,8 @@ public: } private: - bool m_Open; - std::unique_ptr m_PacketData; + bool m_Open; + std::unique_ptr m_PacketData; std::unique_ptr m_Packet; }; @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(DumpIncomingValidFile) decorator.Close(); std::vector data = ReadDumpFile(settings.m_IncomingDumpFileName); - const char* packetData = packet->GetData(); + const char* packetData = reinterpret_cast(packet->GetData()); // check if the data read back from the dump file matches the original constexpr unsigned int bytesToSkip = 2u * sizeof(uint32_t); // skip header and packet length diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index 57a11d0503..27bacf7145 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -198,9 +198,9 @@ BOOST_AUTO_TEST_CASE(CheckEncodeVersion) BOOST_AUTO_TEST_CASE(CheckPacketClass) { uint32_t length = 4; - std::unique_ptr packetData0 = std::make_unique(length); - std::unique_ptr packetData1 = std::make_unique(0); - std::unique_ptr nullPacketData; + std::unique_ptr packetData0 = std::make_unique(length); + std::unique_ptr packetData1 = std::make_unique(0); + std::unique_ptr nullPacketData; Packet packetTest0(472580096, length, packetData0); @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(CheckPacketClass) BOOST_CHECK(packetTest3.GetLength() == 0); BOOST_CHECK(packetTest3.GetData() == nullptr); - const char* packetTest0Data = packetTest0.GetData(); + const unsigned char* packetTest0Data = packetTest0.GetData(); Packet packetTest4(std::move(packetTest0)); BOOST_CHECK(packetTest0.GetData() == nullptr); @@ -260,9 +260,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor) it++; BOOST_CHECK(it->first==keyC); - std::unique_ptr packetDataA; - std::unique_ptr packetDataB; - std::unique_ptr packetDataC; + std::unique_ptr packetDataA; + std::unique_ptr packetDataB; + std::unique_ptr packetDataC; Packet packetA(500000000, 0, packetDataA); Packet packetB(600000000, 0, packetDataB); @@ -302,9 +302,9 @@ BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry) registry.RegisterFunctor(&testFunctorB); registry.RegisterFunctor(&testFunctorC); - std::unique_ptr packetDataA; - std::unique_ptr packetDataB; - std::unique_ptr packetDataC; + std::unique_ptr packetDataA; + std::unique_ptr packetDataB; + std::unique_ptr packetDataC; Packet packetA(500000000, 0, packetDataA); Packet packetB(600000000, 0, packetDataB); @@ -1707,7 +1707,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) uint32_t dataLength1 = 8; uint32_t offset = 0; - std::unique_ptr uniqueData1 = std::make_unique(dataLength1); + std::unique_ptr uniqueData1 = std::make_unique(dataLength1); unsigned char* data1 = reinterpret_cast(uniqueData1.get()); WriteUint32(data1, offset, period1); @@ -1758,7 +1758,7 @@ BOOST_AUTO_TEST_CASE(CounterSelectionCommandHandlerParseData) uint32_t period2 = 11; uint32_t dataLength2 = 4; - std::unique_ptr uniqueData2 = std::make_unique(dataLength2); + std::unique_ptr uniqueData2 = std::make_unique(dataLength2); WriteUint32(reinterpret_cast(uniqueData2.get()), 0, period2); @@ -1802,7 +1802,7 @@ BOOST_AUTO_TEST_CASE(CheckConnectionAcknowledged) uint32_t dataLength1 = 8; uint32_t offset = 0; - std::unique_ptr uniqueData1 = std::make_unique(dataLength1); + std::unique_ptr uniqueData1 = std::make_unique(dataLength1); unsigned char* data1 = reinterpret_cast(uniqueData1.get()); WriteUint32(data1, offset, period1); diff --git a/src/profiling/test/ProfilingTests.hpp b/src/profiling/test/ProfilingTests.hpp index e1686162db..4d2f974344 100644 --- a/src/profiling/test/ProfilingTests.hpp +++ b/src/profiling/test/ProfilingTests.hpp @@ -71,8 +71,7 @@ public: std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); // Return connection acknowledged packet - std::unique_ptr packetData; - return Packet(65536, 0, packetData); + return Packet(65536); } }; @@ -94,8 +93,7 @@ public: } // Return connection acknowledged packet after three timeouts - std::unique_ptr packetData; - return Packet(65536, 0, packetData); + return Packet(65536); } private: -- cgit v1.2.1