Add InlineExecutor.cpp to Makefile.am
[folly.git] / folly / test / FBVectorTest.cpp
index 33a164a004efe0379dd05ef1c78f570c7556c8c4..472ce8d72f6779d90feff86efa4f56056db817af 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 //
 // Author: andrei.alexandrescu@fb.com
 
-#include <folly/Foreach.h>
-#include <folly/Traits.h>
-#include <folly/Random.h>
-#include <folly/FBString.h>
 #include <folly/FBVector.h>
 
-#include <gtest/gtest.h>
 #include <list>
 #include <map>
 #include <memory>
+
 #include <boost/random.hpp>
 
+#include <folly/FBString.h>
+#include <folly/Foreach.h>
+#include <folly/Random.h>
+#include <folly/Traits.h>
+#include <folly/portability/GTest.h>
+
 using namespace std;
 using namespace folly;
 
@@ -60,9 +62,9 @@ void Num2String(String& str, Integral /* n */) {
   str.resize(strlen(str.c_str()));
 }
 
-template<class T> T randomObject();
+template <class T> T randomObject();
 
-template<> int randomObject<int>() {
+template <> int randomObject<int>() {
   return random(0, 1024);
 }
 }
@@ -101,11 +103,11 @@ TEST(fbvector, clause_23_3_6_2_6) {
 
 TEST(fbvector, clause_23_3_6_4_ambiguity) {
   fbvector<int> v;
-  fbvector<int>::const_iterator i = v.end();
-  v.insert(i, 10, 20);
+  fbvector<int>::const_iterator it = v.end();
+  v.insert(it, 10, 20);
   EXPECT_EQ(v.size(), 10);
-  FOR_EACH (i, v) {
-    EXPECT_EQ(*i, 20);
+  for (auto i : v) {
+    EXPECT_EQ(i, 20);
   }
 }
 
@@ -268,3 +270,17 @@ TEST(FBVector, shrink_to_fit_after_clear) {
   EXPECT_EQ(fb1.size(), 0);
   EXPECT_EQ(fb1.capacity(), 0);
 }
+
+TEST(FBVector, zero_len) {
+  fbvector<int> fb1(0);
+  fbvector<int> fb2(0, 10);
+  fbvector<int> fb3(std::move(fb1));
+  fbvector<int> fb4;
+  fb4 = std::move(fb2);
+  fbvector<int> fb5 = fb3;
+  fbvector<int> fb6;
+  fb6 = fb4;
+  std::initializer_list<int> il = {};
+  fb6 = il;
+  fbvector<int> fb7(fb6.begin(), fb6.end());
+}