File: mu-error.cc

package info (click to toggle)
maildir-utils 1.12.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,996 kB
  • sloc: cpp: 56,429; lisp: 11,218; sh: 895; ansic: 889; makefile: 126; pascal: 12; python: 4
file content (64 lines) | stat: -rw-r--r-- 1,489 bytes parent folder | download | duplicates (2)
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
59
60
61
62
63
64
/*
** Copyright (C) 2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the
** Free Software Foundation; either version 3, 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation,
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/


#if BUILD_TESTS

#include "mu-error.hh"
#include "mu-test-utils.hh"

using namespace Mu;

static void
test_fill_error()
{
	const Error err{Error::Code::Internal, "boo!"};
	GError *gerr{};

	err.fill_g_error(&gerr);

	assert_equal(gerr->message, "boo!");
	g_assert_cmpint(gerr->code, ==, static_cast<int>(err.code()));
	
	g_clear_error(&gerr);
}

static void
test_add_hint()
{
	Error err(Error::Code::Internal, "baa!");
	err.add_hint("hello");

	assert_equal(err.hint(), "hello");
}


int
main(int argc, char* argv[])
{
	mu_test_init(&argc, &argv);

	g_test_add_func("/error/fill-error", test_fill_error);
	g_test_add_func("/error/add-hint", test_add_hint);

	return g_test_run();

}

#endif /*BUILD_TESTS*/