From 0c03c28a3b7609d218a9acdff099fc0bda0f4ae6 Mon Sep 17 00:00:00 2001 From: Gil Date: Fri, 20 Apr 2018 12:11:19 -0700 Subject: Implement find-related methods on C++ immutable maps (#1145) * Standardize method ordering across sorted maps * Add SortedMap::find * Add SortedMap::find_index * Add SortedMap::contains --- .../firestore/immutable/array_sorted_map_test.cc | 40 ---------------------- 1 file changed, 40 deletions(-) (limited to 'Firestore/core/test/firebase/firestore/immutable/array_sorted_map_test.cc') diff --git a/Firestore/core/test/firebase/firestore/immutable/array_sorted_map_test.cc b/Firestore/core/test/firebase/firestore/immutable/array_sorted_map_test.cc index 9f18f2d..ea8ae6e 100644 --- a/Firestore/core/test/firebase/firestore/immutable/array_sorted_map_test.cc +++ b/Firestore/core/test/firebase/firestore/immutable/array_sorted_map_test.cc @@ -32,14 +32,6 @@ namespace impl { using IntMap = ArraySortedMap; constexpr IntMap::size_type kFixedSize = IntMap::kFixedSize; -TEST(ArraySortedMap, SearchForSpecificKey) { - IntMap map{{1, 3}, {2, 4}}; - - ASSERT_TRUE(Found(map, 1, 3)); - ASSERT_TRUE(Found(map, 2, 4)); - ASSERT_TRUE(NotFound(map, 3)); -} - TEST(ArraySortedMap, RemoveKeyValuePair) { IntMap map{{1, 3}, {2, 4}}; @@ -100,13 +92,6 @@ TEST(ArraySortedMap, RemovesMiddle) { ASSERT_TRUE(Found(s1, 3, 3)); } -TEST(ArraySortedMap, Override) { - IntMap map = IntMap{}.insert(10, 10).insert(10, 8); - - ASSERT_TRUE(Found(map, 10, 8)); - ASSERT_FALSE(Found(map, 10, 10)); -} - TEST(ArraySortedMap, ChecksSize) { std::vector to_insert = Sequence(kFixedSize); IntMap map = ToMap(to_insert); @@ -118,11 +103,6 @@ TEST(ArraySortedMap, ChecksSize) { ASSERT_ANY_THROW(map.insert(next, next)); } -TEST(ArraySortedMap, EmptyGet) { - IntMap map; - EXPECT_TRUE(NotFound(map, 10)); -} - TEST(ArraySortedMap, EmptyRemoval) { IntMap map; IntMap new_map = map.erase(1); @@ -158,26 +138,6 @@ TEST(ArraySortedMap, BalanceProblem) { ASSERT_SEQ_EQ(Pairs(Sorted(to_insert)), map); } -// TODO(wilhuff): Iterators - -// TODO(wilhuff): IndexOf - -TEST(ArraySortedMap, AvoidsCopying) { - IntMap map = IntMap{}.insert(10, 20); - auto found = map.find(10); - ASSERT_NE(found, map.end()); - EXPECT_EQ(20, found->second); - - // Verify that inserting something with equal keys and values just returns - // the same underlying array. - IntMap duped = map.insert(10, 20); - auto duped_found = duped.find(10); - - // If everything worked correctly, the backing array should not have been - // copied and the pointer to the entry with 10 as key should be the same. - EXPECT_EQ(found, duped_found); -} - } // namespace impl } // namespace immutable } // namespace firestore -- cgit v1.2.3