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/state_cookie_parameter.h" 11 12 #include <stdint.h> 13 14 #include <type_traits> 15 #include <vector> 16 17 #include "api/array_view.h" 18 #include "net/dcsctp/testing/testing_macros.h" 19 #include "rtc_base/gunit.h" 20 #include "test/gmock.h" 21 22 namespace dcsctp { 23 namespace { 24 using ::testing::ElementsAre; 25 TEST(StateCookieParameterTest,SerializeAndDeserialize)26TEST(StateCookieParameterTest, SerializeAndDeserialize) { 27 uint8_t cookie[] = {1, 2, 3}; 28 StateCookieParameter parameter(cookie); 29 30 std::vector<uint8_t> serialized; 31 parameter.SerializeTo(serialized); 32 33 ASSERT_HAS_VALUE_AND_ASSIGN(StateCookieParameter deserialized, 34 StateCookieParameter::Parse(serialized)); 35 36 EXPECT_THAT(deserialized.data(), ElementsAre(1, 2, 3)); 37 } 38 39 } // namespace 40 } // namespace dcsctp 41