-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_Error.cc
More file actions
58 lines (47 loc) · 1.67 KB
/
test_Error.cc
File metadata and controls
58 lines (47 loc) · 1.67 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* \file test_Error.cc
* \authors Fini Jastrow, Lars Fröhlich
* \date Created on January 23, 2024
* \brief Test suite for the git::Error exception class.
*
* \copyright Copyright 2024-2025 Deutsches Elektronen-Synchrotron (DESY), Hamburg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 2.1 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <string>
#include <catch2/catch_test_macros.hpp>
#include "libgit4cpp/Error.h"
using namespace std::literals;
TEST_CASE("Error: Constructor", "[Error]")
{
// Default error code is -7 == GIT_EUSER
git::Error e("Test");
REQUIRE(e.what() == "Test: GIT_EUSER"s);
REQUIRE(e.code().value() == git::git_error_code::GIT_EUSER);
REQUIRE(e.code().value() == -7);
}
TEST_CASE("Error: Copy constructor", "[Error]")
{
const git::Error e("Test");
git::Error e2(e);
REQUIRE(e.what() == std::string(e2.what()));
}
TEST_CASE("Error: Copy assignment", "[Error]")
{
const git::Error e(1, "Test");
git::Error e2(2, "Test2");
e2 = e;
REQUIRE(e2.what() == "Test: unknown GIT error"s);
}