mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Add RawPDU c'tor for const payload_type&. (#253)
* Add RawPDU c'tor for const payload_type &. * Correct indentation.
This commit is contained in:
committed by
Matias Fontanini
parent
ab2850e22e
commit
04e29858ee
@@ -96,6 +96,16 @@ public:
|
||||
RawPDU(ForwardIterator start, ForwardIterator end)
|
||||
: payload_(start, end) { }
|
||||
|
||||
/**
|
||||
* \brief Creates an instance of RawPDU from a payload_type.
|
||||
*
|
||||
* The payload is copied into the RawPDU's internal buffer.
|
||||
*
|
||||
* \param data The payload to use.
|
||||
*/
|
||||
RawPDU(const payload_type & data)
|
||||
: payload_(data) { }
|
||||
|
||||
#if TINS_IS_CXX11
|
||||
/**
|
||||
* \brief Creates an instance of RawPDU from a payload_type.
|
||||
|
||||
@@ -78,6 +78,7 @@ CREATE_TEST(network_interface)
|
||||
CREATE_TEST(pdu)
|
||||
CREATE_TEST(pdu_iterator)
|
||||
CREATE_TEST(pppoe)
|
||||
CREATE_TEST(raw_pdu)
|
||||
CREATE_TEST(radiotap)
|
||||
CREATE_TEST(rc4_eapol)
|
||||
CREATE_TEST(rsn_eapol)
|
||||
|
||||
21
tests/src/raw_pdu_test.cpp
Normal file
21
tests/src/raw_pdu_test.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <tins/rawpdu.h>
|
||||
|
||||
using namespace Tins;
|
||||
|
||||
class RawPDUTest : public testing::Test {
|
||||
public:
|
||||
};
|
||||
|
||||
TEST_F(RawPDUTest, ConstructFromPayloadType) {
|
||||
RawPDU::payload_type payload;
|
||||
payload.push_back(0x01);
|
||||
payload.push_back(0x02);
|
||||
|
||||
RawPDU raw = RawPDU(payload);
|
||||
EXPECT_EQ(payload, raw.payload());
|
||||
|
||||
// The payload should have been copied
|
||||
payload.push_back(0x03);
|
||||
EXPECT_NE(payload, raw.payload());
|
||||
}
|
||||
Reference in New Issue
Block a user