]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/unittests/optional-selftests.c
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / unittests / optional-selftests.c
CommitLineData
d35d1958
PA
1/* Self tests for optional for GDB, the GNU debugger.
2
e2882c85 3 Copyright (C) 2017-2018 Free Software Foundation, Inc.
d35d1958
PA
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "selftest.h"
22#include "common/gdb_optional.h"
23
24/* Used by the included .cc files below. Included here because the
25 included test files are wrapped in a namespace. */
26#include <vector>
27#include <string>
28#include <memory>
29
30/* libstdc++'s testsuite uses VERIFY. */
31#define VERIFY SELF_CHECK
32
33/* Used to disable testing features not supported by
34 gdb::optional. */
35#define GDB_OPTIONAL
36
37namespace selftests {
38namespace optional {
39
40/* The actual tests live in separate files, which were originally
41 copied over from libstdc++'s testsuite. To preserve the structure
42 and help with comparison with the original tests, the file names
43 have been preserved, and only minimal modification was done to have
44 them compile against gdb::optional instead of std::optional:
45
46 - std::optional->gdb:optional, etc.
47 - ATTRIBUTE_UNUSED in a few places
48 - wrap each file in a namespace so they can all be compiled as a
49 single unit.
50 - libstdc++'s license and formatting style was preserved.
51*/
52
53#include "optional/assignment/1.cc"
54#include "optional/assignment/2.cc"
55#include "optional/assignment/3.cc"
56#include "optional/assignment/4.cc"
57#include "optional/assignment/5.cc"
58#include "optional/assignment/6.cc"
59#include "optional/assignment/7.cc"
60#include "optional/cons/copy.cc"
61#include "optional/cons/default.cc"
62#include "optional/cons/move.cc"
63#include "optional/cons/value.cc"
64#include "optional/in_place.cc"
65#include "optional/observers/1.cc"
66#include "optional/observers/2.cc"
67
68static void
69run_tests ()
70{
71 assign_1::test ();
72 assign_2::test ();
73 assign_3::test ();
74 assign_4::test ();
75 assign_5::test ();
76 assign_6::test ();
77 assign_7::test ();
78 cons_copy::test ();
79 cons_default::test ();
80 cons_move::test ();
81 cons_value::test ();
82 in_place::test ();
83 observers_1::test ();
84 observers_2::test ();
85}
86
87} /* namespace optional */
88} /* namespace selftests */
89
90void
91_initialize_optional_selftests ()
92{
1526853e 93 selftests::register_test ("optional", selftests::optional::run_tests);
d35d1958 94}