Use float literals when initializing float values
[folly.git] / folly / test / PaddedTest.cpp
index b3ea1d4a2a3c42b29d973edeb6062404d69c2b5a..b86e2090dc58de68c7de50e255fb3fcdecb6bf2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 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.
@@ -84,7 +84,7 @@ class IntPaddedTestBase : public ::testing::Test {
 
 class IntPaddedConstTest : public IntPaddedTestBase {
  protected:
-  void SetUp() {
+  void SetUp() override {
     v_.resize(4);
     n_ = 0;
     for (int i = 0; i < 4; i++) {
@@ -181,7 +181,7 @@ class StructPaddedTestBase : public ::testing::Test {
 
 class StructPaddedConstTest : public StructPaddedTestBase {
  protected:
-  void SetUp() {
+  void SetUp() override {
     v_.resize(4);
     n_ = 0;
     for (int i = 0; i < 4; i++) {
@@ -239,3 +239,24 @@ TEST_F(IntAdaptorTest, ResizeConstructor) {
     EXPECT_EQ(42, a[i]);
   }
 }
+
+TEST_F(IntAdaptorTest, SimpleEmplaceBack) {
+  for (int i = 0; i < n_; ++i) {
+    EXPECT_EQ((i == 0), a_.empty());
+    EXPECT_EQ(i, a_.size());
+    a_.emplace_back(i);
+  }
+  EXPECT_EQ(n_, a_.size());
+
+  int k = 0;
+  for (auto it = a_.begin(); it != a_.end(); ++it, ++k) {
+    EXPECT_EQ(k, a_[k]);
+    EXPECT_EQ(k, *it);
+  }
+  EXPECT_EQ(n_, k);
+
+  auto p = a_.move();
+  EXPECT_TRUE(a_.empty());
+  EXPECT_EQ(16, p.second);
+  EXPECT_TRUE(v_ == p.first);
+}