1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/base/udp_packet.h"
6
7 #include <vector>
8
9 #include "gmock/gmock.h"
10 #include "gtest/gtest.h"
11
12 namespace openscreen {
13
TEST(UdpPacketTest,ValidateToStringNormalCase)14 TEST(UdpPacketTest, ValidateToStringNormalCase) {
15 UdpPacket packet{0x73, 0xC7, 0x00, 0x14, 0xFF, 0x2C};
16 std::string result = packet.ToString();
17 EXPECT_EQ(result, "[73 C7 00 14 FF 2C ]");
18
19 UdpPacket packet2{0x1, 0x2, 0x3, 0x4, 0x5};
20 result = packet2.ToString();
21 EXPECT_EQ(result, "[01 02 03 04 05 ]");
22
23 UdpPacket packet3{0x0, 0x0, 0x0};
24 result = packet3.ToString();
25 EXPECT_EQ(result, "[00 00 00 ]");
26 }
27
TEST(UdpPacketTest,ValidateToStringEmpty)28 TEST(UdpPacketTest, ValidateToStringEmpty) {
29 UdpPacket packet{};
30 std::string result = packet.ToString();
31 EXPECT_EQ(result, "[]");
32 }
33
34 } // namespace openscreen
35