blob: 76343c65427e2d1e571380c8ca82840972a9e903 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/* Self tests for optional for GDB, the GNU debugger.
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of GDB.
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 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "selftest.h"
#include "common/gdb_optional.h"
/* Used by the included .cc files below. Included here because the
included test files are wrapped in a namespace. */
#include <vector>
#include <string>
#include <memory>
/* libstdc++'s testsuite uses VERIFY. */
#define VERIFY SELF_CHECK
/* Used to disable testing features not supported by
gdb::optional. */
#define GDB_OPTIONAL
namespace selftests {
namespace optional {
/* The actual tests live in separate files, which were originally
copied over from libstdc++'s testsuite. To preserve the structure
and help with comparison with the original tests, the file names
have been preserved, and only minimal modification was done to have
them compile against gdb::optional instead of std::optional:
- std::optional->gdb:optional, etc.
- ATTRIBUTE_UNUSED in a few places
- wrap each file in a namespace so they can all be compiled as a
single unit.
- libstdc++'s license and formatting style was preserved.
*/
#include "optional/assignment/1.cc"
#include "optional/assignment/2.cc"
#include "optional/assignment/3.cc"
#include "optional/assignment/4.cc"
#include "optional/assignment/5.cc"
#include "optional/assignment/6.cc"
#include "optional/assignment/7.cc"
#include "optional/cons/copy.cc"
#include "optional/cons/default.cc"
#include "optional/cons/move.cc"
#include "optional/cons/value.cc"
#include "optional/in_place.cc"
#include "optional/observers/1.cc"
#include "optional/observers/2.cc"
static void
run_tests ()
{
assign_1::test ();
assign_2::test ();
assign_3::test ();
assign_4::test ();
assign_5::test ();
assign_6::test ();
assign_7::test ();
cons_copy::test ();
cons_default::test ();
cons_move::test ();
cons_value::test ();
in_place::test ();
observers_1::test ();
observers_2::test ();
}
} /* namespace optional */
} /* namespace selftests */
void
_initialize_optional_selftests ()
{
register_self_test (selftests::optional::run_tests);
}
|