• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/supported_extensions_parameter.h"
11 
12 #include <cstdint>
13 #include <type_traits>
14 #include <vector>
15 
16 #include "api/array_view.h"
17 #include "net/dcsctp/testing/testing_macros.h"
18 #include "rtc_base/gunit.h"
19 #include "test/gmock.h"
20 
21 namespace dcsctp {
22 namespace {
23 using ::testing::ElementsAre;
24 
TEST(SupportedExtensionsParameterTest,SerializeAndDeserialize)25 TEST(SupportedExtensionsParameterTest, SerializeAndDeserialize) {
26   SupportedExtensionsParameter parameter({1, 2, 3});
27 
28   std::vector<uint8_t> serialized;
29   parameter.SerializeTo(serialized);
30 
31   ASSERT_HAS_VALUE_AND_ASSIGN(SupportedExtensionsParameter deserialized,
32                               SupportedExtensionsParameter::Parse(serialized));
33 
34   EXPECT_THAT(deserialized.chunk_types(), ElementsAre(1, 2, 3));
35   EXPECT_TRUE(deserialized.supports(1));
36   EXPECT_TRUE(deserialized.supports(2));
37   EXPECT_TRUE(deserialized.supports(3));
38   EXPECT_FALSE(deserialized.supports(4));
39 }
40 
41 }  // namespace
42 }  // namespace dcsctp
43