summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/core/quic_types_test.cc
blob: 8b4df895224551c5a6df7738c393f7d7ca451617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/third_party/quiche/src/quic/core/quic_types.h"

#include <cstdint>

#include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"

namespace quic {
namespace test {
namespace {

class QuicUtilsTest : public QuicTest {};

TEST_F(QuicUtilsTest, QuicIetfTransportErrorCodeString) {
  // QuicIetfTransportErrorCode out of bound.
  for (quic::QuicErrorCode error = quic::QUIC_ENCRYPTION_FAILURE;
       error < quic::QUIC_LAST_ERROR;
       error = static_cast<quic::QuicErrorCode>(error + 1)) {
    QuicErrorCodeToIetfMapping mapping =
        QuicErrorCodeToTransportErrorCode(error);
    if (mapping.is_transport_close_) {
      EXPECT_EQ(
          QuicIetfTransportErrorCodeString(mapping.transport_error_code_),
          QuicStrCat("Unknown Transport Error Code Value: ",
                     static_cast<uint16_t>(mapping.transport_error_code_)));
    } else {
      // Some QuicErrorCodes are no longer valid.
      EXPECT_EQ(QuicIetfTransportErrorCodeString(mapping.transport_error_code_),
                "NO_IETF_QUIC_ERROR");
    }
  }
}

}  // namespace
}  // namespace test
}  // namespace quic