aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/unittests')
-rw-r--r--gdb/unittests/array-view-selftests.c176
-rw-r--r--gdb/unittests/child-path-selftests.c15
-rw-r--r--gdb/unittests/cli-utils-selftests.c14
-rw-r--r--gdb/unittests/command-def-selftests.c64
-rw-r--r--gdb/unittests/common-utils-selftests.c17
-rw-r--r--gdb/unittests/copy_bitwise-selftests.c32
-rw-r--r--gdb/unittests/enum-flags-selftests.c204
-rw-r--r--gdb/unittests/environ-selftests.c11
-rw-r--r--gdb/unittests/filtered_iterator-selftests.c34
-rw-r--r--gdb/unittests/format_pieces-selftests.c99
-rw-r--r--gdb/unittests/frame_info_ptr-selftests.c8
-rw-r--r--gdb/unittests/function-view-selftests.c49
-rw-r--r--gdb/unittests/gdb_tilde_expand-selftests.c21
-rw-r--r--gdb/unittests/gmp-utils-selftests.c55
-rw-r--r--gdb/unittests/intrusive_list-selftests.c152
-rw-r--r--gdb/unittests/lookup_name_info-selftests.c42
-rw-r--r--gdb/unittests/main-thread-selftests.c24
-rw-r--r--gdb/unittests/memory-map-selftests.c13
-rw-r--r--gdb/unittests/memrange-selftests.c13
-rw-r--r--gdb/unittests/mkdir-recursive-selftests.c22
-rw-r--r--gdb/unittests/observable-selftests.c91
-rw-r--r--gdb/unittests/offset-type-selftests.c65
-rw-r--r--gdb/unittests/optional-selftests.c7
-rw-r--r--gdb/unittests/packed-selftests.c9
-rw-r--r--gdb/unittests/parallel-for-selftests.c96
-rw-r--r--gdb/unittests/parse-connection-spec-selftests.c195
-rw-r--r--gdb/unittests/path-join-selftests.c16
-rw-r--r--gdb/unittests/ptid-selftests.c10
-rw-r--r--gdb/unittests/rsp-low-selftests.c16
-rw-r--r--gdb/unittests/scoped_fd-selftests.c12
-rw-r--r--gdb/unittests/scoped_ignore_signal-selftests.c28
-rw-r--r--gdb/unittests/scoped_mmap-selftests.c23
-rw-r--r--gdb/unittests/scoped_restore-selftests.c16
-rw-r--r--gdb/unittests/search-memory-selftests.c44
-rw-r--r--gdb/unittests/string_view-selftests.c7
-rw-r--r--gdb/unittests/style-selftests.c10
-rw-r--r--gdb/unittests/tracepoint-selftests.c13
-rw-r--r--gdb/unittests/tui-selftests.c7
-rw-r--r--gdb/unittests/ui-file-selftests.c22
-rw-r--r--gdb/unittests/unique_xmalloc_ptr_char.c11
-rw-r--r--gdb/unittests/unpack-selftests.c19
-rw-r--r--gdb/unittests/utils-selftests.c24
-rw-r--r--gdb/unittests/vec-utils-selftests.c23
-rw-r--r--gdb/unittests/xml-utils-selftests.c20
44 files changed, 955 insertions, 894 deletions
diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c
index b47cf7f..82e8c3a 100644
--- a/gdb/unittests/array-view-selftests.c
+++ b/gdb/unittests/array-view-selftests.c
@@ -23,11 +23,13 @@
#include <array>
#include <vector>
-namespace selftests {
-namespace array_view_tests {
+namespace selftests
+{
+namespace array_view_tests
+{
/* Triviality checks. */
-#define CHECK_TRAIT(TRAIT) \
+#define CHECK_TRAIT(TRAIT) \
static_assert (std::TRAIT<gdb::array_view<gdb_byte>>::value, "")
#if HAVE_IS_TRIVIALLY_COPYABLE
@@ -61,31 +63,42 @@ check_convertible ()
return (true
/* immutable array_view */
- && is_convertible<const T (&) [1], array_view<const T>> ()
- && is_convertible<T (&) [1], array_view<const T>> ()
- && is_convertible<const T, array_view<const T>> ()
- && is_convertible<T, array_view<const T>> ()
+ && is_convertible<const T (&)[1], array_view<const T>> ()
+ && is_convertible<T (&)[1], array_view<const T>> ()
+ && is_convertible<const T, array_view<const T>> ()
+ && is_convertible<T, array_view<const T>> ()
/* mutable array_view */
- && is_convertible<T (&) [1], array_view<T>> ()
- && !is_convertible<const T (&) [1], array_view<T>> ()
- && is_convertible<T, array_view<T>> ()
- && !is_convertible<const T, array_view<T>> ()
+ && is_convertible<T (&)[1], array_view<T>> ()
+ && !is_convertible<const T (&)[1], array_view<T>> ()
+ && is_convertible<T, array_view<T>> ()
+ && !is_convertible<const T, array_view<T>> ()
/* While float is implicitly convertible to gdb_byte, we
don't want implicit float->array_view<gdb_byte>
conversion. */
- && !is_convertible<float, array_view<const T>> ()
- && !is_convertible<float, array_view<T>> ());
+ && !is_convertible<float, array_view<const T>> ()
+ && !is_convertible<float, array_view<T>> ());
}
static_assert (check_convertible (), "");
namespace no_slicing
{
-struct A { int i; };
-struct B : A { int j; };
-struct C : A { int l; };
+struct A
+{
+ int i;
+};
+
+struct B : A
+{
+ int j;
+};
+
+struct C : A
+{
+ int l;
+};
/* Check that there's no array->view conversion for arrays of derived types or
subclasses. */
@@ -98,48 +111,49 @@ check ()
/* array->view */
- && is_convertible <A (&)[1], array_view<A>> ()
- && !is_convertible <B (&)[1], array_view<A>> ()
- && !is_convertible <C (&)[1], array_view<A>> ()
+ && is_convertible<A (&)[1], array_view<A>> ()
+ && !is_convertible<B (&)[1], array_view<A>> ()
+ && !is_convertible<C (&)[1], array_view<A>> ()
- && !is_convertible <A (&)[1], array_view<B>> ()
- && is_convertible <B (&)[1], array_view<B>> ()
- && !is_convertible <C (&)[1], array_view<B>> ()
+ && !is_convertible<A (&)[1], array_view<B>> ()
+ && is_convertible<B (&)[1], array_view<B>> ()
+ && !is_convertible<C (&)[1], array_view<B>> ()
/* elem->view */
- && is_convertible <A, array_view<A>> ()
- && !is_convertible <B, array_view<A>> ()
- && !is_convertible <C, array_view<A>> ()
+ && is_convertible<A, array_view<A>> ()
+ && !is_convertible<B, array_view<A>> ()
+ && !is_convertible<C, array_view<A>> ()
- && !is_convertible <A, array_view<B>> ()
- && is_convertible <B, array_view<B>> ()
- && !is_convertible <C, array_view<B>> ());
+ && !is_convertible<A, array_view<B>> ()
+ && is_convertible<B, array_view<B>> ()
+ && !is_convertible<C, array_view<B>> ());
}
/* Check that there's no container->view conversion for containers of derived
types or subclasses. */
-template<template<typename ...> class Container>
+template<template<typename...> class Container>
static constexpr bool
check_ctor_from_container ()
{
using gdb::array_view;
- return ( is_convertible <Container<A>, array_view<A>> ()
- && !is_convertible <Container<B>, array_view<A>> ()
- && !is_convertible <Container<C>, array_view<A>> ()
+ return (is_convertible<Container<A>, array_view<A>> ()
+ && !is_convertible<Container<B>, array_view<A>> ()
+ && !is_convertible<Container<C>, array_view<A>> ()
- && !is_convertible <Container<A>, array_view<B>> ()
- && is_convertible <Container<B>, array_view<B>> ()
- && !is_convertible <Container<C>, array_view<B>> ());
+ && !is_convertible<Container<A>, array_view<B>> ()
+ && is_convertible<Container<B>, array_view<B>> ()
+ && !is_convertible<Container<C>, array_view<B>> ());
}
} /* namespace no_slicing */
/* std::array with only one template argument, so we can pass it to
check_ctor_from_container. */
-template<typename T> using StdArray1 = std::array<T, 1>;
+template<typename T>
+using StdArray1 = std::array<T, 1>;
static_assert (no_slicing::check (), "");
static_assert (no_slicing::check_ctor_from_container<std::vector> (), "");
@@ -156,9 +170,8 @@ check_convertible_from_std_vector ()
/* Note there's no such thing as std::vector<const T>. */
- return (true
- && is_convertible <std::vector<T>, array_view<T>> ()
- && is_convertible <std::vector<T>, array_view<const T>> ());
+ return (true && is_convertible<std::vector<T>, array_view<T>> ()
+ && is_convertible<std::vector<T>, array_view<const T>> ());
}
static_assert (check_convertible_from_std_vector (), "");
@@ -173,11 +186,10 @@ check_convertible_from_std_array ()
/* Note: a non-const T view can't refer to a const T array. */
- return (true
- && is_convertible <std::array<T, 1>, array_view<T>> ()
- && is_convertible <std::array<T, 1>, array_view<const T>> ()
- && !is_convertible <std::array<const T, 1>, array_view<T>> ()
- && is_convertible <std::array<const T, 1>, array_view<const T>> ());
+ return (true && is_convertible<std::array<T, 1>, array_view<T>> ()
+ && is_convertible<std::array<T, 1>, array_view<const T>> ()
+ && !is_convertible<std::array<const T, 1>, array_view<T>> ()
+ && is_convertible<std::array<const T, 1>, array_view<const T>> ());
}
static_assert (check_convertible_from_std_array (), "");
@@ -253,7 +265,7 @@ template<typename T>
static void
check_ptr_size_ctor ()
{
- T data[] = {0x11, 0x22, 0x33, 0x44};
+ T data[] = { 0x11, 0x22, 0x33, 0x44 };
gdb::array_view<T> view (data + 1, 2);
@@ -288,18 +300,22 @@ require_not_constructible ()
static void
check_ptr_size_ctor2 ()
{
- struct A {};
+ struct A
+ {
+ };
+
A an_a;
A *array[] = { &an_a };
- const A * const carray[] = { &an_a };
+ const A *const carray[] = { &an_a };
- gdb::array_view<A *> v1 = {array, ARRAY_SIZE (array)};
- gdb::array_view<A *> v2 = {array, (char) ARRAY_SIZE (array)};
- gdb::array_view<A * const> v3 = {array, ARRAY_SIZE (array)};
- gdb::array_view<const A * const> cv1 = {carray, ARRAY_SIZE (carray)};
+ gdb::array_view<A *> v1 = { array, ARRAY_SIZE (array) };
+ gdb::array_view<A *> v2 = { array, (char) ARRAY_SIZE (array) };
+ gdb::array_view<A *const> v3 = { array, ARRAY_SIZE (array) };
+ gdb::array_view<const A *const> cv1 = { carray, ARRAY_SIZE (carray) };
- require_not_constructible<gdb::array_view<A *>, decltype (carray), size_t> ();
+ require_not_constructible<gdb::array_view<A *>, decltype (carray),
+ size_t> ();
SELF_CHECK (v1[0] == array[0]);
SELF_CHECK (v2[0] == array[0]);
@@ -323,7 +339,7 @@ template<typename T>
static void
check_ptr_ptr_ctor ()
{
- T data[] = {0x11, 0x22, 0x33, 0x44};
+ T data[] = { 0x11, 0x22, 0x33, 0x44 };
gdb::array_view<T> view (data + 1, data + 3);
@@ -333,7 +349,7 @@ check_ptr_ptr_ctor ()
SELF_CHECK (view[0] == data[1]);
SELF_CHECK (view[1] == data[2]);
- gdb_byte array[] = {0x11, 0x22, 0x33, 0x44};
+ gdb_byte array[] = { 0x11, 0x22, 0x33, 0x44 };
const gdb_byte *p1 = array;
gdb_byte *p2 = array + ARRAY_SIZE (array);
gdb::array_view<const gdb_byte> view2 (p1, p2);
@@ -344,7 +360,7 @@ check_ptr_ptr_ctor ()
static void
check_ptr_ptr_mixed_cv ()
{
- gdb_byte array[] = {0x11, 0x22, 0x33, 0x44};
+ gdb_byte array[] = { 0x11, 0x22, 0x33, 0x44 };
const gdb_byte *cp = array;
gdb_byte *p = array;
gdb::array_view<const gdb_byte> view1 (cp, p);
@@ -360,7 +376,7 @@ template<typename T>
static void
check_range_for ()
{
- T data[] = {1, 2, 3, 4};
+ T data[] = { 1, 2, 3, 4 };
gdb::array_view<T> view (data);
typename std::decay<T>::type sum = 0;
@@ -387,8 +403,8 @@ run_tests ()
static_assert (view2.data () == nullptr, "");
}
- std::vector<gdb_byte> vec = {0x11, 0x22, 0x33, 0x44 };
- std::array<gdb_byte, 4> array = {{0x11, 0x22, 0x33, 0x44}};
+ std::vector<gdb_byte> vec = { 0x11, 0x22, 0x33, 0x44 };
+ std::array<gdb_byte, 4> array = { { 0x11, 0x22, 0x33, 0x44 } };
/* Various tests of views over std::vector. */
{
@@ -429,7 +445,7 @@ run_tests ()
/* Test copy/move ctor and mutable->immutable conversion. */
{
- gdb_byte data[] = {0x11, 0x22, 0x33, 0x44};
+ gdb_byte data[] = { 0x11, 0x22, 0x33, 0x44 };
gdb::array_view<gdb_byte> view1 = data;
gdb::array_view<gdb_byte> view2 = view1;
gdb::array_view<gdb_byte> view3 = std::move (view1);
@@ -446,7 +462,7 @@ run_tests ()
/* Same, but op=(view). */
{
- gdb_byte data[] = {0x55, 0x66, 0x77, 0x88};
+ gdb_byte data[] = { 0x55, 0x66, 0x77, 0x88 };
gdb::array_view<gdb_byte> view1;
gdb::array_view<gdb_byte> view2;
gdb::array_view<gdb_byte> view3;
@@ -470,7 +486,7 @@ run_tests ()
/* op[] */
{
- std::vector<gdb_byte> vec2 = {0x11, 0x22};
+ std::vector<gdb_byte> vec2 = { 0x11, 0x22 };
gdb::array_view<gdb_byte> view = vec2;
gdb::array_view<const gdb_byte> cview = vec2;
@@ -512,7 +528,7 @@ run_tests ()
/* gdb::make_array_view, int length. */
{
- gdb_byte data[] = {0x55, 0x66, 0x77, 0x88};
+ gdb_byte data[] = { 0x55, 0x66, 0x77, 0x88 };
int len = sizeof (data) / sizeof (data[0]);
auto view = gdb::make_array_view (data, len);
@@ -525,7 +541,7 @@ run_tests ()
/* Test slicing. */
{
- gdb_byte data[] = {0x55, 0x66, 0x77, 0x88, 0x99};
+ gdb_byte data[] = { 0x55, 0x66, 0x77, 0x88, 0x99 };
gdb::array_view<gdb_byte> view = data;
{
@@ -546,13 +562,13 @@ run_tests ()
}
}
-template <typename T>
+template<typename T>
void
run_copy_test ()
{
/* Test non-overlapping copy. */
{
- const std::vector<T> src_v = {1, 2, 3, 4};
+ const std::vector<T> src_v = { 1, 2, 3, 4 };
std::vector<T> dest_v (4, -1);
SELF_CHECK (dest_v != src_v);
@@ -562,37 +578,34 @@ run_copy_test ()
/* Test overlapping copy, where the source is before the destination. */
{
- std::vector<T> vec = {1, 2, 3, 4, 5, 6, 7, 8};
+ std::vector<T> vec = { 1, 2, 3, 4, 5, 6, 7, 8 };
gdb::array_view<T> v = vec;
- copy (v.slice (1, 4),
- v.slice (2, 4));
+ copy (v.slice (1, 4), v.slice (2, 4));
- std::vector<T> expected = {1, 2, 2, 3, 4, 5, 7, 8};
+ std::vector<T> expected = { 1, 2, 2, 3, 4, 5, 7, 8 };
SELF_CHECK (vec == expected);
}
/* Test overlapping copy, where the source is after the destination. */
{
- std::vector<T> vec = {1, 2, 3, 4, 5, 6, 7, 8};
+ std::vector<T> vec = { 1, 2, 3, 4, 5, 6, 7, 8 };
gdb::array_view<T> v = vec;
- copy (v.slice (2, 4),
- v.slice (1, 4));
+ copy (v.slice (2, 4), v.slice (1, 4));
- std::vector<T> expected = {1, 3, 4, 5, 6, 6, 7, 8};
+ std::vector<T> expected = { 1, 3, 4, 5, 6, 6, 7, 8 };
SELF_CHECK (vec == expected);
}
/* Test overlapping copy, where the source is the same as the destination. */
{
- std::vector<T> vec = {1, 2, 3, 4, 5, 6, 7, 8};
+ std::vector<T> vec = { 1, 2, 3, 4, 5, 6, 7, 8 };
gdb::array_view<T> v = vec;
- copy (v.slice (2, 4),
- v.slice (2, 4));
+ copy (v.slice (2, 4), v.slice (2, 4));
- std::vector<T> expected = {1, 2, 3, 4, 5, 6, 7, 8};
+ std::vector<T> expected = { 1, 2, 3, 4, 5, 6, 7, 8 };
SELF_CHECK (vec == expected);
}
}
@@ -606,7 +619,8 @@ struct foo
array_view<foo>. */
foo (int n)
: n (n)
- {}
+ {
+ }
/* Needed to avoid -Wdeprecated-copy-with-user-provided-copy error with
Clang. */
@@ -618,10 +632,7 @@ struct foo
this->n_assign_op_called++;
}
- bool operator==(const foo &other) const
- {
- return this->n == other.n;
- }
+ bool operator== (const foo &other) const { return this->n == other.n; }
int n;
@@ -652,6 +663,7 @@ run_copy_tests ()
} /* namespace selftests */
void _initialize_array_view_selftests ();
+
void
_initialize_array_view_selftests ()
{
diff --git a/gdb/unittests/child-path-selftests.c b/gdb/unittests/child-path-selftests.c
index 773fc2f..f4ce765 100644
--- a/gdb/unittests/child-path-selftests.c
+++ b/gdb/unittests/child-path-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/pathstuff.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace child_path {
+namespace selftests
+{
+namespace child_path
+{
/* Verify the result of a single child_path test. */
@@ -56,14 +58,13 @@ test ()
SELF_CHECK (child_path_check ("/one", "/onetwo/three", NULL));
}
-}
-}
+} // namespace child_path
+} // namespace selftests
void _initialize_child_path_selftests ();
+
void
_initialize_child_path_selftests ()
{
- selftests::register_test ("child_path",
- selftests::child_path::test);
+ selftests::register_test ("child_path", selftests::child_path::test);
}
-
diff --git a/gdb/unittests/cli-utils-selftests.c b/gdb/unittests/cli-utils-selftests.c
index ecac71a..d9695b2 100644
--- a/gdb/unittests/cli-utils-selftests.c
+++ b/gdb/unittests/cli-utils-selftests.c
@@ -21,8 +21,10 @@
#include "cli/cli-utils.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace cli_utils {
+namespace selftests
+{
+namespace cli_utils
+{
static void
test_number_or_range_parser ()
@@ -107,13 +109,13 @@ test_cli_utils ()
selftests::cli_utils::test_number_or_range_parser ();
}
-}
-}
+} // namespace cli_utils
+} // namespace selftests
void _initialize_cli_utils_selftests ();
+
void
_initialize_cli_utils_selftests ()
{
- selftests::register_test ("cli_utils",
- selftests::cli_utils::test_cli_utils);
+ selftests::register_test ("cli_utils", selftests::cli_utils::test_cli_utils);
}
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 84137c9..7ddb691 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -24,11 +24,13 @@
#include <map>
-namespace selftests {
+namespace selftests
+{
/* Verify some invariants of GDB commands documentation. */
-namespace help_doc_tests {
+namespace help_doc_tests
+{
static unsigned int nr_failed_invariants;
@@ -65,19 +67,18 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
while (*p && *p != '\n')
p++;
if (p == c->doc)
- broken_doc_invariant
- (prefix, c->name,
- "is missing the first line terminated with a '.' character");
- else if (*(p-1) != '.')
- broken_doc_invariant
- (prefix, c->name,
- "first line is not terminated with a '.' character");
+ broken_doc_invariant (
+ prefix, c->name,
+ "is missing the first line terminated with a '.' character");
+ else if (*(p - 1) != '.')
+ broken_doc_invariant (
+ prefix, c->name,
+ "first line is not terminated with a '.' character");
/* Checks the doc is not terminated with a new line. */
if (c->doc[strlen (c->doc) - 1] == '\n')
- broken_doc_invariant
- (prefix, c->name,
- "has a superfluous trailing end of line");
+ broken_doc_invariant (prefix, c->name,
+ "has a superfluous trailing end of line");
/* Check if this command has subcommands and is not an
abbreviation. We skip checking subcommands of abbreviations
@@ -103,7 +104,8 @@ help_doc_invariants_tests ()
/* Verify some invariants of GDB command structure. */
-namespace command_structure_tests {
+namespace command_structure_tests
+{
/* Nr of commands in which a duplicated list is found. */
static unsigned int nr_duplicates = 0;
@@ -121,8 +123,7 @@ static std::map<cmd_list_element **, const char *> lists;
command. */
static void
-traverse_command_structure (struct cmd_list_element **list,
- const char *prefix)
+traverse_command_structure (struct cmd_list_element **list, const char *prefix)
{
struct cmd_list_element *c, *prefixcmd;
@@ -132,14 +133,12 @@ traverse_command_structure (struct cmd_list_element **list,
gdb_printf ("list %p duplicated,"
" reachable via prefix '%s' and '%s'."
" Duplicated list first command is '%s'\n",
- list,
- prefix, dupl->second,
- (*list)->name);
+ list, prefix, dupl->second, (*list)->name);
nr_duplicates++;
return;
}
- lists.insert ({list, prefix});
+ lists.insert ({ list, prefix });
/* All commands of *list must have a prefix command equal to PREFIXCMD,
the prefix command of the first command. */
@@ -157,21 +156,19 @@ traverse_command_structure (struct cmd_list_element **list,
{
/* Recursively call ourselves on the subcommand list,
passing the right prefix in. */
- traverse_command_structure (c->subcommands, c->prefixname ().c_str ());
+ traverse_command_structure (c->subcommands,
+ c->prefixname ().c_str ());
}
- if (prefixcmd != c->prefix
- || (prefixcmd == nullptr && *list != cmdlist))
+ if (prefixcmd != c->prefix || (prefixcmd == nullptr && *list != cmdlist))
{
if (c->prefix == nullptr)
gdb_printf ("list %p reachable via prefix '%s'."
" command '%s' has null prefixcmd\n",
- list,
- prefix, c->name);
+ list, prefix, c->name);
else
gdb_printf ("list %p reachable via prefix '%s'."
" command '%s' has a different prefixcmd\n",
- list,
- prefix, c->name);
+ list, prefix, c->name);
nr_invalid_prefixcmd++;
}
}
@@ -194,19 +191,20 @@ command_structure_invariants_tests ()
SELF_CHECK (nr_invalid_prefixcmd == 0);
}
-}
+} // namespace command_structure_tests
} /* namespace selftests */
void _initialize_command_def_selftests ();
+
void
_initialize_command_def_selftests ()
{
- selftests::register_test
- ("help_doc_invariants",
- selftests::help_doc_tests::help_doc_invariants_tests);
+ selftests::register_test (
+ "help_doc_invariants",
+ selftests::help_doc_tests::help_doc_invariants_tests);
- selftests::register_test
- ("command_structure_invariants",
- selftests::command_structure_tests::command_structure_invariants_tests);
+ selftests::register_test (
+ "command_structure_invariants",
+ selftests::command_structure_tests::command_structure_invariants_tests);
}
diff --git a/gdb/unittests/common-utils-selftests.c b/gdb/unittests/common-utils-selftests.c
index 4d66faf..dbef2b8 100644
--- a/gdb/unittests/common-utils-selftests.c
+++ b/gdb/unittests/common-utils-selftests.c
@@ -20,7 +20,8 @@
#include "gdbsupport/common-defs.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
+namespace selftests
+{
/* Type of both 'string_printf' and the 'format' function below. Used
to run the same tests against both string_printf and
@@ -46,7 +47,8 @@ test_format_func (format_func *func)
#define X100 X10 X10 X10 X10 X10 X10 X10 X10 X10 X10
#define X1000 X100 X100 X100 X100 X100 X100 X100 X100 X100 X100
#define X10000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000
-#define X100000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000
+#define X100000 \
+ X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000
SELF_CHECK (func ("%s", X10) == X10);
SELF_CHECK (func ("%s", X100) == X100);
SELF_CHECK (func ("%s", X1000) == X1000);
@@ -60,8 +62,7 @@ string_printf_tests ()
test_format_func (string_printf);
}
-static std::string ATTRIBUTE_PRINTF (1, 2)
-format (const char *fmt, ...)
+static std::string ATTRIBUTE_PRINTF (1, 2) format (const char *fmt, ...)
{
va_list vp;
@@ -81,8 +82,7 @@ string_vprintf_tests ()
function below. Used to run the same tests against both
string_appendf and string_vappendf. */
typedef std::string &(string_appendf_func) (std::string &str, const char *fmt,
- ...)
- ATTRIBUTE_PRINTF (2, 3);
+ ...) ATTRIBUTE_PRINTF (2, 3);
static void
test_appendf_func (string_appendf_func *func)
@@ -102,8 +102,8 @@ test_appendf_func (string_appendf_func *func)
SELF_CHECK (str == "test23foo 45 bar");
}
-static std::string & ATTRIBUTE_PRINTF (2, 3)
-string_vappendf_wrapper (std::string &str, const char *fmt, ...)
+static std::string &ATTRIBUTE_PRINTF (2, 3)
+ string_vappendf_wrapper (std::string &str, const char *fmt, ...)
{
va_list vp;
@@ -129,6 +129,7 @@ string_vappendf_tests ()
} /* namespace selftests */
void _initialize_common_utils_selftests ();
+
void
_initialize_common_utils_selftests ()
{
diff --git a/gdb/unittests/copy_bitwise-selftests.c b/gdb/unittests/copy_bitwise-selftests.c
index c4ec768..ca926eb 100644
--- a/gdb/unittests/copy_bitwise-selftests.c
+++ b/gdb/unittests/copy_bitwise-selftests.c
@@ -21,7 +21,8 @@
#include "gdbsupport/selftest.h"
#include "utils.h"
-namespace selftests {
+namespace selftests
+{
/* Helper function for the unit test of copy_bitwise. Convert NBITS bits
out of BITS, starting at OFFS, to the respective '0'/'1'-string. MSB0
@@ -29,8 +30,8 @@ namespace selftests {
resulting (not null-terminated) string at STR. */
static void
-bits_to_str (char *str, const gdb_byte *bits, ULONGEST offs,
- ULONGEST nbits, int msb0)
+bits_to_str (char *str, const gdb_byte *bits, ULONGEST offs, ULONGEST nbits,
+ int msb0)
{
unsigned int j;
size_t i;
@@ -84,8 +85,8 @@ check_copy_bitwise (const gdb_byte *dest, unsigned int dest_offset,
/* Compare the resulting strings. */
expected[len] = actual[len] = '\0';
if (strcmp (expected, actual) != 0)
- error (_("copy_bitwise %s != %s (%u+%u -> %u)"),
- expected, actual, source_offset, nbits, dest_offset);
+ error (_ ("copy_bitwise %s != %s (%u+%u -> %u)"), expected, actual,
+ source_offset, nbits, dest_offset);
}
/* Unit test for copy_bitwise. */
@@ -102,12 +103,8 @@ copy_bitwise_tests (void)
- 0/1- and 1/0 transitions on all bit positions within a byte;
- several sufficiently asymmetric bytes.
*/
- static const gdb_byte data_lsb0[] = {
- 0x00, 0xf8, 0xff, 0x12, 0xa5, 0x4f
- };
- static const gdb_byte data_msb0[] = {
- 0x00, 0x1f, 0xff, 0x48, 0xa5, 0xf2
- };
+ static const gdb_byte data_lsb0[] = { 0x00, 0xf8, 0xff, 0x12, 0xa5, 0x4f };
+ static const gdb_byte data_msb0[] = { 0x00, 0x1f, 0xff, 0x48, 0xa5, 0xf2 };
constexpr size_t data_nbits = 8 * sizeof (data_lsb0);
constexpr unsigned max_nbits = 24;
@@ -126,19 +123,15 @@ copy_bitwise_tests (void)
{
const unsigned int max_offset = data_nbits - nbits;
- for (unsigned source_offset = 0;
- source_offset <= max_offset;
+ for (unsigned source_offset = 0; source_offset <= max_offset;
source_offset++)
{
- for (unsigned dest_offset = 0;
- dest_offset <= max_offset;
+ for (unsigned dest_offset = 0; dest_offset <= max_offset;
dest_offset++)
{
- check_copy_bitwise (data + dest_offset / 8,
- dest_offset % 8,
+ check_copy_bitwise (data + dest_offset / 8, dest_offset % 8,
data + source_offset / 8,
- source_offset % 8,
- nbits, msb0);
+ source_offset % 8, nbits, msb0);
}
}
}
@@ -153,6 +146,7 @@ copy_bitwise_tests (void)
} /* namespace selftests */
void _initialize_copy_bitwise_utils_selftests ();
+
void
_initialize_copy_bitwise_utils_selftests ()
{
diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c
index 2d3c555..087bbd1 100644
--- a/gdb/unittests/enum-flags-selftests.c
+++ b/gdb/unittests/enum-flags-selftests.c
@@ -22,8 +22,10 @@
#include "gdbsupport/valid-expr.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace enum_flags_tests {
+namespace selftests
+{
+namespace enum_flags_tests
+{
/* The (real) enum types used in CHECK_VALID. Their names match the
template parameter names of the templates defined by CHECK_VALID to
@@ -31,32 +33,32 @@ namespace enum_flags_tests {
/* A "real enum". */
enum RE
- {
- RE_FLAG1 = 1 << 1,
- RE_FLAG2 = 1 << 2,
- };
+{
+ RE_FLAG1 = 1 << 1,
+ RE_FLAG2 = 1 << 2,
+};
/* Another "real enum". */
enum RE2
- {
- RE2_FLAG1 = 1 << 1,
- RE2_FLAG2 = 1 << 2,
- };
+{
+ RE2_FLAG1 = 1 << 1,
+ RE2_FLAG2 = 1 << 2,
+};
/* An unsigned "real enum". */
enum URE : unsigned
- {
- URE_FLAG1 = 1 << 1,
- URE_FLAG2 = 1 << 2,
- URE_FLAG3 = 0xffffffff,
- };
+{
+ URE_FLAG1 = 1 << 1,
+ URE_FLAG2 = 1 << 2,
+ URE_FLAG3 = 0xffffffff,
+};
/* A non-flags enum. */
enum NF
- {
- NF_FLAG1 = 1 << 1,
- NF_FLAG2 = 1 << 2,
- };
+{
+ NF_FLAG1 = 1 << 1,
+ NF_FLAG2 = 1 << 2,
+};
/* The corresponding "enum flags" types. */
DEF_ENUM_FLAGS_TYPE (RE, EF);
@@ -87,7 +89,7 @@ static EF ef ATTRIBUTE_UNUSED;
types do compile and that they return the correct type.
*/
-#define CHECK_VALID(VALID, EXPR_TYPE, EXPR) \
+#define CHECK_VALID(VALID, EXPR_TYPE, EXPR) \
CHECK_VALID_EXPR_6 (EF, RE, EF2, RE2, UEF, URE, VALID, EXPR_TYPE, EXPR)
typedef std::underlying_type<RE>::type und;
@@ -95,21 +97,21 @@ typedef std::underlying_type<RE>::type und;
/* Test construction / conversion from/to different types. */
/* RE/EF -> underlying (explicit) */
-CHECK_VALID (true, und, und (RE ()))
-CHECK_VALID (true, und, und (EF ()))
+CHECK_VALID (true, und, und (RE ()))
+CHECK_VALID (true, und, und (EF ()))
/* RE/EF -> int (explicit) */
-CHECK_VALID (true, int, int (RE ()))
-CHECK_VALID (true, int, int (EF ()))
+CHECK_VALID (true, int, int (RE ()))
+CHECK_VALID (true, int, int (EF ()))
/* other -> RE */
/* You can construct a raw enum value from an int explicitly to punch
a hole in the type system if need to. */
-CHECK_VALID (true, RE, RE (1))
-CHECK_VALID (true, RE, RE (RE2 ()))
+CHECK_VALID (true, RE, RE (1))
+CHECK_VALID (true, RE, RE (RE2 ()))
CHECK_VALID (false, void, RE (EF2 ()))
-CHECK_VALID (true, RE, RE (RE ()))
+CHECK_VALID (true, RE, RE (RE ()))
CHECK_VALID (false, void, RE (EF ()))
/* other -> EF. */
@@ -122,8 +124,8 @@ CHECK_VALID (false, void, EF (1))
CHECK_VALID (false, void, EF (1u))
CHECK_VALID (false, void, EF (RE2 ()))
CHECK_VALID (false, void, EF (EF2 ()))
-CHECK_VALID (true, EF, EF (RE ()))
-CHECK_VALID (true, EF, EF (EF ()))
+CHECK_VALID (true, EF, EF (RE ()))
+CHECK_VALID (true, EF, EF (EF ()))
/* Test operators. */
@@ -156,18 +158,18 @@ CHECK_VALID (false, void, 1 ^ EF ())
CHECK_VALID (false, void, RE () | RE2 ())
CHECK_VALID (false, void, RE () & RE2 ())
CHECK_VALID (false, void, RE () ^ RE2 ())
-CHECK_VALID (true, RE, RE () | RE ())
-CHECK_VALID (true, RE, RE () & RE ())
-CHECK_VALID (true, RE, RE () ^ RE ())
+CHECK_VALID (true, RE, RE () | RE ())
+CHECK_VALID (true, RE, RE () & RE ())
+CHECK_VALID (true, RE, RE () ^ RE ())
/* operator OP (enum_flags, raw_enum) */
CHECK_VALID (false, void, EF () | RE2 ())
CHECK_VALID (false, void, EF () & RE2 ())
CHECK_VALID (false, void, EF () ^ RE2 ())
-CHECK_VALID (true, EF, EF () | RE ())
-CHECK_VALID (true, EF, EF () & RE ())
-CHECK_VALID (true, EF, EF () ^ RE ())
+CHECK_VALID (true, EF, EF () | RE ())
+CHECK_VALID (true, EF, EF () & RE ())
+CHECK_VALID (true, EF, EF () ^ RE ())
/* operator OP= (raw_enum, raw_enum), rvalue ref on the lhs. */
@@ -183,9 +185,9 @@ CHECK_VALID (false, void, RE () ^= RE ())
CHECK_VALID (false, void, re |= RE2 ())
CHECK_VALID (false, void, re &= RE2 ())
CHECK_VALID (false, void, re ^= RE2 ())
-CHECK_VALID (true, RE&, re |= RE ())
-CHECK_VALID (true, RE&, re &= RE ())
-CHECK_VALID (true, RE&, re ^= RE ())
+CHECK_VALID (true, RE &, re |= RE ())
+CHECK_VALID (true, RE &, re &= RE ())
+CHECK_VALID (true, RE &, re ^= RE ())
/* operator OP= (enum_flags, raw_enum), rvalue ref on the lhs. */
@@ -201,9 +203,9 @@ CHECK_VALID (false, void, EF () ^= RE ())
CHECK_VALID (false, void, ef |= RE2 ())
CHECK_VALID (false, void, ef &= RE2 ())
CHECK_VALID (false, void, ef ^= RE2 ())
-CHECK_VALID (true, EF&, ef |= EF ())
-CHECK_VALID (true, EF&, ef &= EF ())
-CHECK_VALID (true, EF&, ef ^= EF ())
+CHECK_VALID (true, EF &, ef |= EF ())
+CHECK_VALID (true, EF &, ef &= EF ())
+CHECK_VALID (true, EF &, ef ^= EF ())
/* operator OP= (enum_flags, enum_flags), rvalue ref on the lhs. */
@@ -219,24 +221,24 @@ CHECK_VALID (false, void, EF () ^= EF ())
CHECK_VALID (false, void, ef |= EF2 ())
CHECK_VALID (false, void, ef &= EF2 ())
CHECK_VALID (false, void, ef ^= EF2 ())
-CHECK_VALID (true, EF&, ef |= EF ())
-CHECK_VALID (true, EF&, ef &= EF ())
-CHECK_VALID (true, EF&, ef ^= EF ())
+CHECK_VALID (true, EF &, ef |= EF ())
+CHECK_VALID (true, EF &, ef &= EF ())
+CHECK_VALID (true, EF &, ef ^= EF ())
/* operator~ (raw_enum) */
-CHECK_VALID (false, void, ~RE ())
-CHECK_VALID (true, URE, ~URE ())
+CHECK_VALID (false, void, ~RE ())
+CHECK_VALID (true, URE, ~URE ())
/* operator~ (enum_flags) */
-CHECK_VALID (false, void, ~EF ())
-CHECK_VALID (true, UEF, ~UEF ())
+CHECK_VALID (false, void, ~EF ())
+CHECK_VALID (true, UEF, ~UEF ())
/* Check ternary operator. This exercises implicit conversions. */
-CHECK_VALID (true, EF, true ? EF () : RE ())
-CHECK_VALID (true, EF, true ? RE () : EF ())
+CHECK_VALID (true, EF, true ? EF () : RE ())
+CHECK_VALID (true, EF, true ? RE () : EF ())
/* These are valid, but it's not a big deal since you won't be able to
assign the resulting integer to an enum or an enum_flags without a
@@ -251,22 +253,22 @@ CHECK_VALID (true, EF, true ? RE () : EF ())
They've been confirmed to compile/pass with gcc 5.3, gcc 7.1 and
clang 3.7. */
-CHECK_VALID (true, int, true ? EF () : EF2 ())
-CHECK_VALID (true, int, true ? EF2 () : EF ())
+CHECK_VALID (true, int, true ? EF () : EF2 ())
+CHECK_VALID (true, int, true ? EF2 () : EF ())
#if GCC_VERSION >= 5003 || defined __clang__
-CHECK_VALID (true, int, true ? EF () : RE2 ())
-CHECK_VALID (true, int, true ? RE2 () : EF ())
+CHECK_VALID (true, int, true ? EF () : RE2 ())
+CHECK_VALID (true, int, true ? RE2 () : EF ())
#endif
/* Same, but with an unsigned enum. */
typedef unsigned int uns;
-CHECK_VALID (true, uns, true ? EF () : UEF ())
-CHECK_VALID (true, uns, true ? UEF () : EF ())
+CHECK_VALID (true, uns, true ? EF () : UEF ())
+CHECK_VALID (true, uns, true ? UEF () : EF ())
#if GCC_VERSION >= 5003 || defined __clang__
-CHECK_VALID (true, uns, true ? EF () : URE ())
-CHECK_VALID (true, uns, true ? URE () : EF ())
+CHECK_VALID (true, uns, true ? EF () : URE ())
+CHECK_VALID (true, uns, true ? URE () : EF ())
#endif
/* Unfortunately this can't work due to the way C++ computes the
@@ -307,9 +309,9 @@ CHECK_VALID (false, void, EF () == EF2 ())
CHECK_VALID (false, void, EF () == RE2 ())
CHECK_VALID (false, void, RE () == EF2 ())
-CHECK_VALID (true, bool, EF (RE (1)) == EF (RE (1)))
-CHECK_VALID (true, bool, EF (RE (1)) == RE (1))
-CHECK_VALID (true, bool, RE (1) == EF (RE (1)))
+CHECK_VALID (true, bool, EF (RE (1)) == EF (RE (1)))
+CHECK_VALID (true, bool, EF (RE (1)) == RE (1))
+CHECK_VALID (true, bool, RE (1) == EF (RE (1)))
CHECK_VALID (false, void, EF () != EF2 ())
CHECK_VALID (false, void, EF () != RE2 ())
@@ -331,26 +333,26 @@ CHECK_VALID (false, void, RE () != EF2 ())
Not a big deal since misuses like these in GDB will be caught by
-Werror anyway. This check is here mainly for completeness. */
#if defined __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wenum-compare"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wenum-compare"
#endif
-CHECK_VALID (true, bool, RE () == RE2 ())
-CHECK_VALID (true, bool, RE () != RE2 ())
+CHECK_VALID (true, bool, RE () == RE2 ())
+CHECK_VALID (true, bool, RE () != RE2 ())
#if defined __GNUC__
-# pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
#endif
-CHECK_VALID (true, bool, EF (RE (1)) != EF (RE (2)))
-CHECK_VALID (true, bool, EF (RE (1)) != RE (2))
-CHECK_VALID (true, bool, RE (1) != EF (RE (2)))
+CHECK_VALID (true, bool, EF (RE (1)) != EF (RE (2)))
+CHECK_VALID (true, bool, EF (RE (1)) != RE (2))
+CHECK_VALID (true, bool, RE (1) != EF (RE (2)))
-CHECK_VALID (true, bool, EF () == 0)
+CHECK_VALID (true, bool, EF () == 0)
/* Check we didn't disable/delete comparison between non-flags enums
and unrelated types by mistake. */
-CHECK_VALID (true, bool, NF (1) == NF (1))
-CHECK_VALID (true, bool, NF (1) == int (1))
-CHECK_VALID (true, bool, NF (1) == char (1))
+CHECK_VALID (true, bool, NF (1) == NF (1))
+CHECK_VALID (true, bool, NF (1) == int (1))
+CHECK_VALID (true, bool, NF (1) == char (1))
/* -------------------------------------------------------------------- */
@@ -358,20 +360,20 @@ CHECK_VALID (true, bool, NF (1) == char (1))
when possible, others are run time. */
enum test_flag
- {
- FLAG1 = 1 << 0,
- FLAG2 = 1 << 1,
- FLAG3 = 1 << 2,
- FLAG4 = 1 << 3,
- };
+{
+ FLAG1 = 1 << 0,
+ FLAG2 = 1 << 1,
+ FLAG3 = 1 << 2,
+ FLAG4 = 1 << 3,
+};
enum test_uflag : unsigned
- {
- UFLAG1 = 1 << 0,
- UFLAG2 = 1 << 1,
- UFLAG3 = 1 << 2,
- UFLAG4 = 1 << 3,
- };
+{
+ UFLAG1 = 1 << 0,
+ UFLAG2 = 1 << 1,
+ UFLAG3 = 1 << 2,
+ UFLAG4 = 1 << 3,
+};
DEF_ENUM_FLAGS_TYPE (test_flag, test_flags);
DEF_ENUM_FLAGS_TYPE (test_uflag, test_uflags);
@@ -425,8 +427,8 @@ self_test ()
{
constexpr test_flags zero1 = 0;
constexpr test_flags zero2 (0);
- constexpr test_flags zero3 {0};
- constexpr test_flags zero4 = {0};
+ constexpr test_flags zero3 { 0 };
+ constexpr test_flags zero4 = { 0 };
gdb_static_assert (zero1 == 0);
gdb_static_assert (zero2 == 0);
@@ -446,8 +448,8 @@ self_test ()
constexpr test_flags f1 = src;
constexpr test_flags f2 (src);
- constexpr test_flags f3 {src};
- constexpr test_flags f4 = {src};
+ constexpr test_flags f3 { src };
+ constexpr test_flags f4 = { src };
gdb_static_assert (f1 == FLAG1);
gdb_static_assert (f2 == FLAG1);
@@ -610,31 +612,23 @@ self_test ()
/* Check string conversion. */
{
- SELF_CHECK (to_string_uflags (0)
- == "0x0 []");
- SELF_CHECK (to_string_uflags (UFLAG1)
- == "0x1 [UFLAG1]");
- SELF_CHECK (to_string_uflags (UFLAG1 | UFLAG3)
- == "0x5 [UFLAG1 UFLAG3]");
+ SELF_CHECK (to_string_uflags (0) == "0x0 []");
+ SELF_CHECK (to_string_uflags (UFLAG1) == "0x1 [UFLAG1]");
+ SELF_CHECK (to_string_uflags (UFLAG1 | UFLAG3) == "0x5 [UFLAG1 UFLAG3]");
SELF_CHECK (to_string_uflags (UFLAG1 | UFLAG2 | UFLAG3)
== "0x7 [UFLAG1 UFLAG3 0x2]");
- SELF_CHECK (to_string_uflags (UFLAG2)
- == "0x2 [0x2]");
+ SELF_CHECK (to_string_uflags (UFLAG2) == "0x2 [0x2]");
/* Check that even with multiple unmapped flags, we only print one
unmapped hex number (0xa, in this case). */
SELF_CHECK (to_string_uflags (UFLAG1 | UFLAG2 | UFLAG3 | UFLAG4)
== "0xf [UFLAG1 UFLAG3 0xa]");
- SELF_CHECK (to_string_flags (0)
- == "0x0 []");
- SELF_CHECK (to_string_flags (FLAG1)
- == "0x1 [FLAG1]");
- SELF_CHECK (to_string_flags (FLAG1 | FLAG3)
- == "0x5 [FLAG1 FLAG3]");
+ SELF_CHECK (to_string_flags (0) == "0x0 []");
+ SELF_CHECK (to_string_flags (FLAG1) == "0x1 [FLAG1]");
+ SELF_CHECK (to_string_flags (FLAG1 | FLAG3) == "0x5 [FLAG1 FLAG3]");
SELF_CHECK (to_string_flags (FLAG1 | FLAG2 | FLAG3)
== "0x7 [FLAG1 FLAG3 0x2]");
- SELF_CHECK (to_string_flags (FLAG2)
- == "0x2 [0x2]");
+ SELF_CHECK (to_string_flags (FLAG2) == "0x2 [0x2]");
SELF_CHECK (to_string_flags (FLAG1 | FLAG2 | FLAG3 | FLAG4)
== "0xf [FLAG1 FLAG3 0xa]");
}
diff --git a/gdb/unittests/environ-selftests.c b/gdb/unittests/environ-selftests.c
index 5edbc4e..c1e353d 100644
--- a/gdb/unittests/environ-selftests.c
+++ b/gdb/unittests/environ-selftests.c
@@ -30,8 +30,10 @@ set_contains (const std::set<std::string> &set, std::string key)
return set.find (key) != set.end ();
}
-namespace selftests {
-namespace gdb_environ_tests {
+namespace selftests
+{
+namespace gdb_environ_tests
+{
/* Test if the vector is initialized in a correct way. */
@@ -270,7 +272,7 @@ run_tests ()
{
/* Set a test environment variable. */
if (setenv ("GDB_SELFTEST_ENVIRON", "1", 1) != 0)
- error (_("Could not set environment variable for testing."));
+ error (_ ("Could not set environment variable for testing."));
test_vector_initialization ();
@@ -295,10 +297,11 @@ run_tests ()
test_self_move ();
}
-} /* namespace gdb_environ */
+} // namespace gdb_environ_tests
} /* namespace selftests */
void _initialize_environ_selftests ();
+
void
_initialize_environ_selftests ()
{
diff --git a/gdb/unittests/filtered_iterator-selftests.c b/gdb/unittests/filtered_iterator-selftests.c
index 6e93a09..8a16e70 100644
--- a/gdb/unittests/filtered_iterator-selftests.c
+++ b/gdb/unittests/filtered_iterator-selftests.c
@@ -23,7 +23,8 @@
#include <iterator>
-namespace selftests {
+namespace selftests
+{
/* An iterator class that iterates on integer arrays. */
@@ -38,13 +39,17 @@ struct int_array_iterator
/* Create an iterator that points at the first element of an integer
array at ARRAY of size SIZE. */
int_array_iterator (int *array, size_t size)
- : m_array (array), m_size (size)
- {}
+ : m_array (array),
+ m_size (size)
+ {
+ }
/* Create a past-the-end iterator. */
int_array_iterator ()
- : m_array (nullptr), m_size (0)
- {}
+ : m_array (nullptr),
+ m_size (0)
+ {
+ }
bool operator== (const int_array_iterator &other) const
{
@@ -91,6 +96,7 @@ struct int_array_iterator
}
private:
+
/* A nullptr value in M_ARRAY indicates a past-the-end iterator. */
int *m_array;
size_t m_size;
@@ -101,10 +107,7 @@ private:
struct even_numbers_only
{
- bool operator() (int n)
- {
- return n % 2 == 0;
- }
+ bool operator() (int n) { return n % 2 == 0; }
};
/* Test typical usage. */
@@ -116,8 +119,8 @@ test_filtered_iterator ()
std::vector<int> even_ints;
const std::vector<int> expected_even_ints { 4, 4, 6, 8 };
- filtered_iterator<int_array_iterator, even_numbers_only>
- iter (array, ARRAY_SIZE (array));
+ filtered_iterator<int_array_iterator, even_numbers_only> iter (
+ array, ARRAY_SIZE (array));
filtered_iterator<int_array_iterator, even_numbers_only> end;
for (; iter != end; ++iter)
@@ -133,10 +136,10 @@ test_filtered_iterator_eq ()
{
int array[] = { 4, 4, 5, 6, 7, 8, 9 };
- filtered_iterator<int_array_iterator, even_numbers_only>
- iter1(array, ARRAY_SIZE (array));
- filtered_iterator<int_array_iterator, even_numbers_only>
- iter2(array, ARRAY_SIZE (array));
+ filtered_iterator<int_array_iterator, even_numbers_only> iter1 (
+ array, ARRAY_SIZE (array));
+ filtered_iterator<int_array_iterator, even_numbers_only> iter2 (
+ array, ARRAY_SIZE (array));
/* They start equal. */
gdb_assert (iter1 == iter2);
@@ -156,6 +159,7 @@ test_filtered_iterator_eq ()
} /* namespace selftests */
void _initialize_filtered_iterator_selftests ();
+
void
_initialize_filtered_iterator_selftests ()
{
diff --git a/gdb/unittests/format_pieces-selftests.c b/gdb/unittests/format_pieces-selftests.c
index dd10b0b..46446e0 100644
--- a/gdb/unittests/format_pieces-selftests.c
+++ b/gdb/unittests/format_pieces-selftests.c
@@ -27,8 +27,10 @@
#define LL "ll"
#endif
-namespace selftests {
-namespace format_pieces {
+namespace selftests
+{
+namespace format_pieces
+{
/* Verify that parsing STR gives pieces equal to EXPECTED_PIECES. */
@@ -47,9 +49,9 @@ static void
test_escape_sequences ()
{
check ("This is an escape sequence: \\e",
- {
- format_piece ("This is an escape sequence: \e", literal_piece, 0),
- });
+ {
+ format_piece ("This is an escape sequence: \e", literal_piece, 0),
+ });
}
static void
@@ -58,28 +60,29 @@ test_format_specifier ()
/* The format string here ends with a % sequence, to ensure we don't
see a trailing empty literal piece. */
check ("Hello\\t %d%llx%%d%d", /* ARI: %ll */
- {
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%d", int_arg, 0),
- format_piece ("%" LL "x", long_long_arg, 0),
- format_piece ("%%d", literal_piece, 0),
- format_piece ("%d", int_arg, 0),
- });
+ {
+ format_piece ("Hello\t ", literal_piece, 0),
+ format_piece ("%d", int_arg, 0),
+ format_piece ("%" LL "x", long_long_arg, 0),
+ format_piece ("%%d", literal_piece, 0),
+ format_piece ("%d", int_arg, 0),
+ });
}
static void
test_gdb_formats ()
{
check ("Hello\\t \"%p[%pF%ps%*.*d%p]\"",
- {
- format_piece ("Hello\\t \"", literal_piece, 0),
- format_piece ("%p[", ptr_arg, 0),
- format_piece ("%pF", ptr_arg, 0),
- format_piece ("%ps", ptr_arg, 0),
- format_piece ("%*.*d", int_arg, 2),
- format_piece ("%p]", ptr_arg, 0),
- format_piece ("\"", literal_piece, 0),
- }, true);
+ {
+ format_piece ("Hello\\t \"", literal_piece, 0),
+ format_piece ("%p[", ptr_arg, 0),
+ format_piece ("%pF", ptr_arg, 0),
+ format_piece ("%ps", ptr_arg, 0),
+ format_piece ("%*.*d", int_arg, 2),
+ format_piece ("%p]", ptr_arg, 0),
+ format_piece ("\"", literal_piece, 0),
+ },
+ true);
}
/* Test the different size modifiers that can be applied to an integer
@@ -89,50 +92,37 @@ static void
test_format_int_sizes ()
{
check ("Hello\\t %hu%lu%llu%zu", /* ARI: %ll */
- {
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%hu", int_arg, 0),
- format_piece ("%lu", long_arg, 0),
- format_piece ("%" LL "u", long_long_arg, 0),
- format_piece ("%zu", size_t_arg, 0)
- });
+ { format_piece ("Hello\t ", literal_piece, 0),
+ format_piece ("%hu", int_arg, 0), format_piece ("%lu", long_arg, 0),
+ format_piece ("%" LL "u", long_long_arg, 0),
+ format_piece ("%zu", size_t_arg, 0) });
check ("Hello\\t %hx%lx%llx%zx", /* ARI: %ll */
- {
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%hx", int_arg, 0),
- format_piece ("%lx", long_arg, 0),
- format_piece ("%" LL "x", long_long_arg, 0),
- format_piece ("%zx", size_t_arg, 0)
- });
+ { format_piece ("Hello\t ", literal_piece, 0),
+ format_piece ("%hx", int_arg, 0), format_piece ("%lx", long_arg, 0),
+ format_piece ("%" LL "x", long_long_arg, 0),
+ format_piece ("%zx", size_t_arg, 0) });
check ("Hello\\t %ho%lo%llo%zo", /* ARI: %ll */
- {
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%ho", int_arg, 0),
- format_piece ("%lo", long_arg, 0),
- format_piece ("%" LL "o", long_long_arg, 0),
- format_piece ("%zo", size_t_arg, 0)
- });
+ { format_piece ("Hello\t ", literal_piece, 0),
+ format_piece ("%ho", int_arg, 0), format_piece ("%lo", long_arg, 0),
+ format_piece ("%" LL "o", long_long_arg, 0),
+ format_piece ("%zo", size_t_arg, 0) });
check ("Hello\\t %hd%ld%lld%zd", /* ARI: %ll */
- {
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%hd", int_arg, 0),
- format_piece ("%ld", long_arg, 0),
- format_piece ("%" LL "d", long_long_arg, 0),
- format_piece ("%zd", size_t_arg, 0)
- });
+ { format_piece ("Hello\t ", literal_piece, 0),
+ format_piece ("%hd", int_arg, 0), format_piece ("%ld", long_arg, 0),
+ format_piece ("%" LL "d", long_long_arg, 0),
+ format_piece ("%zd", size_t_arg, 0) });
}
static void
test_windows_formats ()
{
- check ("rc%I64d",
- {
- format_piece ("rc", literal_piece, 0),
- format_piece ("%I64d", long_long_arg, 0),
- });
+ check ("rc%I64d", {
+ format_piece ("rc", literal_piece, 0),
+ format_piece ("%I64d", long_long_arg, 0),
+ });
}
static void
@@ -149,6 +139,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_format_pieces_selftests ();
+
void
_initialize_format_pieces_selftests ()
{
diff --git a/gdb/unittests/frame_info_ptr-selftests.c b/gdb/unittests/frame_info_ptr-selftests.c
index fe1e7be..a970428 100644
--- a/gdb/unittests/frame_info_ptr-selftests.c
+++ b/gdb/unittests/frame_info_ptr-selftests.c
@@ -24,7 +24,8 @@
#include "scoped-mock-context.h"
#include "test-target.h"
-namespace selftests {
+namespace selftests
+{
static void
validate_user_created_frame (frame_id id)
@@ -50,8 +51,8 @@ user_created_frame_callee (frame_info_ptr frame)
static void
test_user_created_frame ()
{
- scoped_mock_context<test_target_ops> mock_context
- (current_inferior ()->gdbarch);
+ scoped_mock_context<test_target_ops> mock_context (
+ current_inferior ()->gdbarch);
frame_info_ptr frame = create_new_frame (0x1234, 0x5678);
validate_user_created_frame (get_frame_id (frame));
@@ -68,6 +69,7 @@ test_user_created_frame ()
} /* namespace selftests */
void _initialize_frame_info_ptr_selftests ();
+
void
_initialize_frame_info_ptr_selftests ()
{
diff --git a/gdb/unittests/function-view-selftests.c b/gdb/unittests/function-view-selftests.c
index ab9375c..faa10ed 100644
--- a/gdb/unittests/function-view-selftests.c
+++ b/gdb/unittests/function-view-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/function-view.h"
-namespace selftests {
-namespace function_view {
+namespace selftests
+{
+namespace function_view
+{
static int
plus_one_fn_int (int val)
@@ -37,20 +39,20 @@ plus_one_fn_short (short val)
}
static int
-call_callback_int (int val, gdb::function_view <int (int)> callback)
+call_callback_int (int val, gdb::function_view<int (int)> callback)
{
return callback (val);
}
static void
-call_callback_void (int val, gdb::function_view <void (int)> callback)
+call_callback_void (int val, gdb::function_view<void (int)> callback)
{
callback (val);
}
struct plus_one_int_func_obj
{
- int operator () (int val)
+ int operator() (int val)
{
++call_count;
return ++val;
@@ -80,10 +82,7 @@ test_function_view ()
/* Check calling a function that takes a function_view as argument,
by value. Pass a lambda, making sure a function_view is properly
constructed implicitly. */
- SELF_CHECK (call_callback_int (1, [] (int val)
- {
- return val + 2;
- }) == 3);
+ SELF_CHECK (call_callback_int (1, [] (int val) { return val + 2; }) == 3);
/* Same, passing a named/lvalue lambda. */
SELF_CHECK (call_callback_int (1, plus_one_lambda) == 2);
@@ -104,10 +103,9 @@ test_function_view ()
/* Check calling a function with a
compatible-but-not-exactly-the-same prototype. */
- SELF_CHECK (call_callback_int (1, [] (short val) -> short
- {
- return val + 2;
- }) == 3);
+ SELF_CHECK (call_callback_int (1,
+ [] (short val) -> short { return val + 2; })
+ == 3);
/* Same, but passing a function pointer. */
SELF_CHECK (call_callback_int (1, plus_one_fn_short) == 2);
@@ -115,10 +113,7 @@ test_function_view ()
can reference callables with non-void return type. The result is
simply discarded. Check a lambda, function object and a function
pointer. */
- call_callback_void (1, [] (int val) -> int
- {
- return val + 2;
- });
+ call_callback_void (1, [] (int val) -> int { return val + 2; });
call_callback_void (1, func_obj);
call_callback_void (1, plus_one_fn_int);
@@ -126,9 +121,11 @@ test_function_view ()
auto plus_one_func_view2 (plus_one_func_view);
auto plus_one_func_view3 (plus_one_func_view2);
static_assert (std::is_same<decltype (plus_one_func_view),
- decltype (plus_one_func_view2)>::value, "");
+ decltype (plus_one_func_view2)>::value,
+ "");
static_assert (std::is_same<decltype (plus_one_func_view),
- decltype (plus_one_func_view3)>::value, "");
+ decltype (plus_one_func_view3)>::value,
+ "");
SELF_CHECK (plus_one_func_view3 (1) == 2);
@@ -188,20 +185,14 @@ make_fv_test_func (int val)
struct func_obj_const_op
{
- int operator() (int val) const
- {
- return val + 1;
- }
+ int operator() (int val) const { return val + 1; }
};
/* A function object with non-const operator(). */
struct func_obj_non_const_op
{
- int operator() (int val)
- {
- return val + 1;
- }
+ int operator() (int val) { return val + 1; }
};
static void
@@ -211,7 +202,8 @@ test_make_function_view ()
SELF_CHECK (3 == tmpl_func (1, gdb::make_function_view (make_fv_test_func)));
/* Function pointer. */
- SELF_CHECK (3 == tmpl_func (1, gdb::make_function_view (&make_fv_test_func)));
+ SELF_CHECK (3
+ == tmpl_func (1, gdb::make_function_view (&make_fv_test_func)));
/* Reference to const and non-const function pointers. */
typedef int (*func_ptr) (int);
@@ -252,6 +244,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_function_view_selftests ();
+
void
_initialize_function_view_selftests ()
{
diff --git a/gdb/unittests/gdb_tilde_expand-selftests.c b/gdb/unittests/gdb_tilde_expand-selftests.c
index 3de67c3..1bba9a7 100644
--- a/gdb/unittests/gdb_tilde_expand-selftests.c
+++ b/gdb/unittests/gdb_tilde_expand-selftests.c
@@ -23,8 +23,10 @@
#include "gdbsupport/gdb_tilde_expand.h"
-namespace selftests {
-namespace gdb_tilde_expand_tests {
+namespace selftests
+{
+namespace gdb_tilde_expand_tests
+{
static void
do_test ()
@@ -45,7 +47,7 @@ do_test ()
does not exist, gdb_tilde expand must still be able to do the tilde
expansion. */
SELF_CHECK (gdb_tilde_expand ("~/non/existent/directory")
- == home + "/non/existent/directory");
+ == home + "/non/existent/directory");
/* gdb_tilde_expand only expands tilde and does not try to do any other
substitution. */
@@ -63,7 +65,7 @@ do_test ()
const std::string user (c_user);
SELF_CHECK (gdb_tilde_expand (("~" + user).c_str ()) == home);
SELF_CHECK (gdb_tilde_expand (("~" + user + "/a/b").c_str ())
- == home + "/a/b");
+ == home + "/a/b");
}
/* Check that an error is thrown when trying to expand home of a unknown
@@ -76,9 +78,9 @@ do_test ()
catch (const gdb_exception_error &e)
{
SELF_CHECK (e.error == GENERIC_ERROR);
- SELF_CHECK
- (*e.message
- == "Could not find a match for '~no_one_should_have_that_login'.");
+ SELF_CHECK (
+ *e.message
+ == "Could not find a match for '~no_one_should_have_that_login'.");
}
}
@@ -86,9 +88,10 @@ do_test ()
} /* namespace selftests */
void _initialize_gdb_tilde_expand_selftests ();
+
void
_initialize_gdb_tilde_expand_selftests ()
{
- selftests::register_test
- ("gdb_tilde_expand", selftests::gdb_tilde_expand_tests::do_test);
+ selftests::register_test ("gdb_tilde_expand",
+ selftests::gdb_tilde_expand_tests::do_test);
}
diff --git a/gdb/unittests/gmp-utils-selftests.c b/gdb/unittests/gmp-utils-selftests.c
index cc525a1..ca63f0f 100644
--- a/gdb/unittests/gmp-utils-selftests.c
+++ b/gdb/unittests/gmp-utils-selftests.c
@@ -22,7 +22,8 @@
#include <math.h>
-namespace selftests {
+namespace selftests
+{
/* Perform a series of general tests of gdb_mpz's as_integer method.
@@ -172,7 +173,7 @@ store_and_read_back (T val, size_t buf_len, enum bfd_endian byte_order,
mpz_set (actual.val, expected.val);
mpz_sub_ui (actual.val, actual.val, 500);
- actual.read ({buf, buf_len}, byte_order, !std::is_signed<T>::value);
+ actual.read ({ buf, buf_len }, byte_order, !std::is_signed<T>::value);
}
/* Test the gdb_mpz::read method over a reasonable range of values.
@@ -229,48 +230,48 @@ gdb_mpz_read_min_max ()
LONGEST l_min = (LONGEST) 1 << (sizeof (LONGEST) * 8 - 1);
- store_and_read_back (l_min, sizeof (LONGEST), BFD_ENDIAN_BIG,
- expected, actual);
+ store_and_read_back (l_min, sizeof (LONGEST), BFD_ENDIAN_BIG, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
- store_and_read_back (l_min, sizeof (LONGEST), BFD_ENDIAN_LITTLE,
- expected, actual);
+ store_and_read_back (l_min, sizeof (LONGEST), BFD_ENDIAN_LITTLE, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
/* Same with LONGEST_MAX. */
LONGEST l_max = LONGEST_MAX;
- store_and_read_back (l_max, sizeof (LONGEST), BFD_ENDIAN_BIG,
- expected, actual);
+ store_and_read_back (l_max, sizeof (LONGEST), BFD_ENDIAN_BIG, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
- store_and_read_back (l_max, sizeof (LONGEST), BFD_ENDIAN_LITTLE,
- expected, actual);
+ store_and_read_back (l_max, sizeof (LONGEST), BFD_ENDIAN_LITTLE, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
/* Same with the smallest ULONGEST. */
ULONGEST ul_min = 0;
- store_and_read_back (ul_min, sizeof (ULONGEST), BFD_ENDIAN_BIG,
- expected, actual);
+ store_and_read_back (ul_min, sizeof (ULONGEST), BFD_ENDIAN_BIG, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
- store_and_read_back (ul_min, sizeof (ULONGEST), BFD_ENDIAN_LITTLE,
- expected, actual);
+ store_and_read_back (ul_min, sizeof (ULONGEST), BFD_ENDIAN_LITTLE, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
/* Same with ULONGEST_MAX. */
ULONGEST ul_max = ULONGEST_MAX;
- store_and_read_back (ul_max, sizeof (ULONGEST), BFD_ENDIAN_BIG,
- expected, actual);
+ store_and_read_back (ul_max, sizeof (ULONGEST), BFD_ENDIAN_BIG, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
- store_and_read_back (ul_max, sizeof (ULONGEST), BFD_ENDIAN_LITTLE,
- expected, actual);
+ store_and_read_back (ul_max, sizeof (ULONGEST), BFD_ENDIAN_LITTLE, expected,
+ actual);
SELF_CHECK (mpz_cmp (actual.val, expected.val) == 0);
}
@@ -297,9 +298,9 @@ write_and_extract (T val, size_t buf_len, enum bfd_endian byte_order)
SELF_CHECK (v.as_integer<T> () == val);
gdb_byte *buf = (gdb_byte *) alloca (buf_len);
- v.write ({buf, buf_len}, byte_order, !std::is_signed<T>::value);
+ v.write ({ buf, buf_len }, byte_order, !std::is_signed<T>::value);
- return extract_integer<T> ({buf, buf_len}, byte_order);
+ return extract_integer<T> ({ buf, buf_len }, byte_order);
}
/* Test the gdb_mpz::write method over a reasonable range of values.
@@ -320,7 +321,7 @@ gdb_mpz_write_all_from_small ()
SELF_CHECK (write_and_extract (l, buf_len, BFD_ENDIAN_LITTLE) == l);
}
- /* Do the same as above, but with an unsigned type. */
+ /* Do the same as above, but with an unsigned type. */
ULONGEST ul_min = 0;
ULONGEST ul_max = pow (2.0, buf_len * 8) - 1;
@@ -387,8 +388,7 @@ gdb_mpz_write_min_max ()
static void
read_fp_test (int unscaled, const gdb_mpq &scaling_factor,
- enum bfd_endian byte_order,
- gdb_mpq &expected, gdb_mpq &actual)
+ enum bfd_endian byte_order, gdb_mpq &expected, gdb_mpq &actual)
{
/* For this kind of testing, we'll use a buffer the same size as
our unscaled parameter. */
@@ -396,7 +396,7 @@ read_fp_test (int unscaled, const gdb_mpq &scaling_factor,
gdb_byte buf[len];
store_signed_integer (buf, len, byte_order, unscaled);
- actual.read_fixed_point ({buf, len}, byte_order, 0, scaling_factor);
+ actual.read_fixed_point ({ buf, len }, byte_order, 0, scaling_factor);
mpq_set_si (expected.val, unscaled, 1);
mpq_mul (expected.val, expected.val, scaling_factor.val);
@@ -451,8 +451,7 @@ gdb_mpq_read_fixed_point ()
static LONGEST
write_fp_test (int numerator, unsigned int denominator,
- const gdb_mpq &scaling_factor,
- enum bfd_endian byte_order)
+ const gdb_mpq &scaling_factor, enum bfd_endian byte_order)
{
/* For this testing, we'll use a buffer the size of LONGEST.
This is really an arbitrary decision, as long as the buffer
@@ -465,7 +464,7 @@ write_fp_test (int numerator, unsigned int denominator,
gdb_mpq v;
mpq_set_si (v.val, numerator, denominator);
mpq_canonicalize (v.val);
- v.write_fixed_point ({buf, len}, byte_order, 0, scaling_factor);
+ v.write_fixed_point ({ buf, len }, byte_order, 0, scaling_factor);
return extract_unsigned_integer (buf, len, byte_order);
}
@@ -499,7 +498,7 @@ gdb_mpq_write_fixed_point ()
SELF_CHECK (write_fp_test (5, 3, scaling_factor, BFD_ENDIAN_LITTLE) == 5);
}
-}
+} // namespace selftests
void _initialize_gmp_utils_selftests ();
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index fe47177..9c640b7 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -36,7 +36,8 @@ struct item_with_base : public other_base,
{
explicit item_with_base (const char *name)
: name (name)
- {}
+ {
+ }
const char *const name;
};
@@ -51,7 +52,8 @@ struct item_with_member
{
explicit item_with_member (const char *name)
: name (name)
- {}
+ {
+ }
const char *const name;
intrusive_list_node<item_with_member> node;
@@ -66,7 +68,7 @@ using item_with_member_list
declared in this templated class, which is instantiated once for each
list type. */
-template <typename ListType>
+template<typename ListType>
struct intrusive_list_test
{
using item_type = typename ListType::value_type;
@@ -75,14 +77,13 @@ struct intrusive_list_test
Traverse the list forward and backwards to exercise all links. */
- static void
- verify_items (const ListType &list,
- gdb::array_view<const typename ListType::value_type *> expected)
+ static void verify_items (
+ const ListType &list,
+ gdb::array_view<const typename ListType::value_type *> expected)
{
int i = 0;
- for (typename ListType::iterator it = list.begin ();
- it != list.end ();
+ for (typename ListType::iterator it = list.begin (); it != list.end ();
++it)
{
const item_type &item = *it;
@@ -96,8 +97,7 @@ struct intrusive_list_test
gdb_assert (i == expected.size ());
for (typename ListType::reverse_iterator it = list.rbegin ();
- it != list.rend ();
- ++it)
+ it != list.rend (); ++it)
{
const item_type &item = *it;
@@ -110,8 +110,7 @@ struct intrusive_list_test
gdb_assert (i == 0);
}
- static void
- test_move_constructor ()
+ static void test_move_constructor ()
{
{
/* Other list is not empty. */
@@ -128,7 +127,7 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list2, expected);
}
@@ -145,7 +144,7 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a};
+ expected = { &a };
verify_items (list2, expected);
}
@@ -164,8 +163,7 @@ struct intrusive_list_test
}
}
- static void
- test_move_assignment ()
+ static void test_move_assignment ()
{
{
/* Both lists are not empty. */
@@ -186,7 +184,7 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list2, expected);
}
@@ -226,7 +224,7 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list2, expected);
}
@@ -245,7 +243,7 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a};
+ expected = { &a };
verify_items (list2, expected);
}
@@ -265,8 +263,7 @@ struct intrusive_list_test
}
}
- static void
- test_swap ()
+ static void test_swap ()
{
{
/* Two non-empty lists. */
@@ -284,10 +281,10 @@ struct intrusive_list_test
std::swap (list1, list2);
- expected = {&d, &e};
+ expected = { &d, &e };
verify_items (list1, expected);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list2, expected);
}
@@ -307,7 +304,7 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list2, expected);
}
@@ -324,7 +321,7 @@ struct intrusive_list_test
std::swap (list1, list2);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list1, expected);
expected = {};
@@ -360,12 +357,12 @@ struct intrusive_list_test
expected = {};
verify_items (list1, expected);
- expected = {&a};
+ expected = { &a };
verify_items (list2, expected);
std::swap (list1, list2);
- expected = {&a};
+ expected = { &a };
verify_items (list1, expected);
expected = {};
@@ -373,8 +370,7 @@ struct intrusive_list_test
}
}
- static void
- test_front_back ()
+ static void test_front_back ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -390,8 +386,7 @@ struct intrusive_list_test
gdb_assert (&clist.back () == &c);
}
- static void
- test_push_front ()
+ static void test_push_front ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -401,20 +396,19 @@ struct intrusive_list_test
verify_items (list, expected);
list.push_front (a);
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
list.push_front (b);
- expected = {&b, &a};
+ expected = { &b, &a };
verify_items (list, expected);
list.push_front (c);
- expected = {&c, &b, &a};
+ expected = { &c, &b, &a };
verify_items (list, expected);
}
- static void
- test_push_back ()
+ static void test_push_back ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -424,20 +418,19 @@ struct intrusive_list_test
verify_items (list, expected);
list.push_back (a);
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
list.push_back (b);
- expected = {&a, &b};
+ expected = { &a, &b };
verify_items (list, expected);
list.push_back (c);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list, expected);
}
- static void
- test_insert ()
+ static void test_insert ()
{
std::vector<const item_type *> expected;
@@ -446,17 +439,16 @@ struct intrusive_list_test
item_type a ("a"), b ("b"), c ("c");
ListType list;
-
list.insert (list.begin (), a);
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
list.insert (list.begin (), b);
- expected = {&b, &a};
+ expected = { &b, &a };
verify_items (list, expected);
list.insert (list.begin (), c);
- expected = {&c, &b, &a};
+ expected = { &c, &b, &a };
verify_items (list, expected);
}
@@ -465,17 +457,16 @@ struct intrusive_list_test
item_type a ("a"), b ("b"), c ("c");
ListType list;
-
list.insert (list.end (), a);
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
list.insert (list.end (), b);
- expected = {&a, &b};
+ expected = { &a, &b };
verify_items (list, expected);
list.insert (list.end (), c);
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list, expected);
}
@@ -488,7 +479,7 @@ struct intrusive_list_test
list.push_back (b);
list.insert (list.iterator_to (b), c);
- expected = {&a, &c, &b};
+ expected = { &a, &c, &b };
verify_items (list, expected);
}
@@ -498,13 +489,12 @@ struct intrusive_list_test
ListType list;
list.insert (list.end (), a);
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
}
}
- static void
- test_splice ()
+ static void test_splice ()
{
{
/* Two non-empty lists. */
@@ -522,7 +512,7 @@ struct intrusive_list_test
list1.splice (std::move (list2));
- expected = {&a, &b, &c, &d, &e};
+ expected = { &a, &b, &c, &d, &e };
verify_items (list1, expected);
expected = {};
@@ -542,7 +532,7 @@ struct intrusive_list_test
list1.splice (std::move (list2));
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list1, expected);
expected = {};
@@ -562,7 +552,7 @@ struct intrusive_list_test
list1.splice (std::move (list2));
- expected = {&a, &b, &c};
+ expected = { &a, &b, &c };
verify_items (list1, expected);
expected = {};
@@ -586,8 +576,7 @@ struct intrusive_list_test
}
}
- static void
- test_pop_front ()
+ static void test_pop_front ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -598,11 +587,11 @@ struct intrusive_list_test
list.push_back (c);
list.pop_front ();
- expected = {&b, &c};
+ expected = { &b, &c };
verify_items (list, expected);
list.pop_front ();
- expected = {&c};
+ expected = { &c };
verify_items (list, expected);
list.pop_front ();
@@ -610,8 +599,7 @@ struct intrusive_list_test
verify_items (list, expected);
}
- static void
- test_pop_back ()
+ static void test_pop_back ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -621,12 +609,12 @@ struct intrusive_list_test
list.push_back (b);
list.push_back (c);
- list.pop_back();
- expected = {&a, &b};
+ list.pop_back ();
+ expected = { &a, &b };
verify_items (list, expected);
list.pop_back ();
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
list.pop_back ();
@@ -634,8 +622,7 @@ struct intrusive_list_test
verify_items (list, expected);
}
- static void
- test_erase ()
+ static void test_erase ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -646,11 +633,11 @@ struct intrusive_list_test
list.push_back (c);
list.erase (list.iterator_to (b));
- expected = {&a, &c};
+ expected = { &a, &c };
verify_items (list, expected);
list.erase (list.iterator_to (c));
- expected = {&a};
+ expected = { &a };
verify_items (list, expected);
list.erase (list.iterator_to (a));
@@ -658,8 +645,7 @@ struct intrusive_list_test
verify_items (list, expected);
}
- static void
- test_clear ()
+ static void test_clear ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -679,8 +665,7 @@ struct intrusive_list_test
verify_items (list, expected);
}
- static void
- test_clear_and_dispose ()
+ static void test_clear_and_dispose ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -692,11 +677,10 @@ struct intrusive_list_test
list.push_back (b);
list.push_back (c);
- auto disposer = [&] (const item_type *item)
- {
- disposer_seen.insert (item);
- disposer_calls++;
- };
+ auto disposer = [&] (const item_type *item) {
+ disposer_seen.insert (item);
+ disposer_calls++;
+ };
list.clear_and_dispose (disposer);
expected = {};
@@ -711,8 +695,7 @@ struct intrusive_list_test
gdb_assert (disposer_calls == 3);
}
- static void
- test_empty ()
+ static void test_empty ()
{
item_type a ("a");
ListType list;
@@ -724,8 +707,7 @@ struct intrusive_list_test
gdb_assert (list.empty ());
}
- static void
- test_begin_end ()
+ static void test_begin_end ()
{
item_type a ("a"), b ("b"), c ("c");
ListType list;
@@ -752,7 +734,7 @@ struct intrusive_list_test
}
};
-template <typename ListType>
+template<typename ListType>
static void
test_intrusive_list_1 ()
{
@@ -810,9 +792,9 @@ test_intrusive_list ()
}
void _initialize_intrusive_list_selftests ();
+
void
_initialize_intrusive_list_selftests ()
{
- selftests::register_test
- ("intrusive_list", test_intrusive_list);
+ selftests::register_test ("intrusive_list", test_intrusive_list);
}
diff --git a/gdb/unittests/lookup_name_info-selftests.c b/gdb/unittests/lookup_name_info-selftests.c
index b69f79b..65688e4 100644
--- a/gdb/unittests/lookup_name_info-selftests.c
+++ b/gdb/unittests/lookup_name_info-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "symtab.h"
-namespace selftests {
-namespace lookup_name {
+namespace selftests
+{
+namespace lookup_name
+{
/* Check that removing parameter info out of NAME produces EXPECTED.
COMPLETION_MODE indicates whether we're testing normal and
@@ -30,8 +32,7 @@ namespace lookup_name {
location information in case the check fails. */
static void
-check_make_paramless (const char *file, int line,
- enum language lang,
+check_make_paramless (const char *file, int line, enum language lang,
const char *name, const char *expected,
bool completion_mode)
{
@@ -41,10 +42,10 @@ check_make_paramless (const char *file, int line,
if (strcmp (result, expected) != 0)
{
- error (_("%s:%d: make-paramless self-test failed: (completion=%d, lang=%d) "
- "\"%s\" -> \"%s\", expected \"%s\""),
- file, line, completion_mode, lang, name,
- result, expected);
+ error (
+ _ ("%s:%d: make-paramless self-test failed: (completion=%d, lang=%d) "
+ "\"%s\" -> \"%s\", expected \"%s\""),
+ file, line, completion_mode, lang, name, result, expected);
}
}
@@ -52,26 +53,23 @@ static void
run_tests ()
{
/* Helper for CHECK and CHECK_INCOMPL. */
-#define CHECK_1(INCOMPLETE, LANG, NAME, EXPECTED) \
- do \
- { \
- check_make_paramless (__FILE__, __LINE__, \
- LANG, NAME, \
- (INCOMPLETE) ? "" : (EXPECTED), false); \
- check_make_paramless (__FILE__, __LINE__, \
- LANG, NAME, EXPECTED, true); \
- } \
+#define CHECK_1(INCOMPLETE, LANG, NAME, EXPECTED) \
+ do \
+ { \
+ check_make_paramless (__FILE__, __LINE__, LANG, NAME, \
+ (INCOMPLETE) ? "" : (EXPECTED), false); \
+ check_make_paramless (__FILE__, __LINE__, LANG, NAME, EXPECTED, true); \
+ } \
while (0)
/* Check that removing parameter info out of NAME produces EXPECTED.
Checks both normal and completion modes. */
-#define CHECK(LANG, NAME, EXPECTED) \
- CHECK_1(false, LANG, NAME, EXPECTED)
+#define CHECK(LANG, NAME, EXPECTED) CHECK_1 (false, LANG, NAME, EXPECTED)
/* Similar, but used when NAME is incomplete -- i.e., NAME has
unbalanced parentheses. In this case, looking for the exact name
should fail / return empty. */
-#define CHECK_INCOMPL(LANG, NAME, EXPECTED) \
+#define CHECK_INCOMPL(LANG, NAME, EXPECTED) \
CHECK_1 (true, LANG, NAME, EXPECTED)
/* None of these languages support function overloading like C++
@@ -101,9 +99,11 @@ run_tests ()
#undef CHECK_INCOMPL
}
-}} // namespace selftests::lookup_name
+} // namespace lookup_name
+} // namespace selftests
void _initialize_lookup_name_info_selftests ();
+
void
_initialize_lookup_name_info_selftests ()
{
diff --git a/gdb/unittests/main-thread-selftests.c b/gdb/unittests/main-thread-selftests.c
index bdc1628..ee10247 100644
--- a/gdb/unittests/main-thread-selftests.c
+++ b/gdb/unittests/main-thread-selftests.c
@@ -27,8 +27,10 @@
#include <thread>
#endif
-namespace selftests {
-namespace main_thread_tests {
+namespace selftests
+{
+namespace main_thread_tests
+{
#if CXX_STD_THREAD
@@ -37,10 +39,7 @@ static bool done;
static void
set_done ()
{
- run_on_main_thread ([] ()
- {
- done = true;
- });
+ run_on_main_thread ([] () { done = true; });
}
static void
@@ -54,10 +53,10 @@ run_tests ()
gdb::block_signals blocker;
SCOPE_EXIT
- {
- if (thread.joinable ())
- thread.join ();
- };
+ {
+ if (thread.joinable ())
+ thread.join ();
+ };
thread = std::thread (set_done);
}
@@ -71,10 +70,11 @@ run_tests ()
#endif
-}
-}
+} // namespace main_thread_tests
+} // namespace selftests
void _initialize_main_thread_selftests ();
+
void
_initialize_main_thread_selftests ()
{
diff --git a/gdb/unittests/memory-map-selftests.c b/gdb/unittests/memory-map-selftests.c
index 2d5f2d6..4a318ad 100644
--- a/gdb/unittests/memory-map-selftests.c
+++ b/gdb/unittests/memory-map-selftests.c
@@ -23,8 +23,10 @@
#if defined(HAVE_LIBEXPAT)
-namespace selftests {
-namespace memory_map_tests {
+namespace selftests
+{
+namespace memory_map_tests
+{
/* A simple valid test input for parse_memory_map. */
@@ -54,7 +56,6 @@ check_mem_region (const mem_region &r, CORE_ADDR lo, CORE_ADDR hi,
SELF_CHECK (r.attrib.mode == mode);
SELF_CHECK (r.attrib.blocksize == blocksize);
-
}
/* Test the parse_memory_map function. */
@@ -77,12 +78,12 @@ parse_memory_map_tests ()
#endif /* HAVE_LIBEXPAT */
void _initialize_memory_map_selftests ();
+
void
_initialize_memory_map_selftests ()
{
#if defined(HAVE_LIBEXPAT)
- selftests::register_test
- ("parse_memory_map",
- selftests::memory_map_tests::parse_memory_map_tests);
+ selftests::register_test (
+ "parse_memory_map", selftests::memory_map_tests::parse_memory_map_tests);
#endif
}
diff --git a/gdb/unittests/memrange-selftests.c b/gdb/unittests/memrange-selftests.c
index a48944e..e4139a6 100644
--- a/gdb/unittests/memrange-selftests.c
+++ b/gdb/unittests/memrange-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "memrange.h"
-namespace selftests {
-namespace memrange_tests {
+namespace selftests
+{
+namespace memrange_tests
+{
static void
normalize_mem_ranges_tests ()
@@ -107,10 +109,11 @@ normalize_mem_ranges_tests ()
} /* namespace selftests */
void _initialize_memrange_selftests ();
+
void
_initialize_memrange_selftests ()
{
- selftests::register_test
- ("normalize_mem_ranges",
- selftests::memrange_tests::normalize_mem_ranges_tests);
+ selftests::register_test (
+ "normalize_mem_ranges",
+ selftests::memrange_tests::normalize_mem_ranges_tests);
}
diff --git a/gdb/unittests/mkdir-recursive-selftests.c b/gdb/unittests/mkdir-recursive-selftests.c
index 87b290e..8dc0e81 100644
--- a/gdb/unittests/mkdir-recursive-selftests.c
+++ b/gdb/unittests/mkdir-recursive-selftests.c
@@ -24,8 +24,10 @@
#include "gdbsupport/byte-vector.h"
#include "gdbsupport/pathstuff.h"
-namespace selftests {
-namespace mkdir_recursive {
+namespace selftests
+{
+namespace mkdir_recursive
+{
/* Try to create DIR using mkdir_recursive and make sure it exists. */
@@ -53,12 +55,15 @@ test ()
perror_with_name (("mkdtemp"));
/* Try not to leave leftover directories. */
- struct cleanup_dirs {
+ struct cleanup_dirs
+ {
cleanup_dirs (const char *base)
: m_base (base)
- {}
+ {
+ }
- ~cleanup_dirs () {
+ ~cleanup_dirs ()
+ {
rmdir (string_printf ("%s/a/b/c/d/e", m_base).c_str ());
rmdir (string_printf ("%s/a/b/c/d", m_base).c_str ());
rmdir (string_printf ("%s/a/b/c", m_base).c_str ());
@@ -68,6 +73,7 @@ test ()
}
private:
+
const char *m_base;
} cleanup_dirs (base.data ());
@@ -78,14 +84,14 @@ test ()
SELF_CHECK (create_dir_and_check (dir.c_str ()));
}
-}
-}
+} // namespace mkdir_recursive
+} // namespace selftests
void _initialize_mkdir_recursive_selftests ();
+
void
_initialize_mkdir_recursive_selftests ()
{
selftests::register_test ("mkdir_recursive",
selftests::mkdir_recursive::test);
}
-
diff --git a/gdb/unittests/observable-selftests.c b/gdb/unittests/observable-selftests.c
index 680b09e..8b8f482 100644
--- a/gdb/unittests/observable-selftests.c
+++ b/gdb/unittests/observable-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/observable.h"
-namespace selftests {
-namespace observers {
+namespace selftests
+{
+namespace observers
+{
static gdb::observers::observable<int> test_notification ("test_notification");
@@ -66,22 +68,46 @@ static void observer_dependency_test_callback (size_t index);
/* Data for observers to use for dependency tests, using some sample
dependencies between the observers. */
static std::vector<dependency_observer_data> test_observers = {
- {&observer_token0, "test0", {}, {},
- [] (int) { observer_dependency_test_callback (0); }},
- {&observer_token1, "test1", {0}, {0},
- [] (int) { observer_dependency_test_callback (1); }},
- {&observer_token2, "test2", {1}, {0, 1},
- [] (int) { observer_dependency_test_callback (2); }},
- {&observer_token3, "test3", {1}, {0, 1},
- [] (int) { observer_dependency_test_callback (3); }},
- {&observer_token4, "test4", {2, 3, 5}, {0, 1, 2, 3, 5},
- [] (int) { observer_dependency_test_callback (4); }},
- {&observer_token5, "test5", {0}, {0},
- [] (int) { observer_dependency_test_callback (5); }},
- {nullptr, "test6", {4}, {0, 1, 2, 3, 4, 5},
- [] (int) { observer_dependency_test_callback (6); }},
- {nullptr, "test7", {0}, {0},
- [] (int) { observer_dependency_test_callback (7); }},
+ { &observer_token0,
+ "test0",
+ {},
+ {},
+ [] (int) { observer_dependency_test_callback (0); } },
+ { &observer_token1,
+ "test1",
+ { 0 },
+ { 0 },
+ [] (int) { observer_dependency_test_callback (1); } },
+ { &observer_token2,
+ "test2",
+ { 1 },
+ { 0, 1 },
+ [] (int) { observer_dependency_test_callback (2); } },
+ { &observer_token3,
+ "test3",
+ { 1 },
+ { 0, 1 },
+ [] (int) { observer_dependency_test_callback (3); } },
+ { &observer_token4,
+ "test4",
+ { 2, 3, 5 },
+ { 0, 1, 2, 3, 5 },
+ [] (int) { observer_dependency_test_callback (4); } },
+ { &observer_token5,
+ "test5",
+ { 0 },
+ { 0 },
+ [] (int) { observer_dependency_test_callback (5); } },
+ { nullptr,
+ "test6",
+ { 4 },
+ { 0, 1, 2, 3, 4, 5 },
+ [] (int) { observer_dependency_test_callback (6); } },
+ { nullptr,
+ "test7",
+ { 0 },
+ { 0 },
+ [] (int) { observer_dependency_test_callback (7); } },
};
static void
@@ -137,8 +163,8 @@ observer_dependency_test_callback (size_t index)
static void
run_dependency_test (std::vector<int> insertion_order)
{
- gdb::observers::observable<int> dependency_test_notification
- ("dependency_test_notification");
+ gdb::observers::observable<int> dependency_test_notification (
+ "dependency_test_notification");
/* Reset counters. */
dependency_test_counters = std::vector<int> (test_observers.size (), 0);
@@ -154,8 +180,8 @@ run_dependency_test (std::vector<int> insertion_order)
dependency_tokens.emplace_back (test_observers[index].token);
if (o.token != nullptr)
- dependency_test_notification.attach
- (o.callback, *o.token, o.name, dependency_tokens);
+ dependency_test_notification.attach (o.callback, *o.token, o.name,
+ dependency_tokens);
else
dependency_test_notification.attach (o.callback, o.name,
dependency_tokens);
@@ -169,9 +195,9 @@ static void
test_dependency ()
{
/* Run dependency tests with different insertion orders. */
- run_dependency_test ({0, 1, 2, 3, 4, 5, 6, 7});
- run_dependency_test ({7, 6, 5, 4, 3, 2, 1, 0});
- run_dependency_test ({0, 3, 2, 1, 7, 6, 4, 5});
+ run_dependency_test ({ 0, 1, 2, 3, 4, 5, 6, 7 });
+ run_dependency_test ({ 7, 6, 5, 4, 3, 2, 1, 0 });
+ run_dependency_test ({ 0, 3, 2, 1, 7, 6, 4, 5 });
}
static void
@@ -181,10 +207,11 @@ run_tests ()
attached. */
notify_check_counters (0, 0, 0);
- const gdb::observers::token token1 {}, token2 {} , token3 {};
+ const gdb::observers::token token1 {}, token2 {}, token3 {};
/* Now, attach one observer, and send a notification. */
- test_notification.attach (&test_second_notification_function, token2, "test");
+ test_notification.attach (&test_second_notification_function, token2,
+ "test");
notify_check_counters (0, 1, 0);
/* Remove the observer, and send a notification. */
@@ -196,7 +223,8 @@ run_tests ()
notify_check_counters (1, 0, 0);
/* With 2 observers. */
- test_notification.attach (&test_second_notification_function, token2, "test");
+ test_notification.attach (&test_second_notification_function, token2,
+ "test");
notify_check_counters (1, 1, 0);
/* With 3 observers. */
@@ -218,7 +246,8 @@ run_tests ()
/* Go back to 3 observers, and remove them in a different
order... */
test_notification.attach (&test_first_notification_function, token1, "test");
- test_notification.attach (&test_second_notification_function, token2, "test");
+ test_notification.attach (&test_second_notification_function, token2,
+ "test");
test_notification.attach (&test_third_notification_function, token3, "test");
notify_check_counters (1, 1, 1);
@@ -239,11 +268,11 @@ run_tests ()
} /* namespace selftests */
void _initialize_observer_selftest ();
+
void
_initialize_observer_selftest ()
{
- selftests::register_test ("gdb::observers",
- selftests::observers::run_tests);
+ selftests::register_test ("gdb::observers", selftests::observers::run_tests);
selftests::register_test ("gdb::observers dependency",
selftests::observers::test_dependency);
}
diff --git a/gdb/unittests/offset-type-selftests.c b/gdb/unittests/offset-type-selftests.c
index dc63ef4..932a89b 100644
--- a/gdb/unittests/offset-type-selftests.c
+++ b/gdb/unittests/offset-type-selftests.c
@@ -23,8 +23,10 @@
#include "gdbsupport/underlying.h"
#include "gdbsupport/valid-expr.h"
-namespace selftests {
-namespace offset_type {
+namespace selftests
+{
+namespace offset_type
+{
DEFINE_OFFSET_TYPE (off_A, unsigned int);
DEFINE_OFFSET_TYPE (off_B, unsigned int);
@@ -38,7 +40,7 @@ DEFINE_OFFSET_TYPE (off_B, unsigned int);
do compile and that they return the correct type.
*/
-#define CHECK_VALID(VALID, EXPR_TYPE, EXPR) \
+#define CHECK_VALID(VALID, EXPR_TYPE, EXPR) \
CHECK_VALID_EXPR_2 (off_A, off_B, VALID, EXPR_TYPE, EXPR)
off_A lval_a {};
@@ -48,58 +50,58 @@ using undrl = std::underlying_type<off_A>::type;
/* Offset +/- underlying. */
-CHECK_VALID (true, off_A, off_A {} + undrl {});
-CHECK_VALID (true, off_A, off_A {} - undrl {});
-CHECK_VALID (true, off_A, undrl {} + off_A {});
-CHECK_VALID (true, off_A, undrl {} - off_A {});
+CHECK_VALID (true, off_A, off_A {} + undrl {});
+CHECK_VALID (true, off_A, off_A {} - undrl {});
+CHECK_VALID (true, off_A, undrl {} + off_A {});
+CHECK_VALID (true, off_A, undrl {} - off_A {});
/* Add offset types. Both same and different. */
-CHECK_VALID (false, void, off_A {} + off_A {});
-CHECK_VALID (false, void, off_A {} + off_B {});
+CHECK_VALID (false, void, off_A {} + off_A {});
+CHECK_VALID (false, void, off_A {} + off_B {});
/* Subtract offset types. Both same and different. */
-CHECK_VALID (false, void, off_B {} - off_A {});
-CHECK_VALID (true, undrl, off_A {} - off_A {});
+CHECK_VALID (false, void, off_B {} - off_A {});
+CHECK_VALID (true, undrl, off_A {} - off_A {});
/* Add/assign offset types. Both same and different. */
-CHECK_VALID (false, void, lval_a += off_A {});
-CHECK_VALID (false, void, lval_a += off_B {});
-CHECK_VALID (false, void, lval_a -= off_A {});
-CHECK_VALID (false, void, lval_a -= off_B {});
+CHECK_VALID (false, void, lval_a += off_A {});
+CHECK_VALID (false, void, lval_a += off_B {});
+CHECK_VALID (false, void, lval_a -= off_A {});
+CHECK_VALID (false, void, lval_a -= off_B {});
/* operator OP+= (offset, underlying), lvalue ref on the lhs. */
-CHECK_VALID (true, off_A&, lval_a += undrl {});
-CHECK_VALID (true, off_A&, lval_a -= undrl {});
+CHECK_VALID (true, off_A &, lval_a += undrl {});
+CHECK_VALID (true, off_A &, lval_a -= undrl {});
/* operator OP+= (offset, underlying), rvalue ref on the lhs. */
-CHECK_VALID (false, void, off_A {} += undrl {});
-CHECK_VALID (false, void, off_A {} -= undrl {});
+CHECK_VALID (false, void, off_A {} += undrl {});
+CHECK_VALID (false, void, off_A {} -= undrl {});
/* Rel ops, with same type. */
-CHECK_VALID (true, bool, off_A {} < off_A {});
-CHECK_VALID (true, bool, off_A {} > off_A {});
-CHECK_VALID (true, bool, off_A {} <= off_A {});
-CHECK_VALID (true, bool, off_A {} >= off_A {});
+CHECK_VALID (true, bool, off_A {} < off_A {});
+CHECK_VALID (true, bool, off_A {} > off_A {});
+CHECK_VALID (true, bool, off_A {} <= off_A {});
+CHECK_VALID (true, bool, off_A {} >= off_A {});
/* Rel ops, with unrelated offset types. */
-CHECK_VALID (false, void, off_A {} < off_B {});
-CHECK_VALID (false, void, off_A {} > off_B {});
-CHECK_VALID (false, void, off_A {} <= off_B {});
-CHECK_VALID (false, void, off_A {} >= off_B {});
+CHECK_VALID (false, void, off_A {} < off_B {});
+CHECK_VALID (false, void, off_A {} > off_B {});
+CHECK_VALID (false, void, off_A {} <= off_B {});
+CHECK_VALID (false, void, off_A {} >= off_B {});
/* Rel ops, with unrelated types. */
-CHECK_VALID (false, void, off_A {} < undrl {});
-CHECK_VALID (false, void, off_A {} > undrl {});
-CHECK_VALID (false, void, off_A {} <= undrl {});
-CHECK_VALID (false, void, off_A {} >= undrl {});
+CHECK_VALID (false, void, off_A {} < undrl {});
+CHECK_VALID (false, void, off_A {} > undrl {});
+CHECK_VALID (false, void, off_A {} <= undrl {});
+CHECK_VALID (false, void, off_A {} >= undrl {});
static void
run_tests ()
@@ -172,6 +174,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_offset_type_selftests ();
+
void
_initialize_offset_type_selftests ()
{
diff --git a/gdb/unittests/optional-selftests.c b/gdb/unittests/optional-selftests.c
index 8a727c0..b191e78 100644
--- a/gdb/unittests/optional-selftests.c
+++ b/gdb/unittests/optional-selftests.c
@@ -34,8 +34,10 @@
gdb::optional. */
#define GDB_OPTIONAL
-namespace selftests {
-namespace 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
@@ -88,6 +90,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_optional_selftests ();
+
void
_initialize_optional_selftests ()
{
diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selftests.c
index c5dd843..470d465 100644
--- a/gdb/unittests/packed-selftests.c
+++ b/gdb/unittests/packed-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/packed.h"
-namespace selftests {
-namespace packed_tests {
+namespace selftests
+{
+namespace packed_tests
+{
enum test_enum
{
@@ -43,7 +45,7 @@ gdb_static_assert (alignof (packed<test_enum, 3>) == 1);
gdb_static_assert (alignof (packed<test_enum, 4>) == 1);
/* Triviality checks. */
-#define CHECK_TRAIT(TRAIT) \
+#define CHECK_TRAIT(TRAIT) \
static_assert (std::TRAIT<packed<test_enum, 1>>::value, "")
#if HAVE_IS_TRIVIALLY_COPYABLE
@@ -125,6 +127,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_packed_selftests ();
+
void
_initialize_packed_selftests ()
{
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c
index 15a095a..e91a6b7 100644
--- a/gdb/unittests/parallel-for-selftests.c
+++ b/gdb/unittests/parallel-for-selftests.c
@@ -32,8 +32,10 @@
#include "gdbsupport/thread-pool.h"
-namespace selftests {
-namespace parallel_for {
+namespace selftests
+{
+namespace parallel_for
+{
struct save_restore_n_threads
{
@@ -79,12 +81,13 @@ test_n_threads ()
test (3);
}
-}
-}
+} // namespace parallel_for
+} // namespace selftests
#endif /* CXX_STD_THREAD */
void _initialize_parallel_for_selftests ();
+
void
_initialize_parallel_for_selftests ()
{
@@ -106,46 +109,29 @@ TEST (int n_threads)
std::atomic<int> counter (0);
FOR_EACH (1, 0, NUMBER,
- [&] (int start, int end)
- {
- counter += end - start;
- });
+ [&] (int start, int end) { counter += end - start; });
SELF_CHECK (counter == NUMBER);
counter = 0;
- FOR_EACH (1, 0, 0,
- [&] (int start, int end)
- {
- counter += end - start;
- });
+ FOR_EACH (1, 0, 0, [&] (int start, int end) { counter += end - start; });
SELF_CHECK (counter == 0);
- auto task_size_max_ = [] (int iter)
- {
- return (size_t)SIZE_MAX;
- };
+ auto task_size_max_ = [] (int iter) { return (size_t) SIZE_MAX; };
auto task_size_max = gdb::make_function_view (task_size_max_);
counter = 0;
- FOR_EACH (1, 0, NUMBER,
- [&] (int start, int end)
- {
- counter += end - start;
- }, task_size_max);
+ FOR_EACH (
+ 1, 0, NUMBER, [&] (int start, int end) { counter += end - start; },
+ task_size_max);
SELF_CHECK (counter == NUMBER);
- auto task_size_one_ = [] (int iter)
- {
- return (size_t)1;
- };
+ auto task_size_one_ = [] (int iter) { return (size_t) 1; };
auto task_size_one = gdb::make_function_view (task_size_one_);
counter = 0;
- FOR_EACH (1, 0, NUMBER,
- [&] (int start, int end)
- {
- counter += end - start;
- }, task_size_one);
+ FOR_EACH (
+ 1, 0, NUMBER, [&] (int start, int end) { counter += end - start; },
+ task_size_one);
SELF_CHECK (counter == NUMBER);
#undef NUMBER
@@ -155,39 +141,33 @@ TEST (int n_threads)
std::vector<std::unique_ptr<int>> intresults;
std::atomic<bool> any_empty_tasks (false);
- FOR_EACH (1, 0, 1,
- [&] (int start, int end)
- {
- if (start == end)
- any_empty_tasks = true;
- return std::unique_ptr<int> (new int (end - start));
- });
+ FOR_EACH (1, 0, 1, [&] (int start, int end) {
+ if (start == end)
+ any_empty_tasks = true;
+ return std::unique_ptr<int> (new int (end - start));
+ });
SELF_CHECK (!any_empty_tasks);
- SELF_CHECK (std::all_of (intresults.begin (),
- intresults.end (),
- [] (const std::unique_ptr<int> &entry)
- {
- return entry != nullptr;
- }));
+ SELF_CHECK (std::all_of (intresults.begin (), intresults.end (),
+ [] (const std::unique_ptr<int> &entry) {
+ return entry != nullptr;
+ }));
/* The same but using the task size parameter. */
intresults.clear ();
any_empty_tasks = false;
- FOR_EACH (1, 0, 1,
- [&] (int start, int end)
- {
- if (start == end)
- any_empty_tasks = true;
- return std::unique_ptr<int> (new int (end - start));
- },
- task_size_one);
+ FOR_EACH (
+ 1, 0, 1,
+ [&] (int start, int end) {
+ if (start == end)
+ any_empty_tasks = true;
+ return std::unique_ptr<int> (new int (end - start));
+ },
+ task_size_one);
SELF_CHECK (!any_empty_tasks);
- SELF_CHECK (std::all_of (intresults.begin (),
- intresults.end (),
- [] (const std::unique_ptr<int> &entry)
- {
- return entry != nullptr;
- }));
+ SELF_CHECK (std::all_of (intresults.begin (), intresults.end (),
+ [] (const std::unique_ptr<int> &entry) {
+ return entry != nullptr;
+ }));
}
#endif /* FOR_EACH */
diff --git a/gdb/unittests/parse-connection-spec-selftests.c b/gdb/unittests/parse-connection-spec-selftests.c
index aa773f5..8c43d70 100644
--- a/gdb/unittests/parse-connection-spec-selftests.c
+++ b/gdb/unittests/parse-connection-spec-selftests.c
@@ -31,8 +31,10 @@
#include <netinet/tcp.h>
#endif
-namespace selftests {
-namespace parse_connection_spec_tests {
+namespace selftests
+{
+namespace parse_connection_spec_tests
+{
/* Auxiliary struct that holds info about a specific test for a
connection spec. */
@@ -66,9 +68,11 @@ struct parse_conn_test
/* Initialize a full entry. */
#define INIT_ENTRY(ADDR, EXP_HOST, EXP_PORT, SHOULD_FAIL, EXP_AI_FAMILY, \
- EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL) \
- { ADDR, { EXP_HOST, EXP_PORT }, SHOULD_FAIL, EXP_AI_FAMILY, \
- EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL }
+ EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL) \
+ { \
+ ADDR, { EXP_HOST, EXP_PORT }, SHOULD_FAIL, EXP_AI_FAMILY, \
+ EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL \
+ }
/* Initialize an unprefixed entry. In this case, we don't expect
anything on the 'struct addrinfo' HINT. */
@@ -82,121 +86,117 @@ struct parse_conn_test
/* Initialize a prefixed entry. */
#define INIT_PREFIXED_ENTRY(ADDR, EXP_HOST, EXP_PORT, EXP_AI_FAMILY, \
- EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL) \
- INIT_ENTRY (ADDR, EXP_HOST, EXP_PORT, false, EXP_AI_FAMILY, \
+ EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL) \
+ INIT_ENTRY (ADDR, EXP_HOST, EXP_PORT, false, EXP_AI_FAMILY, \
EXP_AI_SOCKTYPE, EXP_AI_PROTOCOL)
/* Initialize an entry prefixed with "tcp4:". */
-#define INIT_PREFIXED_IPV4_TCP(ADDR, EXP_HOST, EXP_PORT) \
+#define INIT_PREFIXED_IPV4_TCP(ADDR, EXP_HOST, EXP_PORT) \
INIT_PREFIXED_ENTRY (ADDR, EXP_HOST, EXP_PORT, AF_INET, SOCK_STREAM, \
IPPROTO_TCP)
/* Initialize an entry prefixed with "tcp6:". */
-#define INIT_PREFIXED_IPV6_TCP(ADDR, EXP_HOST, EXP_PORT) \
+#define INIT_PREFIXED_IPV6_TCP(ADDR, EXP_HOST, EXP_PORT) \
INIT_PREFIXED_ENTRY (ADDR, EXP_HOST, EXP_PORT, AF_INET6, SOCK_STREAM, \
IPPROTO_TCP)
/* Initialize an entry prefixed with "udp4:". */
-#define INIT_PREFIXED_IPV4_UDP(ADDR, EXP_HOST, EXP_PORT) \
+#define INIT_PREFIXED_IPV4_UDP(ADDR, EXP_HOST, EXP_PORT) \
INIT_PREFIXED_ENTRY (ADDR, EXP_HOST, EXP_PORT, AF_INET, SOCK_DGRAM, \
IPPROTO_UDP)
/* Initialize an entry prefixed with "udp6:". */
-#define INIT_PREFIXED_IPV6_UDP(ADDR, EXP_HOST, EXP_PORT) \
+#define INIT_PREFIXED_IPV6_UDP(ADDR, EXP_HOST, EXP_PORT) \
INIT_PREFIXED_ENTRY (ADDR, EXP_HOST, EXP_PORT, AF_INET6, SOCK_DGRAM, \
IPPROTO_UDP)
/* Initialize a bogus entry, i.e., a connection spec that should
fail. */
-#define INIT_BOGUS_ENTRY(ADDR) \
- INIT_ENTRY (ADDR, "", "", true, 0, 0, 0)
+#define INIT_BOGUS_ENTRY(ADDR) INIT_ENTRY (ADDR, "", "", true, 0, 0, 0)
/* The variable which holds all of our tests. */
-static const parse_conn_test conn_test[] =
- {
- /* Unprefixed addresses. */
-
- /* IPv4, host and port present. */
- INIT_UNPREFIXED_ENTRY ("127.0.0.1:1234", "127.0.0.1", "1234"),
- /* IPv4, only host. */
- INIT_UNPREFIXED_ENTRY ("127.0.0.1", "127.0.0.1", ""),
- /* IPv4, missing port. */
- INIT_UNPREFIXED_ENTRY ("127.0.0.1:", "127.0.0.1", ""),
-
- /* IPv6, host and port present, no brackets. */
- INIT_UNPREFIXED_ENTRY ("::1:1234", "::1", "1234"),
- /* IPv6, missing port, no brackets. */
- INIT_UNPREFIXED_ENTRY ("::1:", "::1", ""),
- /* IPv6, host and port present, with brackets. */
- INIT_UNPREFIXED_IPV6_ENTRY ("[::1]:1234", "::1", "1234"),
- /* IPv6, only host, with brackets. */
- INIT_UNPREFIXED_IPV6_ENTRY ("[::1]", "::1", ""),
- /* IPv6, missing port, with brackets. */
- INIT_UNPREFIXED_IPV6_ENTRY ("[::1]:", "::1", ""),
-
- /* Unspecified, only port. */
- INIT_UNPREFIXED_ENTRY (":1234", "localhost", "1234"),
-
- /* Prefixed addresses. */
-
- /* Prefixed "tcp4:" IPv4, host and port presents. */
- INIT_PREFIXED_IPV4_TCP ("tcp4:127.0.0.1:1234", "127.0.0.1", "1234"),
- /* Prefixed "tcp4:" IPv4, only port. */
- INIT_PREFIXED_IPV4_TCP ("tcp4::1234", "localhost", "1234"),
- /* Prefixed "tcp4:" IPv4, only host. */
- INIT_PREFIXED_IPV4_TCP ("tcp4:127.0.0.1", "127.0.0.1", ""),
- /* Prefixed "tcp4:" IPv4, missing port. */
- INIT_PREFIXED_IPV4_TCP ("tcp4:127.0.0.1:", "127.0.0.1", ""),
-
- /* Prefixed "udp4:" IPv4, host and port present. */
- INIT_PREFIXED_IPV4_UDP ("udp4:127.0.0.1:1234", "127.0.0.1", "1234"),
- /* Prefixed "udp4:" IPv4, only port. */
- INIT_PREFIXED_IPV4_UDP ("udp4::1234", "localhost", "1234"),
- /* Prefixed "udp4:" IPv4, only host. */
- INIT_PREFIXED_IPV4_UDP ("udp4:127.0.0.1", "127.0.0.1", ""),
- /* Prefixed "udp4:" IPv4, missing port. */
- INIT_PREFIXED_IPV4_UDP ("udp4:127.0.0.1:", "127.0.0.1", ""),
-
-
- /* Prefixed "tcp6:" IPv6, host and port present. */
- INIT_PREFIXED_IPV6_TCP ("tcp6:::1:1234", "::1", "1234"),
- /* Prefixed "tcp6:" IPv6, only port. */
- INIT_PREFIXED_IPV6_TCP ("tcp6::1234", "localhost", "1234"),
- /* Prefixed "tcp6:" IPv6, only host. */
- //INIT_PREFIXED_IPV6_TCP ("tcp6:::1", "::1", ""),
- /* Prefixed "tcp6:" IPv6, missing port. */
- INIT_PREFIXED_IPV6_TCP ("tcp6:::1:", "::1", ""),
-
- /* Prefixed "udp6:" IPv6, host and port present. */
- INIT_PREFIXED_IPV6_UDP ("udp6:::1:1234", "::1", "1234"),
- /* Prefixed "udp6:" IPv6, only port. */
- INIT_PREFIXED_IPV6_UDP ("udp6::1234", "localhost", "1234"),
- /* Prefixed "udp6:" IPv6, only host. */
- //INIT_PREFIXED_IPV6_UDP ("udp6:::1", "::1", ""),
- /* Prefixed "udp6:" IPv6, missing port. */
- INIT_PREFIXED_IPV6_UDP ("udp6:::1:", "::1", ""),
-
- /* Prefixed "tcp6:" IPv6 with brackets, host and port present. */
- INIT_PREFIXED_IPV6_TCP ("tcp6:[::1]:1234", "::1", "1234"),
- /* Prefixed "tcp6:" IPv6 with brackets, only host. */
- INIT_PREFIXED_IPV6_TCP ("tcp6:[::1]", "::1", ""),
- /* Prefixed "tcp6:" IPv6 with brackets, missing port. */
- INIT_PREFIXED_IPV6_TCP ("tcp6:[::1]:", "::1", ""),
-
- /* Prefixed "udp6:" IPv6 with brackets, host and port present. */
- INIT_PREFIXED_IPV6_UDP ("udp6:[::1]:1234", "::1", "1234"),
- /* Prefixed "udp6:" IPv6 with brackets, only host. */
- INIT_PREFIXED_IPV6_UDP ("udp6:[::1]", "::1", ""),
- /* Prefixed "udp6:" IPv6 with brackets, missing port. */
- INIT_PREFIXED_IPV6_UDP ("udp6:[::1]:", "::1", ""),
-
-
- /* Bogus addresses. */
- INIT_BOGUS_ENTRY ("tcp6:[::1]123:44"),
- INIT_BOGUS_ENTRY ("[::1"),
- INIT_BOGUS_ENTRY ("tcp6:::1]:"),
- };
+static const parse_conn_test conn_test[] = {
+ /* Unprefixed addresses. */
+
+ /* IPv4, host and port present. */
+ INIT_UNPREFIXED_ENTRY ("127.0.0.1:1234", "127.0.0.1", "1234"),
+ /* IPv4, only host. */
+ INIT_UNPREFIXED_ENTRY ("127.0.0.1", "127.0.0.1", ""),
+ /* IPv4, missing port. */
+ INIT_UNPREFIXED_ENTRY ("127.0.0.1:", "127.0.0.1", ""),
+
+ /* IPv6, host and port present, no brackets. */
+ INIT_UNPREFIXED_ENTRY ("::1:1234", "::1", "1234"),
+ /* IPv6, missing port, no brackets. */
+ INIT_UNPREFIXED_ENTRY ("::1:", "::1", ""),
+ /* IPv6, host and port present, with brackets. */
+ INIT_UNPREFIXED_IPV6_ENTRY ("[::1]:1234", "::1", "1234"),
+ /* IPv6, only host, with brackets. */
+ INIT_UNPREFIXED_IPV6_ENTRY ("[::1]", "::1", ""),
+ /* IPv6, missing port, with brackets. */
+ INIT_UNPREFIXED_IPV6_ENTRY ("[::1]:", "::1", ""),
+
+ /* Unspecified, only port. */
+ INIT_UNPREFIXED_ENTRY (":1234", "localhost", "1234"),
+
+ /* Prefixed addresses. */
+
+ /* Prefixed "tcp4:" IPv4, host and port presents. */
+ INIT_PREFIXED_IPV4_TCP ("tcp4:127.0.0.1:1234", "127.0.0.1", "1234"),
+ /* Prefixed "tcp4:" IPv4, only port. */
+ INIT_PREFIXED_IPV4_TCP ("tcp4::1234", "localhost", "1234"),
+ /* Prefixed "tcp4:" IPv4, only host. */
+ INIT_PREFIXED_IPV4_TCP ("tcp4:127.0.0.1", "127.0.0.1", ""),
+ /* Prefixed "tcp4:" IPv4, missing port. */
+ INIT_PREFIXED_IPV4_TCP ("tcp4:127.0.0.1:", "127.0.0.1", ""),
+
+ /* Prefixed "udp4:" IPv4, host and port present. */
+ INIT_PREFIXED_IPV4_UDP ("udp4:127.0.0.1:1234", "127.0.0.1", "1234"),
+ /* Prefixed "udp4:" IPv4, only port. */
+ INIT_PREFIXED_IPV4_UDP ("udp4::1234", "localhost", "1234"),
+ /* Prefixed "udp4:" IPv4, only host. */
+ INIT_PREFIXED_IPV4_UDP ("udp4:127.0.0.1", "127.0.0.1", ""),
+ /* Prefixed "udp4:" IPv4, missing port. */
+ INIT_PREFIXED_IPV4_UDP ("udp4:127.0.0.1:", "127.0.0.1", ""),
+
+ /* Prefixed "tcp6:" IPv6, host and port present. */
+ INIT_PREFIXED_IPV6_TCP ("tcp6:::1:1234", "::1", "1234"),
+ /* Prefixed "tcp6:" IPv6, only port. */
+ INIT_PREFIXED_IPV6_TCP ("tcp6::1234", "localhost", "1234"),
+ /* Prefixed "tcp6:" IPv6, only host. */
+ //INIT_PREFIXED_IPV6_TCP ("tcp6:::1", "::1", ""),
+ /* Prefixed "tcp6:" IPv6, missing port. */
+ INIT_PREFIXED_IPV6_TCP ("tcp6:::1:", "::1", ""),
+
+ /* Prefixed "udp6:" IPv6, host and port present. */
+ INIT_PREFIXED_IPV6_UDP ("udp6:::1:1234", "::1", "1234"),
+ /* Prefixed "udp6:" IPv6, only port. */
+ INIT_PREFIXED_IPV6_UDP ("udp6::1234", "localhost", "1234"),
+ /* Prefixed "udp6:" IPv6, only host. */
+ //INIT_PREFIXED_IPV6_UDP ("udp6:::1", "::1", ""),
+ /* Prefixed "udp6:" IPv6, missing port. */
+ INIT_PREFIXED_IPV6_UDP ("udp6:::1:", "::1", ""),
+
+ /* Prefixed "tcp6:" IPv6 with brackets, host and port present. */
+ INIT_PREFIXED_IPV6_TCP ("tcp6:[::1]:1234", "::1", "1234"),
+ /* Prefixed "tcp6:" IPv6 with brackets, only host. */
+ INIT_PREFIXED_IPV6_TCP ("tcp6:[::1]", "::1", ""),
+ /* Prefixed "tcp6:" IPv6 with brackets, missing port. */
+ INIT_PREFIXED_IPV6_TCP ("tcp6:[::1]:", "::1", ""),
+
+ /* Prefixed "udp6:" IPv6 with brackets, host and port present. */
+ INIT_PREFIXED_IPV6_UDP ("udp6:[::1]:1234", "::1", "1234"),
+ /* Prefixed "udp6:" IPv6 with brackets, only host. */
+ INIT_PREFIXED_IPV6_UDP ("udp6:[::1]", "::1", ""),
+ /* Prefixed "udp6:" IPv6 with brackets, missing port. */
+ INIT_PREFIXED_IPV6_UDP ("udp6:[::1]:", "::1", ""),
+
+ /* Bogus addresses. */
+ INIT_BOGUS_ENTRY ("tcp6:[::1]123:44"),
+ INIT_BOGUS_ENTRY ("[::1"),
+ INIT_BOGUS_ENTRY ("tcp6:::1]:"),
+};
/* Test a connection spec C. */
@@ -240,6 +240,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_parse_connection_spec_selftests ();
+
void
_initialize_parse_connection_spec_selftests ()
{
diff --git a/gdb/unittests/path-join-selftests.c b/gdb/unittests/path-join-selftests.c
index c41396f..26355b6 100644
--- a/gdb/unittests/path-join-selftests.c
+++ b/gdb/unittests/path-join-selftests.c
@@ -21,10 +21,12 @@
#include "gdbsupport/pathstuff.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace path_join {
+namespace selftests
+{
+namespace path_join
+{
-template <typename ...Args>
+template<typename... Args>
static void
test_one (const char *expected, Args... paths)
{
@@ -61,13 +63,13 @@ test ()
#endif /* _WIN32 */
}
-}
-}
+} // namespace path_join
+} // namespace selftests
void _initialize_path_join_selftests ();
+
void
_initialize_path_join_selftests ()
{
- selftests::register_test ("path_join",
- selftests::path_join::test);
+ selftests::register_test ("path_join", selftests::path_join::test);
}
diff --git a/gdb/unittests/ptid-selftests.c b/gdb/unittests/ptid-selftests.c
index 5af73b0..c634a26 100644
--- a/gdb/unittests/ptid-selftests.c
+++ b/gdb/unittests/ptid-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/ptid.h"
#include <type_traits>
-namespace selftests {
-namespace ptid {
+namespace selftests
+{
+namespace ptid
+{
/* Check that the ptid_t class is POD.
@@ -125,7 +127,8 @@ static_assert (both.matches (pid), "both matches pid");
static_assert (!ptid_t (2, 0, 0).matches (pid), "other pid doesn't match pid");
static_assert (!ptid_t (2, 2, 0).matches (pid), "other lwp doesn't match pid");
static_assert (!ptid_t (2, 0, 2).matches (pid), "other tid doesn't match pid");
-static_assert (!ptid_t (2, 2, 2).matches (pid), "other both doesn't match pid");
+static_assert (!ptid_t (2, 2, 2).matches (pid),
+ "other both doesn't match pid");
/* Verify matches against exact matches. */
@@ -148,6 +151,5 @@ static_assert (both.matches (both), "both matches both");
static_assert (!ptid_t (2, 2, 2).matches (both),
"other both doesn't match both");
-
} /* namespace ptid */
} /* namespace selftests */
diff --git a/gdb/unittests/rsp-low-selftests.c b/gdb/unittests/rsp-low-selftests.c
index 6e0c90e..5a98525 100644
--- a/gdb/unittests/rsp-low-selftests.c
+++ b/gdb/unittests/rsp-low-selftests.c
@@ -21,12 +21,15 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/rsp-low.h"
-namespace selftests {
-namespace rsp_low {
+namespace selftests
+{
+namespace rsp_low
+{
/* Test the variant of hex2bin that returns a byte_vector. */
-static void test_hex2bin_byte_vector ()
+static void
+test_hex2bin_byte_vector ()
{
gdb::byte_vector bv;
@@ -48,7 +51,8 @@ static void test_hex2bin_byte_vector ()
SELF_CHECK (bv[1] == 0x23);
}
-static void test_hex2str ()
+static void
+test_hex2str ()
{
SELF_CHECK (hex2str ("666f6f") == "foo");
SELF_CHECK (hex2str ("666f6fa") == "foo");
@@ -62,11 +66,11 @@ static void test_hex2str ()
} /* namespace selftests */
void _initialize_rsp_low_selftests ();
+
void
_initialize_rsp_low_selftests ()
{
selftests::register_test ("hex2bin_byte_vector",
selftests::rsp_low::test_hex2bin_byte_vector);
- selftests::register_test ("hex2str",
- selftests::rsp_low::test_hex2str);
+ selftests::register_test ("hex2str", selftests::rsp_low::test_hex2str);
}
diff --git a/gdb/unittests/scoped_fd-selftests.c b/gdb/unittests/scoped_fd-selftests.c
index 409f2be..cfc54da 100644
--- a/gdb/unittests/scoped_fd-selftests.c
+++ b/gdb/unittests/scoped_fd-selftests.c
@@ -24,8 +24,10 @@
#include "config.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace scoped_fd {
+namespace selftests
+{
+namespace scoped_fd
+{
/* Test that the file descriptor is closed. */
static void
@@ -75,7 +77,7 @@ test_to_file ()
SELF_CHECK (sfd.get () >= 0);
unlink (filename);
-
+
gdb_file_up file = sfd.to_file ("rw");
SELF_CHECK (file != nullptr);
SELF_CHECK (sfd.get () == -1);
@@ -94,9 +96,9 @@ run_tests ()
} /* namespace selftests */
void _initialize_scoped_fd_selftests ();
+
void
_initialize_scoped_fd_selftests ()
{
- selftests::register_test ("scoped_fd",
- selftests::scoped_fd::run_tests);
+ selftests::register_test ("scoped_fd", selftests::scoped_fd::run_tests);
}
diff --git a/gdb/unittests/scoped_ignore_signal-selftests.c b/gdb/unittests/scoped_ignore_signal-selftests.c
index c8bb1ec..421eda7 100644
--- a/gdb/unittests/scoped_ignore_signal-selftests.c
+++ b/gdb/unittests/scoped_ignore_signal-selftests.c
@@ -24,8 +24,10 @@
#include <unistd.h>
#include <signal.h>
-namespace selftests {
-namespace scoped_ignore_sig {
+namespace selftests
+{
+namespace scoped_ignore_sig
+{
#ifdef SIGPIPE
@@ -46,7 +48,10 @@ static void
test_sigpipe ()
{
auto *osig = signal (SIGPIPE, handle_sigpipe);
- SCOPE_EXIT { signal (SIGPIPE, osig); };
+ SCOPE_EXIT
+ {
+ signal (SIGPIPE, osig);
+ };
#ifdef HAVE_SIGPROCMASK
/* Make sure SIGPIPE isn't blocked. */
@@ -54,7 +59,10 @@ test_sigpipe ()
sigemptyset (&set);
sigaddset (&set, SIGPIPE);
sigprocmask (SIG_UNBLOCK, &set, &old_state);
- SCOPE_EXIT { sigprocmask (SIG_SETMASK, &old_state, nullptr); };
+ SCOPE_EXIT
+ {
+ sigprocmask (SIG_SETMASK, &old_state, nullptr);
+ };
#endif
/* Create pipe, and close read end so that writes to the pipe fail
@@ -68,18 +76,19 @@ test_sigpipe ()
SELF_CHECK (r == 0);
close (fd[0]);
- SCOPE_EXIT { close (fd[1]); };
+ SCOPE_EXIT
+ {
+ close (fd[1]);
+ };
/* Check that writing to the pipe results in EPIPE. EXPECT_SIG
indicates whether a SIGPIPE signal is expected. */
- auto check_pipe_write = [&] (bool expect_sig)
- {
+ auto check_pipe_write = [&] (bool expect_sig) {
got_sigpipe = 0;
errno = 0;
r = write (fd[1], &c, 1);
- SELF_CHECK (r == -1 && errno == EPIPE
- && got_sigpipe == expect_sig);
+ SELF_CHECK (r == -1 && errno == EPIPE && got_sigpipe == expect_sig);
};
/* Check that without a scoped_ignore_sigpipe in scope we indeed get
@@ -116,6 +125,7 @@ test_sigpipe ()
} /* namespace selftests */
void _initialize_scoped_ignore_signal_selftests ();
+
void
_initialize_scoped_ignore_signal_selftests ()
{
diff --git a/gdb/unittests/scoped_mmap-selftests.c b/gdb/unittests/scoped_mmap-selftests.c
index a8f507c..d897f14 100644
--- a/gdb/unittests/scoped_mmap-selftests.c
+++ b/gdb/unittests/scoped_mmap-selftests.c
@@ -30,8 +30,10 @@
#include <unistd.h>
-namespace selftests {
-namespace scoped_mmap {
+namespace selftests
+{
+namespace scoped_mmap
+{
/* Test that the file is unmapped. */
static void
@@ -113,16 +115,18 @@ test_invalid_filename ()
{
bool threw = false;
- try {
+ try
+ {
::scoped_mmap m = ::mmap_file ("/this/file/should/not/exist");
- } catch (gdb_exception &e) {
+ }
+ catch (gdb_exception &e)
+ {
threw = true;
- }
+ }
SELF_CHECK (threw);
}
-
/* Run selftests. */
static void
run_tests ()
@@ -137,13 +141,12 @@ run_tests ()
#endif /* !defined(HAVE_SYS_MMAN_H) */
void _initialize_scoped_mmap_selftests ();
+
void
_initialize_scoped_mmap_selftests ()
{
#if defined(HAVE_SYS_MMAN_H)
- selftests::register_test ("scoped_mmap",
- selftests::scoped_mmap::run_tests);
- selftests::register_test ("mmap_file",
- selftests::mmap_file::run_tests);
+ selftests::register_test ("scoped_mmap", selftests::scoped_mmap::run_tests);
+ selftests::register_test ("mmap_file", selftests::mmap_file::run_tests);
#endif
}
diff --git a/gdb/unittests/scoped_restore-selftests.c b/gdb/unittests/scoped_restore-selftests.c
index a21fba5..0bfdca5 100644
--- a/gdb/unittests/scoped_restore-selftests.c
+++ b/gdb/unittests/scoped_restore-selftests.c
@@ -21,11 +21,18 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/scoped_restore.h"
-namespace selftests {
-namespace scoped_restore_tests {
+namespace selftests
+{
+namespace scoped_restore_tests
+{
+
+struct Base
+{
+};
-struct Base {};
-struct Derived : Base {};
+struct Derived : Base
+{
+};
static int global;
@@ -104,6 +111,7 @@ run_tests ()
} /* namespace selftests */
void _initialize_scoped_restore_selftests ();
+
void
_initialize_scoped_restore_selftests ()
{
diff --git a/gdb/unittests/search-memory-selftests.c b/gdb/unittests/search-memory-selftests.c
index 954b2e3..4addb78 100644
--- a/gdb/unittests/search-memory-selftests.c
+++ b/gdb/unittests/search-memory-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/search.h"
-namespace selftests {
-namespace search_memory_tests {
+namespace selftests
+{
+namespace search_memory_tests
+{
static void
run_tests ()
@@ -34,22 +36,21 @@ run_tests ()
bool read_fully = false;
bool read_off_end = false;
- auto read_memory = [&] (CORE_ADDR from, gdb_byte *out, size_t len)
- {
- if (from + len > data.size ())
- read_off_end = true;
- else
- memcpy (out, &data[from], len);
- if (from + len == data.size ())
- read_fully = true;
- return true;
- };
+ auto read_memory = [&] (CORE_ADDR from, gdb_byte *out, size_t len) {
+ if (from + len > data.size ())
+ read_off_end = true;
+ else
+ memcpy (out, &data[from], len);
+ if (from + len == data.size ())
+ read_fully = true;
+ return true;
+ };
gdb_byte pattern = 'x';
CORE_ADDR addr = 0;
- int result = simple_search_memory (read_memory, 0, data.size (),
- &pattern, 1, &addr);
+ int result
+ = simple_search_memory (read_memory, 0, data.size (), &pattern, 1, &addr);
/* In this case we don't care if read_fully was set or not. */
SELF_CHECK (result == 1);
SELF_CHECK (!read_off_end);
@@ -59,8 +60,8 @@ run_tests ()
read_fully = false;
read_off_end = false;
pattern = 'q';
- result = simple_search_memory (read_memory, 0, data.size (),
- &pattern, 1, &addr);
+ result
+ = simple_search_memory (read_memory, 0, data.size (), &pattern, 1, &addr);
SELF_CHECK (result == 0);
SELF_CHECK (!read_off_end);
SELF_CHECK (read_fully);
@@ -74,11 +75,10 @@ run_tests ()
const CORE_ADDR found_addr = 0x837bac8;
memcpy (&data[found_addr - base_addr], wpattern, sizeof (wpattern));
- auto read_memory_2 = [&] (CORE_ADDR from, gdb_byte *out, size_t len)
- {
- memcpy (out, &data[from - base_addr], len);
- return true;
- };
+ auto read_memory_2 = [&] (CORE_ADDR from, gdb_byte *out, size_t len) {
+ memcpy (out, &data[from - base_addr], len);
+ return true;
+ };
result = simple_search_memory (read_memory_2, base_addr, data.size (),
wpattern, sizeof (wpattern), &addr);
@@ -89,8 +89,8 @@ run_tests ()
} /* namespace search_memory_tests */
} /* namespace selftests */
-
void _initialize_search_memory_selftests ();
+
void
_initialize_search_memory_selftests ()
{
diff --git a/gdb/unittests/string_view-selftests.c b/gdb/unittests/string_view-selftests.c
index cf43d29..f9d3c3c 100644
--- a/gdb/unittests/string_view-selftests.c
+++ b/gdb/unittests/string_view-selftests.c
@@ -52,8 +52,10 @@ DIAGNOSTIC_POP
gdb::string_view. */
#define GDB_STRING_VIEW
-namespace selftests {
-namespace string_view {
+namespace selftests
+{
+namespace string_view
+{
/* The actual tests live in separate files, which were originally
copied over from libstdc++'s testsuite. To preserve the structure
@@ -184,6 +186,7 @@ run_tests ()
#endif /* __cplusplus < 201703L */
void _initialize_string_view_selftests ();
+
void
_initialize_string_view_selftests ()
{
diff --git a/gdb/unittests/style-selftests.c b/gdb/unittests/style-selftests.c
index 9a467da..56f8ac2 100644
--- a/gdb/unittests/style-selftests.c
+++ b/gdb/unittests/style-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "ui-style.h"
-namespace selftests {
-namespace style {
+namespace selftests
+{
+namespace style
+{
#define CHECK_RGB(R, G, B) \
SELF_CHECK (rgb[0] == (R) && rgb[1] == (G) && rgb[2] == (B))
@@ -102,9 +104,9 @@ run_tests ()
} /* namespace selftests */
void _initialize_style_selftest ();
+
void
_initialize_style_selftest ()
{
- selftests::register_test ("style",
- selftests::style::run_tests);
+ selftests::register_test ("style", selftests::style::run_tests);
}
diff --git a/gdb/unittests/tracepoint-selftests.c b/gdb/unittests/tracepoint-selftests.c
index 7ae5250..dea4eba 100644
--- a/gdb/unittests/tracepoint-selftests.c
+++ b/gdb/unittests/tracepoint-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "tracepoint.h"
-namespace selftests {
-namespace tracepoint_tests {
+namespace selftests
+{
+namespace tracepoint_tests
+{
static void
test_parse_static_tracepoint_marker_definition ()
@@ -62,10 +64,11 @@ test_parse_static_tracepoint_marker_definition ()
} /* namespace selftests */
void _initialize_tracepoint_selftests ();
+
void
_initialize_tracepoint_selftests ()
{
- selftests::register_test
- ("parse_static_tracepoint_marker_definition",
- selftests::tracepoint_tests::test_parse_static_tracepoint_marker_definition);
+ selftests::register_test ("parse_static_tracepoint_marker_definition",
+ selftests::tracepoint_tests::
+ test_parse_static_tracepoint_marker_definition);
}
diff --git a/gdb/unittests/tui-selftests.c b/gdb/unittests/tui-selftests.c
index e017b71..a73a444 100644
--- a/gdb/unittests/tui-selftests.c
+++ b/gdb/unittests/tui-selftests.c
@@ -24,8 +24,10 @@
#include "tui/tui-winsource.h"
-namespace selftests {
-namespace tui {
+namespace selftests
+{
+namespace tui
+{
static void
run_tests ()
@@ -47,6 +49,7 @@ run_tests ()
#endif /* TUI */
void _initialize_tui_selftest ();
+
void
_initialize_tui_selftest ()
{
diff --git a/gdb/unittests/ui-file-selftests.c b/gdb/unittests/ui-file-selftests.c
index 4e5a471..9078cd8 100644
--- a/gdb/unittests/ui-file-selftests.c
+++ b/gdb/unittests/ui-file-selftests.c
@@ -21,8 +21,10 @@
#include "gdbsupport/selftest.h"
#include "ui-file.h"
-namespace selftests {
-namespace file {
+namespace selftests
+{
+namespace file
+{
static void
check_one (const char *str, int quoter, const char *result)
@@ -35,28 +37,24 @@ check_one (const char *str, int quoter, const char *result)
static void
run_tests ()
{
- check_one ("basic stuff: \\", '\\',
- "basic stuff: \\\\");
- check_one ("more basic stuff: \\Q", 'Q',
- "more basic stuff: \\\\\\Q");
- check_one ("more basic stuff: \\Q", '\0',
- "more basic stuff: \\Q");
+ check_one ("basic stuff: \\", '\\', "basic stuff: \\\\");
+ check_one ("more basic stuff: \\Q", 'Q', "more basic stuff: \\\\\\Q");
+ check_one ("more basic stuff: \\Q", '\0', "more basic stuff: \\Q");
check_one ("weird stuff: \x1f\x90\n\b\t\f\r\033\007", '\\',
"weird stuff: \\037\\220\\n\\b\\t\\f\\r\\e\\a");
scoped_restore save_7 = make_scoped_restore (&sevenbit_strings, true);
- check_one ("more weird stuff: \xa5", '\\',
- "more weird stuff: \\245");
+ check_one ("more weird stuff: \xa5", '\\', "more weird stuff: \\245");
}
} /* namespace file*/
} /* namespace selftests */
void _initialize_ui_file_selftest ();
+
void
_initialize_ui_file_selftest ()
{
- selftests::register_test ("ui-file",
- selftests::file::run_tests);
+ selftests::register_test ("ui-file", selftests::file::run_tests);
}
diff --git a/gdb/unittests/unique_xmalloc_ptr_char.c b/gdb/unittests/unique_xmalloc_ptr_char.c
index aa8a0de..dccf14c 100644
--- a/gdb/unittests/unique_xmalloc_ptr_char.c
+++ b/gdb/unittests/unique_xmalloc_ptr_char.c
@@ -22,8 +22,10 @@
#include "selftest-arch.h"
#include "gdbsupport/gdb_unique_ptr.h"
-namespace selftests {
-namespace unpack {
+namespace selftests
+{
+namespace unpack
+{
static void
unique_xmalloc_ptr_char ()
@@ -45,10 +47,11 @@ unique_xmalloc_ptr_char ()
SELF_CHECK (str == "xxxabcdef");
}
-}
-}
+} // namespace unpack
+} // namespace selftests
void _initialize_unique_xmalloc_ptr_char ();
+
void
_initialize_unique_xmalloc_ptr_char ()
{
diff --git a/gdb/unittests/unpack-selftests.c b/gdb/unittests/unpack-selftests.c
index 51e8c39..301b90c 100644
--- a/gdb/unittests/unpack-selftests.c
+++ b/gdb/unittests/unpack-selftests.c
@@ -24,16 +24,18 @@
#include "gdbtypes.h"
#include "arch-utils.h"
-namespace selftests {
-namespace unpack {
+namespace selftests
+{
+namespace unpack
+{
static void
unpack_field_as_long_tests (struct gdbarch *arch)
{
gdb_byte buffer[8];
const struct builtin_type *bt = builtin_type (arch);
- struct type *struct_type = arch_composite_type (arch, "<<selftest>>",
- TYPE_CODE_STRUCT);
+ struct type *struct_type
+ = arch_composite_type (arch, "<<selftest>>", TYPE_CODE_STRUCT);
append_composite_type_field (struct_type, "field0", bt->builtin_int8);
append_composite_type_field_aligned (struct_type, "field1",
@@ -50,13 +52,14 @@ unpack_field_as_long_tests (struct gdbarch *arch)
SELF_CHECK (unpack_field_as_long (struct_type, buffer, 1) == 23);
}
-}
-}
+} // namespace unpack
+} // namespace selftests
void _initialize_unpack_selftests ();
+
void
_initialize_unpack_selftests ()
{
- selftests::register_test_foreach_arch
- ("unpack_field_as_long", selftests::unpack::unpack_field_as_long_tests);
+ selftests::register_test_foreach_arch (
+ "unpack_field_as_long", selftests::unpack::unpack_field_as_long_tests);
}
diff --git a/gdb/unittests/utils-selftests.c b/gdb/unittests/utils-selftests.c
index 70609aa..a01bbc7 100644
--- a/gdb/unittests/utils-selftests.c
+++ b/gdb/unittests/utils-selftests.c
@@ -21,20 +21,21 @@
#include "utils.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace utils {
+namespace selftests
+{
+namespace utils
+{
static void
test_substitute_path_component ()
{
auto test = [] (std::string s, const char *from, const char *to,
- const char *expected)
- {
- char *temp = xstrdup (s.c_str ());
- substitute_path_component (&temp, from, to);
- SELF_CHECK (strcmp (temp, expected) == 0);
- xfree (temp);
- };
+ const char *expected) {
+ char *temp = xstrdup (s.c_str ());
+ substitute_path_component (&temp, from, to);
+ SELF_CHECK (strcmp (temp, expected) == 0);
+ xfree (temp);
+ };
test ("/abc/$def/g", "abc", "xyz", "/xyz/$def/g");
test ("abc/$def/g", "abc", "xyz", "xyz/$def/g");
@@ -48,10 +49,11 @@ test_substitute_path_component ()
test ("/abc/$def/abc", "abc", "xyz", "/xyz/$def/xyz");
}
-}
-}
+} // namespace utils
+} // namespace selftests
void _initialize_utils_selftests ();
+
void
_initialize_utils_selftests ()
{
diff --git a/gdb/unittests/vec-utils-selftests.c b/gdb/unittests/vec-utils-selftests.c
index 246631f..061d60a 100644
--- a/gdb/unittests/vec-utils-selftests.c
+++ b/gdb/unittests/vec-utils-selftests.c
@@ -22,8 +22,10 @@
#include "gdbsupport/gdb_vecs.h"
-namespace selftests {
-namespace vector_utils_tests {
+namespace selftests
+{
+namespace vector_utils_tests
+{
static void
unordered_remove_tests ()
@@ -38,19 +40,16 @@ unordered_remove_tests ()
{
std::vector<void *> var;
- obj() = default;
+ obj () = default;
/* gcc complains if we provide an assignment operator but no copy
constructor, so provide one even if don't really care for this test. */
- obj(const obj &other)
- {
- this->var = other.var;
- }
+ obj (const obj &other) { this->var = other.var; }
obj &operator= (const obj &other)
{
if (this == &other)
- error (_("detected self move assign"));
+ error (_ ("detected self move assign"));
this->var = other.var;
return *this;
}
@@ -64,13 +63,13 @@ unordered_remove_tests ()
}
} /* namespace vector_utils_tests */
-} /* amespace selftests */
+} // namespace selftests
void _initialize_vec_utils_selftests ();
+
void
_initialize_vec_utils_selftests ()
{
- selftests::register_test
- ("unordered_remove",
- selftests::vector_utils_tests::unordered_remove_tests);
+ selftests::register_test (
+ "unordered_remove", selftests::vector_utils_tests::unordered_remove_tests);
}
diff --git a/gdb/unittests/xml-utils-selftests.c b/gdb/unittests/xml-utils-selftests.c
index eefe2c6..c1c054d 100644
--- a/gdb/unittests/xml-utils-selftests.c
+++ b/gdb/unittests/xml-utils-selftests.c
@@ -21,19 +21,24 @@
#include "gdbsupport/xml-utils.h"
#include "gdbsupport/selftest.h"
-namespace selftests {
-namespace xml_utils {
+namespace selftests
+{
+namespace xml_utils
+{
-static void test_xml_escape_text ()
+static void
+test_xml_escape_text ()
{
const char *input = "<this isn't=\"xml\"> &";
- const char *expected_output = "&lt;this isn&apos;t=&quot;xml&quot;&gt; &amp;";
+ const char *expected_output
+ = "&lt;this isn&apos;t=&quot;xml&quot;&gt; &amp;";
std::string actual_output = xml_escape_text (input);
SELF_CHECK (actual_output == expected_output);
}
-static void test_xml_escape_text_append ()
+static void
+test_xml_escape_text_append ()
{
/* Make sure that we do indeed append. */
std::string actual_output = "foo<xml>";
@@ -45,10 +50,11 @@ static void test_xml_escape_text_append ()
SELF_CHECK (actual_output == expected_output);
}
-}
-}
+} // namespace xml_utils
+} // namespace selftests
void _initialize_xml_utils ();
+
void
_initialize_xml_utils ()
{