aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests/command-def-selftests.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:36:23 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2023-02-08 15:46:02 -0500
commitc583a2520616c2736cffc389c89a48b159366e6c (patch)
treeb4925f26506fcee96c16119431c01760f05db95d /gdb/unittests/command-def-selftests.c
parentca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff)
downloadgdb-users/simark/clang-format.zip
gdb-users/simark/clang-format.tar.gz
gdb-users/simark/clang-format.tar.bz2
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/unittests/command-def-selftests.c')
-rw-r--r--gdb/unittests/command-def-selftests.c64
1 files changed, 31 insertions, 33 deletions
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);
}