Skip to content

Commit 7298549

Browse files
cngzhnpOzanCansel
andauthored
Forgetten int8_t type support for vector data output (#1136)
Co-authored-by: Ozan Cansel <[email protected]>
1 parent 391fad5 commit 7298549

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

hazelcast/include/hazelcast/client/serialization/pimpl/data_output.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class HAZELCAST_API data_output
138138
typename std::enable_if<std::is_same<std::vector<byte>, T>::value ||
139139
std::is_same<std::vector<char>, T>::value ||
140140
std::is_same<std::vector<bool>, T>::value ||
141+
std::is_same<std::vector<int8_t>, T>::value ||
141142
std::is_same<std::vector<int16_t>, T>::value ||
142143
std::is_same<std::vector<int32_t>, T>::value ||
143144
std::is_same<std::vector<int64_t>, T>::value ||
@@ -349,6 +350,7 @@ template<typename T>
349350
typename std::enable_if<std::is_same<std::vector<byte>, T>::value ||
350351
std::is_same<std::vector<char>, T>::value ||
351352
std::is_same<std::vector<bool>, T>::value ||
353+
std::is_same<std::vector<int8_t>, T>::value ||
352354
std::is_same<std::vector<int16_t>, T>::value ||
353355
std::is_same<std::vector<int32_t>, T>::value ||
354356
std::is_same<std::vector<int64_t>, T>::value ||

hazelcast/test/src/HazelcastTests1.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,24 @@ TEST_F(DataOutputTest, testWriteChar_16_LittleEndian)
36753675
ASSERT_EQ(std::vector<byte>({ 0xAC, 0x20 }), dataOutput.to_byte_array());
36763676
}
36773677

3678+
TEST_F(DataOutputTest, testWriteInt8)
3679+
{
3680+
std::vector<byte> bytes{ 0x34, 0x12 };
3681+
serialization::pimpl::data_output dataOutput(boost::endian::order::big);
3682+
dataOutput.write<int8_t>(0x34);
3683+
dataOutput.write<int8_t>(0x12);
3684+
ASSERT_EQ(bytes, dataOutput.to_byte_array());
3685+
}
3686+
3687+
TEST_F(DataOutputTest, testWriteInt8_LittleEndian)
3688+
{
3689+
std::vector<byte> bytes{ 0x1A, 0x5F };
3690+
serialization::pimpl::data_output dataOutput(boost::endian::order::little);
3691+
dataOutput.write<int8_t>(0x1A);
3692+
dataOutput.write<int8_t>(0x5F);
3693+
ASSERT_EQ(bytes, dataOutput.to_byte_array());
3694+
}
3695+
36783696
TEST_F(DataOutputTest, testWriteShort)
36793697
{
36803698
std::vector<byte> bytes{ 0x12, 0x34 };

0 commit comments

Comments
 (0)