summaryrefslogtreecommitdiff
path: root/gdb/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/unittests')
-rw-r--r--gdb/unittests/intrusive_list-selftests.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index 5497a012dd9..8b2b2d1391e 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -504,6 +504,89 @@ struct intrusive_list_test
}
static void
+ test_splice ()
+ {
+ {
+ /* Two non-empty lists. */
+ item_type a ("a"), b ("b"), c ("c"), d ("d"), e ("e");
+ ListType list1;
+ ListType list2;
+ std::vector<const item_type *> expected;
+
+ list1.push_back (a);
+ list1.push_back (b);
+ list1.push_back (c);
+
+ list2.push_back (d);
+ list2.push_back (e);
+
+ list1.splice (std::move (list2));
+
+ expected = {&a, &b, &c, &d, &e};
+ verify_items (list1, expected);
+
+ expected = {};
+ verify_items (list2, expected);
+ }
+
+ {
+ /* Receiving list empty. */
+ item_type a ("a"), b ("b"), c ("c");
+ ListType list1;
+ ListType list2;
+ std::vector<const item_type *> expected;
+
+ list2.push_back (a);
+ list2.push_back (b);
+ list2.push_back (c);
+
+ list1.splice (std::move (list2));
+
+ expected = {&a, &b, &c};
+ verify_items (list1, expected);
+
+ expected = {};
+ verify_items (list2, expected);
+ }
+
+ {
+ /* Giving list empty. */
+ item_type a ("a"), b ("b"), c ("c");
+ ListType list1;
+ ListType list2;
+ std::vector<const item_type *> expected;
+
+ list1.push_back (a);
+ list1.push_back (b);
+ list1.push_back (c);
+
+ list1.splice (std::move (list2));
+
+ expected = {&a, &b, &c};
+ verify_items (list1, expected);
+
+ expected = {};
+ verify_items (list2, expected);
+ }
+
+ {
+ /* Both lists empty. */
+ item_type a ("a"), b ("b"), c ("c");
+ ListType list1;
+ ListType list2;
+ std::vector<const item_type *> expected;
+
+ list1.splice (std::move (list2));
+
+ expected = {};
+ verify_items (list1, expected);
+
+ expected = {};
+ verify_items (list2, expected);
+ }
+ }
+
+ static void
test_pop_front ()
{
item_type a ("a"), b ("b"), c ("c");
@@ -682,6 +765,7 @@ test_intrusive_list ()
tests.test_push_front ();
tests.test_push_back ();
tests.test_insert ();
+ tests.test_splice ();
tests.test_pop_front ();
tests.test_pop_back ();
tests.test_erase ();