1
// Copyright (C) 2016 Canonical Ltd.
3
// This library is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU Lesser General Public License as published
5
// by the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
13
// You should have received a copy of the GNU Lesser General Public License
14
// along with this program. If not, see <http://www.gnu.org/licenses/>.
15
#include <ichnaea/response.h>
17
#include <gtest/gtest.h>
19
TEST(Response, yields_error_instance_if_initialized_with_error)
21
ichnaea::Error e{core::net::http::Status::ok, ""};
22
ichnaea::Response<double> r{e};
23
EXPECT_TRUE(r.is_error());
24
EXPECT_NO_THROW(r.error());
25
EXPECT_ANY_THROW(r.result());
28
TEST(Response, yields_result_instance_if_initialized_with_result)
30
ichnaea::Response<unsigned int> r{42};
31
EXPECT_FALSE(r.is_error());
32
EXPECT_EQ(42, r.result());
33
EXPECT_ANY_THROW(r.error());