]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use gdb unordered set and map in unit tests
authorTom Tromey <tom@tromey.com>
Tue, 11 Mar 2025 19:49:30 +0000 (13:49 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 18 Mar 2025 11:32:04 +0000 (05:32 -0600)
This changes some unit test code to use gdb:unordered_set and
gdb::unordered_map.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/gdbarch-selftests.c
gdb/unittests/command-def-selftests.c
gdb/unittests/intrusive_list-selftests.c

index 56ecc381505b4368c20609f597e008b12f0e2f24..27b17d172a60aa75b29041ae7a0ff770d3d4a8fe 100644 (file)
@@ -25,8 +25,7 @@
 #include "gdbsupport/def-vector.h"
 #include "gdbarch.h"
 #include "scoped-mock-context.h"
-
-#include <map>
+#include "gdbsupport/unordered_map.h"
 
 namespace selftests {
 
@@ -131,7 +130,7 @@ register_name_test (struct gdbarch *gdbarch)
   scoped_mock_context<test_target_ops> mockctx (gdbarch);
 
   /* Track the number of times each register name appears.  */
-  std::map<const std::string, int> name_counts;
+  gdb::unordered_map<std::string, int> name_counts;
 
   const int num_regs = gdbarch_num_cooked_regs (gdbarch);
   for (auto regnum = 0; regnum < num_regs; regnum++)
index cf51f0d275ab799d2f205d46e1c9e6555bd04108..1579511db1960e582de0098b08f2a9ba879161c8 100644 (file)
@@ -20,8 +20,7 @@
 #include "cli/cli-cmds.h"
 #include "cli/cli-decode.h"
 #include "gdbsupport/selftest.h"
-
-#include <map>
+#include "gdbsupport/unordered_map.h"
 
 namespace selftests {
 
@@ -134,7 +133,7 @@ static unsigned int nr_invalid_prefixcmd = 0;
 
 /* A map associating a list with the prefix leading to it.  */
 
-static std::map<cmd_list_element **, const char *> lists;
+static gdb::unordered_map<cmd_list_element **, const char *> lists;
 
 /* Store each command list in lists, associated with the prefix to reach it.  A
    list must only be found once.
index 0bcfa624ce579f132b59d019828fd060a5e35909..6d624e4954743bea19c20e5cbb6d321b22ca33b7 100644 (file)
@@ -20,7 +20,7 @@
 #include "gdbsupport/intrusive_list.h"
 #include "gdbsupport/owning_intrusive_list.h"
 #include "gdbsupport/selftest.h"
-#include <unordered_set>
+#include "gdbsupport/unordered_set.h"
 
 /* Count of how many item_with_base or item_with_member objects are
    currently alive.  */
@@ -717,7 +717,7 @@ struct intrusive_list_test
     item_type a ("a"), b ("b"), c ("c");
     ListType list;
     std::vector<const item_type *> expected;
-    std::unordered_set<const item_type *> disposer_seen;
+    gdb::unordered_set<const item_type *> disposer_seen;
     int disposer_calls = 0;
 
     list.push_back (a);