proxygen
MergeTest.cpp File Reference
#include <folly/container/Merge.h>
#include <map>
#include <vector>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Functions

 TEST (MergeTest, NonOverlapping)
 
 TEST (MergeTest, OverlappingInSingleInputRange)
 
 TEST (MergeTest, OverlappingInDifferentInputRange)
 

Function Documentation

TEST ( MergeTest  ,
NonOverlapping   
)

Definition at line 24 of file MergeTest.cpp.

References a, b, c, EXPECT_EQ, i, and folly::merge().

24  {
25  std::vector<int> a = {0, 2, 4, 6};
26  std::vector<int> b = {1, 3, 5, 7};
27  std::vector<int> c;
28 
29  folly::merge(a.begin(), a.end(), b.begin(), b.end(), std::back_inserter(c));
30  EXPECT_EQ(8, c.size());
31  for (size_t i = 0; i < 8; ++i) {
32  EXPECT_EQ(i, c[i]);
33  }
34 }
OutputIt merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp)
Definition: Merge.h:46
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
char a
char c
TEST ( MergeTest  ,
OverlappingInSingleInputRange   
)

Definition at line 36 of file MergeTest.cpp.

References a, b, c, EXPECT_EQ, and folly::merge().

36  {
37  std::vector<std::pair<int, int>> a = {{0, 0}, {0, 1}};
38  std::vector<std::pair<int, int>> b = {{2, 2}, {3, 3}};
39  std::map<int, int> c;
40 
42  a.begin(), a.end(), b.begin(), b.end(), std::inserter(c, c.begin()));
43  EXPECT_EQ(3, c.size());
44 
45  // First value is inserted, second is not
46  EXPECT_EQ(c[0], 0);
47 
48  EXPECT_EQ(c[2], 2);
49  EXPECT_EQ(c[3], 3);
50 }
OutputIt merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp)
Definition: Merge.h:46
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
char a
char c
TEST ( MergeTest  ,
OverlappingInDifferentInputRange   
)

Definition at line 52 of file MergeTest.cpp.

References a, b, c, EXPECT_EQ, and folly::merge().

52  {
53  std::vector<std::pair<int, int>> a = {{0, 0}, {1, 1}};
54  std::vector<std::pair<int, int>> b = {{0, 2}, {3, 3}};
55  std::map<int, int> c;
56 
58  a.begin(), a.end(), b.begin(), b.end(), std::inserter(c, c.begin()));
59  EXPECT_EQ(3, c.size());
60 
61  // Value from a is inserted, value from b is not.
62  EXPECT_EQ(c[0], 0);
63 
64  EXPECT_EQ(c[1], 1);
65  EXPECT_EQ(c[3], 3);
66 }
OutputIt merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp)
Definition: Merge.h:46
char b
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
char a
char c