about summary refs log tree commit diff
path: root/absl/container/inlined_vector_test.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2017-12-13T20·02-0800
committerTitus Winters <titus@google.com>2017-12-14T14·04-0500
commit720c017e30339fd1786ce4aac68bc8559736e53f (patch)
treee1ee954f7311f39125b93c91303828e27fc5e4cf /absl/container/inlined_vector_test.cc
parent5fe41affbaab5b9ad4876a6295c78f21a86d862d (diff)
Changes imported from Abseil "staging" branch:
  - a42e9b454ca8be7d021789cdb9bcada07d3e2d3e Merge pull request #57. by Derek Mauro <dmauro@google.com>
  - b1e03838f059c034a6489501804d516326246042 Move the long ostream tests into a separate source file u... by Alex Strelnikov <strel@google.com>
  - 7c56b7dbb05faa7e8653632e00be470331d79cb9 Return reference from absl::InlinedVector::emplace_back(). by Abseil Team <absl-team@google.com>
  - 85b070822b62688ff348d9ad9cc9e230a851f617 Treat \u or \U followed by Unicode surrogate character as... by Abseil Team <absl-team@google.com>

GitOrigin-RevId: a42e9b454ca8be7d021789cdb9bcada07d3e2d3e
Change-Id: I7d8fb68ffd7eb4e9e737f21fbed6d56b71985f94
Diffstat (limited to 'absl/container/inlined_vector_test.cc')
-rw-r--r--absl/container/inlined_vector_test.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc
index 055bca983cac..8527ba1aa008 100644
--- a/absl/container/inlined_vector_test.cc
+++ b/absl/container/inlined_vector_test.cc
@@ -393,6 +393,19 @@ TEST(InlinedVectorTest, Noexcept) {
                 absl::InlinedVector<MoveCanThrow, 2>>::value));
 }
 
+TEST(InlinedVectorTest, EmplaceBack) {
+  absl::InlinedVector<std::pair<std::string, int>, 1> v;
+
+  auto& inlined_element = v.emplace_back("answer", 42);
+  EXPECT_EQ(&inlined_element, &v[0]);
+  EXPECT_EQ(inlined_element.first, "answer");
+  EXPECT_EQ(inlined_element.second, 42);
+
+  auto& allocated_element = v.emplace_back("taxicab", 1729);
+  EXPECT_EQ(&allocated_element, &v[1]);
+  EXPECT_EQ(allocated_element.first, "taxicab");
+  EXPECT_EQ(allocated_element.second, 1729);
+}
 
 TEST(IntVec, Insert) {
   for (int len = 0; len < 20; len++) {