cleanup includes in folly/Format.h
[folly.git] / folly / test / FormatOtherTest.cpp
index c41f1f060798477512322812ae6467c775af96d8..97d2db102e38439d9862f653882b4d336328cc78 100644 (file)
 
 #include <folly/Format.h>
 
+#include <folly/FBVector.h>
 #include <folly/FileUtil.h>
-#include <folly/json.h>
 #include <folly/dynamic.h>
+#include <folly/json.h>
+#include <folly/small_vector.h>
 
 #include <glog/logging.h>
 #include <gflags/gflags.h>
@@ -76,6 +78,28 @@ TEST(FormatOther, dynamic) {
   EXPECT_EQ("(null)", sformat("{}", dynamic(nullptr)));
 }
 
+namespace {
+
+template <class T>
+void testFormatSeq() {
+  T v{10, 20, 30};
+  EXPECT_EQ("30 10", sformat("{0[2]} {0[0]}", v));
+  EXPECT_EQ("0020", sformat("{0[1]:04}", v));
+  EXPECT_EQ("0020", svformat("{1:04}", v));
+  EXPECT_EQ("10 20", svformat("{} {}", v));
+  EXPECT_EQ("10 20 0030", svformat("{} {} {:04}", v));
+}
+
+}  // namespace
+
+TEST(FormatOther, fbvector) {
+  testFormatSeq<fbvector<int>>();
+}
+
+TEST(FormatOther, small_vector) {
+  testFormatSeq<small_vector<int, 2>>();
+}
+
 int main(int argc, char *argv[]) {
   testing::InitGoogleTest(&argc, argv);
   gflags::ParseCommandLineFlags(&argc, &argv, true);