aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-04-07 14:51:58 -0600
committerTom Tromey <tom@tromey.com>2023-04-12 14:13:25 -0600
commitfade906daab13c99fc329c1e08447f2aac168b62 (patch)
tree27b2598d43a1d374cba7578e2de40af42b19df91 /gdb/unittests
parent4bbb4dfbed1c3e1df4e06b615e7ebe704186ca50 (diff)
downloadgdb-fade906daab13c99fc329c1e08447f2aac168b62.zip
gdb-fade906daab13c99fc329c1e08447f2aac168b62.tar.gz
gdb-fade906daab13c99fc329c1e08447f2aac168b62.tar.bz2
Use SELF_CHECK in all unit tests
I noticed a few unit tests are using gdb_assert. I think this was an older style, before SELF_CHECK was added. This patch switches them over. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/unittests')
-rw-r--r--gdb/unittests/filtered_iterator-selftests.c20
-rw-r--r--gdb/unittests/intrusive_list-selftests.c60
2 files changed, 40 insertions, 40 deletions
diff --git a/gdb/unittests/filtered_iterator-selftests.c b/gdb/unittests/filtered_iterator-selftests.c
index 6e93a09..2558bb4 100644
--- a/gdb/unittests/filtered_iterator-selftests.c
+++ b/gdb/unittests/filtered_iterator-selftests.c
@@ -59,7 +59,7 @@ struct int_array_iterator
/* If they are both not past-the-end, make sure they iterate on the
same array (we shouldn't compare iterators that iterate on different
things). */
- gdb_assert (m_array == other.m_array);
+ SELF_CHECK (m_array == other.m_array);
/* They are equal if they have the same current index. */
return m_cur_idx == other.m_cur_idx;
@@ -73,7 +73,7 @@ struct int_array_iterator
void operator++ ()
{
/* Make sure nothing tries to increment a past the end iterator. */
- gdb_assert (m_cur_idx < m_size);
+ SELF_CHECK (m_cur_idx < m_size);
m_cur_idx++;
@@ -85,7 +85,7 @@ struct int_array_iterator
int operator* () const
{
/* Make sure nothing tries to dereference a past the end iterator. */
- gdb_assert (m_cur_idx < m_size);
+ SELF_CHECK (m_cur_idx < m_size);
return m_array[m_cur_idx];
}
@@ -123,7 +123,7 @@ test_filtered_iterator ()
for (; iter != end; ++iter)
even_ints.push_back (*iter);
- gdb_assert (even_ints == expected_even_ints);
+ SELF_CHECK (even_ints == expected_even_ints);
}
/* Test operator== and operator!=. */
@@ -139,18 +139,18 @@ test_filtered_iterator_eq ()
iter2(array, ARRAY_SIZE (array));
/* They start equal. */
- gdb_assert (iter1 == iter2);
- gdb_assert (!(iter1 != iter2));
+ SELF_CHECK (iter1 == iter2);
+ SELF_CHECK (!(iter1 != iter2));
/* Advance 1, now they aren't equal (despite pointing to equal values). */
++iter1;
- gdb_assert (!(iter1 == iter2));
- gdb_assert (iter1 != iter2);
+ SELF_CHECK (!(iter1 == iter2));
+ SELF_CHECK (iter1 != iter2);
/* Advance 2, now they are equal again. */
++iter2;
- gdb_assert (iter1 == iter2);
- gdb_assert (!(iter1 != iter2));
+ SELF_CHECK (iter1 == iter2);
+ SELF_CHECK (!(iter1 != iter2));
}
} /* namespace selftests */
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index fe47177..1f85b32 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -87,13 +87,13 @@ struct intrusive_list_test
{
const item_type &item = *it;
- gdb_assert (i < expected.size ());
- gdb_assert (&item == expected[i]);
+ SELF_CHECK (i < expected.size ());
+ SELF_CHECK (&item == expected[i]);
++i;
}
- gdb_assert (i == expected.size ());
+ SELF_CHECK (i == expected.size ());
for (typename ListType::reverse_iterator it = list.rbegin ();
it != list.rend ();
@@ -103,11 +103,11 @@ struct intrusive_list_test
--i;
- gdb_assert (i >= 0);
- gdb_assert (&item == expected[i]);
+ SELF_CHECK (i >= 0);
+ SELF_CHECK (&item == expected[i]);
}
- gdb_assert (i == 0);
+ SELF_CHECK (i == 0);
}
static void
@@ -384,10 +384,10 @@ struct intrusive_list_test
list.push_back (b);
list.push_back (c);
- gdb_assert (&list.front () == &a);
- gdb_assert (&clist.front () == &a);
- gdb_assert (&list.back () == &c);
- gdb_assert (&clist.back () == &c);
+ SELF_CHECK (&list.front () == &a);
+ SELF_CHECK (&clist.front () == &a);
+ SELF_CHECK (&list.back () == &c);
+ SELF_CHECK (&clist.back () == &c);
}
static void
@@ -701,14 +701,14 @@ struct intrusive_list_test
expected = {};
verify_items (list, expected);
- gdb_assert (disposer_calls == 3);
- gdb_assert (disposer_seen.find (&a) != disposer_seen.end ());
- gdb_assert (disposer_seen.find (&b) != disposer_seen.end ());
- gdb_assert (disposer_seen.find (&c) != disposer_seen.end ());
+ SELF_CHECK (disposer_calls == 3);
+ SELF_CHECK (disposer_seen.find (&a) != disposer_seen.end ());
+ SELF_CHECK (disposer_seen.find (&b) != disposer_seen.end ());
+ SELF_CHECK (disposer_seen.find (&c) != disposer_seen.end ());
/* Verify idempotency. */
list.clear_and_dispose (disposer);
- gdb_assert (disposer_calls == 3);
+ SELF_CHECK (disposer_calls == 3);
}
static void
@@ -717,11 +717,11 @@ struct intrusive_list_test
item_type a ("a");
ListType list;
- gdb_assert (list.empty ());
+ SELF_CHECK (list.empty ());
list.push_back (a);
- gdb_assert (!list.empty ());
+ SELF_CHECK (!list.empty ());
list.erase (list.iterator_to (a));
- gdb_assert (list.empty ());
+ SELF_CHECK (list.empty ());
}
static void
@@ -735,12 +735,12 @@ struct intrusive_list_test
list.push_back (b);
list.push_back (c);
- gdb_assert (&*list.begin () == &a);
- gdb_assert (&*list.cbegin () == &a);
- gdb_assert (&*clist.begin () == &a);
- gdb_assert (&*list.rbegin () == &c);
- gdb_assert (&*list.crbegin () == &c);
- gdb_assert (&*clist.rbegin () == &c);
+ SELF_CHECK (&*list.begin () == &a);
+ SELF_CHECK (&*list.cbegin () == &a);
+ SELF_CHECK (&*clist.begin () == &a);
+ SELF_CHECK (&*list.rbegin () == &c);
+ SELF_CHECK (&*list.crbegin () == &c);
+ SELF_CHECK (&*clist.rbegin () == &c);
/* At least check that they compile. */
list.end ();
@@ -782,22 +782,22 @@ test_node_is_linked ()
item_with_base a ("a");
item_with_base_list list;
- gdb_assert (!a.is_linked ());
+ SELF_CHECK (!a.is_linked ());
list.push_back (a);
- gdb_assert (a.is_linked ());
+ SELF_CHECK (a.is_linked ());
list.pop_back ();
- gdb_assert (!a.is_linked ());
+ SELF_CHECK (!a.is_linked ());
}
{
item_with_member a ("a");
item_with_member_list list;
- gdb_assert (!a.node.is_linked ());
+ SELF_CHECK (!a.node.is_linked ());
list.push_back (a);
- gdb_assert (a.node.is_linked ());
+ SELF_CHECK (a.node.is_linked ());
list.pop_back ();
- gdb_assert (!a.node.is_linked ());
+ SELF_CHECK (!a.node.is_linked ());
}
}