1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Add test for partial TCP packet.

This commit is contained in:
Matias Fontanini
2015-04-05 09:43:50 -07:00
parent 3791fc0ee6
commit ebad686987

View File

@@ -12,7 +12,8 @@ using namespace Tins;
class TCPTest : public testing::Test {
public:
static const uint8_t expected_packet[], checksum_packet[];
static const uint8_t expected_packet[], checksum_packet[],
partial_packet[];
void test_equals(const TCP &tcp1, const TCP &tcp2);
};
@@ -30,6 +31,10 @@ const uint8_t TCPTest::checksum_packet[] = {
0, 0
};
const uint8_t TCPTest::partial_packet[] = {
142, 210, 0, 80, 60, 158, 102, 111, 10, 2, 46, 161, 80, 24, 0, 229, 247, 192, 0, 0
};
TEST_F(TCPTest, DefaultConstructor) {
TCP tcp;
@@ -197,7 +202,6 @@ void TCPTest::test_equals(const TCP &tcp1, const TCP &tcp2) {
EXPECT_EQ((bool)tcp1.inner_pdu(), (bool)tcp2.inner_pdu());
}
// This is not working, but i don't want to fix it right now.
TEST_F(TCPTest, ConstructorFromBuffer) {
TCP tcp1(expected_packet, sizeof(expected_packet));
@@ -229,6 +233,11 @@ TEST_F(TCPTest, ConstructorFromBuffer) {
test_equals(tcp1, tcp2);
}
TEST_F(TCPTest, ConstructorFromPartialBuffer) {
TCP tcp(partial_packet, sizeof(partial_packet));
EXPECT_FALSE(tcp.inner_pdu());
}
TEST_F(TCPTest, Serialize) {
TCP tcp1(expected_packet, sizeof(expected_packet));
PDU::serialization_type buffer = tcp1.serialize();