1 /*
2  *  Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h"
11 
12 #include <cstdint>
13 #include <type_traits>
14 #include <vector>
15 
16 #include "api/array_view.h"
17 #include "net/dcsctp/common/internal_types.h"
18 #include "net/dcsctp/public/types.h"
19 #include "net/dcsctp/testing/testing_macros.h"
20 #include "rtc_base/gunit.h"
21 #include "test/gmock.h"
22 
23 namespace dcsctp {
24 namespace {
25 using ::testing::ElementsAre;
26 
TEST(OutgoingSSNResetRequestParameterTest,SerializeAndDeserialize)27 TEST(OutgoingSSNResetRequestParameterTest, SerializeAndDeserialize) {
28   OutgoingSSNResetRequestParameter parameter(
29       ReconfigRequestSN(1), ReconfigRequestSN(2), TSN(3),
30       {StreamID(4), StreamID(5), StreamID(6)});
31 
32   std::vector<uint8_t> serialized;
33   parameter.SerializeTo(serialized);
34 
35   ASSERT_HAS_VALUE_AND_ASSIGN(
36       OutgoingSSNResetRequestParameter deserialized,
37       OutgoingSSNResetRequestParameter::Parse(serialized));
38 
39   EXPECT_EQ(*deserialized.request_sequence_number(), 1u);
40   EXPECT_EQ(*deserialized.response_sequence_number(), 2u);
41   EXPECT_EQ(*deserialized.sender_last_assigned_tsn(), 3u);
42   EXPECT_THAT(deserialized.stream_ids(),
43               ElementsAre(StreamID(4), StreamID(5), StreamID(6)));
44 }
45 
46 }  // namespace
47 }  // namespace dcsctp
48