add Synchronized::withLock() methods
[folly.git] / folly / test / sorted_vector_test.cpp
index ca806aa0a01f05584de80809358b2dfb3fcc02b6..d257a4ea4c233c46a9f499fae567db69a539865c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -149,10 +149,12 @@ TEST(SortedVectorTypes, SimpleMapTest) {
   m[32] = 100.0;
   check_invariant(m);
   EXPECT_TRUE(m.count(32) == 1);
+  EXPECT_DOUBLE_EQ(100.0, m.at(32));
   EXPECT_FALSE(m.find(32) == m.end());
   m.erase(32);
   EXPECT_TRUE(m.find(32) == m.end());
   check_invariant(m);
+  EXPECT_THROW(m.at(32), std::out_of_range);
 
   sorted_vector_map<int,float> m2 = m;
   EXPECT_TRUE(m2 == m);
@@ -207,7 +209,7 @@ TEST(SortedVectorTypes, Sizes) {
   typedef sorted_vector_set<int,std::less<int>,
     std::allocator<int>,OneAtATimePolicy> SetT;
   typedef sorted_vector_map<int,int,std::less<int>,
-    std::allocator<int>,OneAtATimePolicy> MapT;
+    std::allocator<std::pair<int,int>>,OneAtATimePolicy> MapT;
 
   EXPECT_EQ(sizeof(SetT), sizeof(std::vector<int>));
   EXPECT_EQ(sizeof(MapT), sizeof(std::vector<std::pair<int,int> >));
@@ -278,7 +280,7 @@ TEST(SortedVectorTypes, GrowthPolicy) {
 
   std::list<CountCopyCtor> v;
   for (int i = 0; i < 20; ++i) {
-    v.push_back(CountCopyCtor(20 + i));
+    v.emplace_back(20 + i);
   }
   a.insert(v.begin(), v.end());
   check_invariant(a);
@@ -300,6 +302,7 @@ TEST(SortedVectorTest, EmptyTest) {
   sorted_vector_map<int,int> emptyMap;
   EXPECT_TRUE(emptyMap.lower_bound(10) == emptyMap.end());
   EXPECT_TRUE(emptyMap.find(10) == emptyMap.end());
+  EXPECT_THROW(emptyMap.at(10), std::out_of_range);
 }
 
 TEST(SortedVectorTest, MoveTest) {