diff options
author | Evan Brown <ezb@google.com> | 2022-10-25 11:07:59 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-25 11:08:45 -0700 |
commit | 90184f6cdf914e1e88c719cfbccc15f22bfa11dc (patch) | |
tree | c92f2c1874f7614f8f341a428336f68e75f599b2 /absl/container/btree_test.cc | |
parent | b3e64c416844c3579f90f4b1cc42d8d137f21b0a (diff) |
Improve b-tree error messages when dereferencing invalid iterators.
- Check for invalid generation before checking for other types of invalid iterators.
- Check specifically for dereferencing end() iterators.
PiperOrigin-RevId: 483725646
Change-Id: Ibca19c48b1b242384683580145be8fb9ae707bc8
Diffstat (limited to 'absl/container/btree_test.cc')
-rw-r--r-- | absl/container/btree_test.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc index 6a5351fe..e6d4e360 100644 --- a/absl/container/btree_test.cc +++ b/absl/container/btree_test.cc @@ -3340,6 +3340,14 @@ TEST(Btree, IteratorSubtraction) { } } +#ifndef NDEBUG +TEST(Btree, DereferencingEndIterator) { + absl::btree_set<int> set; + for (int i = 0; i < 1000; ++i) set.insert(i); + EXPECT_DEATH(*set.end(), R"regex(Dereferencing end\(\) iterator)regex"); +} +#endif + } // namespace } // namespace container_internal ABSL_NAMESPACE_END |