| 1 |
//===-- DAPErrorTest.cpp---------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "DAPError.h" |
| 10 |
#include "gmock/gmock.h" |
| 11 |
#include "gtest/gtest.h" |
| 12 |
#include <string> |
| 13 |
#include <system_error> |
| 14 |
|
| 15 |
using namespace lldb_dap; |
| 16 |
using namespace llvm; |
| 17 |
|
| 18 |
TEST(DAPErrorTest, DefaultConstructor) { |
| 19 |
DAPError error("Invalid thread"); |
| 20 |
|
| 21 |
EXPECT_EQ(error.getMessage(), "Invalid thread"); |
| 22 |
EXPECT_EQ(error.convertToErrorCode(), llvm::inconvertibleErrorCode()); |
| 23 |
EXPECT_TRUE(error.getShowUser()); |
| 24 |
EXPECT_EQ(error.getURL(), std::nullopt); |
| 25 |
EXPECT_EQ(error.getURLLabel(), std::nullopt); |
| 26 |
} |
| 27 |
|
| 28 |
TEST(DAPErrorTest, FullConstructor) { |
| 29 |
auto timed_out = std::make_error_code(std::errc::timed_out); |
| 30 |
DAPError error("Timed out", timed_out, false, "URL", "URLLabel"); |
| 31 |
|
| 32 |
EXPECT_EQ(error.getMessage(), "Timed out"); |
| 33 |
EXPECT_EQ(error.convertToErrorCode(), timed_out); |
| 34 |
EXPECT_FALSE(error.getShowUser()); |
| 35 |
EXPECT_THAT(error.getURL(), testing::Optional<std::string>("URL")); |
| 36 |
EXPECT_THAT(error.getURLLabel(), testing::Optional<std::string>("URLLabel")); |
| 37 |
} |