folly copyright 2015 -> copyright 2016
[folly.git] / folly / test / FBVectorTest.cpp
index 74d15054890753e21f607e7ad3c66ca93cb208ec..4fadf2cdbff6763165fca98d156d838fe0b72782 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.
@@ -17,6 +17,7 @@
 //
 // Author: andrei.alexandrescu@fb.com
 
+#include <folly/Foreach.h>
 #include <folly/Traits.h>
 #include <folly/Random.h>
 #include <folly/FBString.h>
@@ -36,8 +37,6 @@ using namespace folly;
 auto static const seed = randomNumberSeed();
 typedef boost::mt19937 RandomT;
 static RandomT rng(seed);
-static const size_t maxString = 100;
-static const bool avoidAliasing = true;
 
 template <class Integral1, class Integral2>
 Integral2 random(Integral1 low, Integral2 up) {
@@ -55,7 +54,7 @@ void randomString(String* toFill, unsigned int maxSize = 1000) {
 }
 
 template <class String, class Integral>
-void Num2String(String& str, Integral n) {
+void Num2String(String& str, Integral /* n */) {
   str.resize(10, '\0');
   sprintf(&str[0], "%ul", 10);
   str.resize(strlen(str.c_str()));
@@ -274,6 +273,16 @@ TEST(FBVector, vector_of_maps) {
   EXPECT_EQ(1, v[1].size());
 }
 
+TEST(FBVector, shrink_to_fit_after_clear) {
+  fbvector<int> fb1;
+  fb1.push_back(42);
+  fb1.push_back(1337);
+  fb1.clear();
+  fb1.shrink_to_fit();
+  EXPECT_EQ(fb1.size(), 0);
+  EXPECT_EQ(fb1.capacity(), 0);
+}
+
 int main(int argc, char** argv) {
   testing::InitGoogleTest(&argc, argv);
   gflags::ParseCommandLineFlags(&argc, &argv, true);