1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00
transmission/tests/libtransmission/error-test.cc
Mike Gelfand 57e6b06921
Modernize CMake code (ongoing refactoring) (#4515)
* Use imported CMake target for CURL

* Use imported CMake target for fmtlib

* Use imported CMake target for WideInteger

* Use imported CMake target for FastFloat

* Use imported CMake target for UtfCpp

* Use imported CMake target for Threads

* Use imported CMake target for Iconv

* Use imported CMake target for crypto backend

* Use imported CMake target for GTK

* Use imported CMake target for Qt

* Use imported CMake target for deflate

* Use imported CMake target for libevent

* Use imported CMake target for natpmp

* Use imported CMake target for miniupnpc

* Use imported CMake target for dht

* Use imported CMake target for psl

* Use imported CMake target for libutp

* Use imported CMake target for libb64

* Use include directories from libtransmission target
2023-01-02 16:23:51 +00:00

53 lines
1.3 KiB
C++

// This file Copyright (C) 2013-2022 Mnemosyne LLC.
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#include <libtransmission/transmission.h>
#include <libtransmission/error.h>
#include "test-fixtures.h"
#include "gtest/gtest.h"
using namespace std::literals;
TEST(Error, errorSet)
{
tr_error* err = nullptr;
tr_error_prefix(&err, "error: ");
EXPECT_EQ(nullptr, err) << *err;
tr_error_set(&err, 2, "oops"sv);
EXPECT_NE(nullptr, err);
EXPECT_EQ(2, err->code);
EXPECT_STREQ("oops", err->message);
tr_error_prefix(&err, "error: ");
EXPECT_NE(nullptr, err);
EXPECT_EQ(2, err->code);
EXPECT_STREQ("error: oops", err->message);
tr_error_free(err);
}
TEST(Error, propagate)
{
tr_error* err = nullptr;
tr_error* err2 = nullptr;
auto constexpr Code = int{ 1 };
tr_error_set(&err, Code, "oops"sv);
EXPECT_NE(nullptr, err);
EXPECT_EQ(Code, err->code);
EXPECT_STREQ("oops", err->message);
tr_error_propagate(&err2, &err);
EXPECT_NE(nullptr, err2);
EXPECT_EQ(Code, err2->code);
EXPECT_STREQ("oops", err2->message);
EXPECT_EQ(nullptr, err) << *err;
tr_error_clear(&err2);
}