diff options
author | Abseil Team <absl-team@google.com> | 2020-07-16 18:14:20 -0700 |
---|---|---|
committer | vslashg <gfalcon@google.com> | 2020-07-17 10:32:57 -0400 |
commit | 672d9e0aef6e856c1258d0810143d1f202d3204d (patch) | |
tree | 92172f1ada59ee1f98f5cc66c6c920b3f18e91c6 /absl/container/btree_test.cc | |
parent | f624790b7f76ab92fed5ae966abb99a0d455c96f (diff) |
Export of internal Abseil changes
--
d2b7a83bafb90d35b2b7d8eb4177e9d712e8d62c by Gennadiy Rozental <rogeeff@google.com>:
Introduce ABSL specific macros for detecting the usage of sanitizers.
PiperOrigin-RevId: 321687443
--
a41342cc04b1088087dda12d7272aa3835f8e36a by Evan Brown <ezb@google.com>:
Get rid of recursion in clear_and_delete().
PiperOrigin-RevId: 321583786
--
99c6d300b17f186c28867b08cc79f1e55077e88a by Evan Brown <ezb@google.com>:
Code simplification: consolidate methods to erase values/nodes.
Motivation: this will make floating storage work simpler.
- Delete erase_same_node/erase_from_leaf_node/remove_value/remove_values_ignore_children.
- Move node deletion methods inside btree_node.
- Delete three-argument move() and use transfer_n() instead.
- Note: there's still one usage of move (in btree::erase(iterator)) that could use transfer, but I think doing so would add more complexity than it's worth.
PiperOrigin-RevId: 321407673
--
c3efed6c1763190c6b3bccbede9b2989ab21b258 by Evan Brown <ezb@google.com>:
Support heterogeneous insert_or_assign, try_emplace, operator[] for btree_map.
Also do a bit of cleanup:
- Add _impl methods for insert_or_assign/try_emplace.
- Rename some hint iterator params from `position` to `hint`.
PiperOrigin-RevId: 321399557
GitOrigin-RevId: d2b7a83bafb90d35b2b7d8eb4177e9d712e8d62c
Change-Id: Ie2d0c7c3ed197c2b53d475248941392cbad20e59
Diffstat (limited to 'absl/container/btree_test.cc')
-rw-r--r-- | absl/container/btree_test.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc index c580807..67ee752 100644 --- a/absl/container/btree_test.cc +++ b/absl/container/btree_test.cc @@ -2509,6 +2509,39 @@ TEST(Btree, EXPECT_THAT(m2, ElementsAre(Pair(IsEmpty(), 1), Pair(ElementsAre(IsNull()), 2))); } + +TEST(Btree, HeterogeneousTryEmplace) { + absl::btree_map<std::string, int> m; + std::string s = "key"; + absl::string_view sv = s; + m.try_emplace(sv, 1); + EXPECT_EQ(m[s], 1); + + m.try_emplace(m.end(), sv, 2); + EXPECT_EQ(m[s], 1); +} + +TEST(Btree, HeterogeneousOperatorMapped) { + absl::btree_map<std::string, int> m; + std::string s = "key"; + absl::string_view sv = s; + m[sv] = 1; + EXPECT_EQ(m[s], 1); + + m[sv] = 2; + EXPECT_EQ(m[s], 2); +} + +TEST(Btree, HeterogeneousInsertOrAssign) { + absl::btree_map<std::string, int> m; + std::string s = "key"; + absl::string_view sv = s; + m.insert_or_assign(sv, 1); + EXPECT_EQ(m[s], 1); + + m.insert_or_assign(m.end(), sv, 2); + EXPECT_EQ(m[s], 2); +} #endif } // namespace |