proxygen
ArrayTest.cpp File Reference
#include <folly/container/Array.h>
#include <folly/portability/GTest.h>
#include <string>

Go to the source code of this file.

Functions

 TEST (make_array, base_case)
 
 TEST (make_array, deduce_size_primitive)
 
 TEST (make_array, deduce_size_class)
 
 TEST (make_array, deduce_everything)
 
 TEST (make_array, fixed_common_type)
 
 TEST (make_array, deduced_common_type)
 
 TEST (make_array_with, example)
 

Function Documentation

TEST ( make_array  ,
base_case   
)

Definition at line 23 of file ArrayTest.cpp.

References EXPECT_EQ, and value.

23  {
24  auto arr = make_array<int>();
25  static_assert(
26  is_same<typename decltype(arr)::value_type, int>::value,
27  "Wrong array type");
28  EXPECT_EQ(arr.size(), 0);
29 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TEST ( make_array  ,
deduce_size_primitive   
)

Definition at line 31 of file ArrayTest.cpp.

References EXPECT_EQ, and value.

31  {
32  auto arr = make_array<int>(1, 2, 3, 4, 5);
33  static_assert(
34  is_same<typename decltype(arr)::value_type, int>::value,
35  "Wrong array type");
36  EXPECT_EQ(arr.size(), 5);
37 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TEST ( make_array  ,
deduce_size_class   
)

Definition at line 39 of file ArrayTest.cpp.

References EXPECT_EQ, string, and value.

39  {
40  auto arr = make_array<string>(string{"foo"}, string{"bar"});
41  static_assert(
42  is_same<typename decltype(arr)::value_type, std::string>::value,
43  "Wrong array type");
44  EXPECT_EQ(arr.size(), 2);
45  EXPECT_EQ(arr[1], "bar");
46 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
const char * string
Definition: Conv.cpp:212
TEST ( make_array  ,
deduce_everything   
)

Definition at line 48 of file ArrayTest.cpp.

References EXPECT_EQ, folly::make_array(), string, and value.

48  {
49  auto arr = make_array(string{"foo"}, string{"bar"});
50  static_assert(
51  is_same<typename decltype(arr)::value_type, std::string>::value,
52  "Wrong array type");
53  EXPECT_EQ(arr.size(), 2);
54  EXPECT_EQ(arr[1], "bar");
55 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr array_detail::return_type< D, TList... > make_array(TList &&...t)
Definition: Array.h:56
static const char *const value
Definition: Conv.cpp:50
const char * string
Definition: Conv.cpp:212
TEST ( make_array  ,
fixed_common_type   
)

Definition at line 57 of file ArrayTest.cpp.

References EXPECT_EQ, and value.

57  {
58  auto arr = make_array<double>(1.0, 2.5f, 3, 4, 5);
59  static_assert(
60  is_same<typename decltype(arr)::value_type, double>::value,
61  "Wrong array type");
62  EXPECT_EQ(arr.size(), 5);
63 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TEST ( make_array  ,
deduced_common_type   
)

Definition at line 65 of file ArrayTest.cpp.

References EXPECT_EQ, f, folly::make_array(), and value.

65  {
66  auto arr = make_array(1.0, 2.5f, 3, 4, 5);
67  static_assert(
68  is_same<typename decltype(arr)::value_type, double>::value,
69  "Wrong array type");
70  EXPECT_EQ(arr.size(), 5);
71 }
auto f
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr array_detail::return_type< D, TList... > make_array(TList &&...t)
Definition: Array.h:56
static const char *const value
Definition: Conv.cpp:50
TEST ( make_array_with  ,
example   
)

Definition at line 73 of file ArrayTest.cpp.

References EXPECT_EQ, folly::array_detail::make_array_with(), and folly::make_array_with().

73  {
74  struct make_item {
75  constexpr int operator()(size_t index) const {
76  return index + 4;
77  }
78  };
80  using folly::array_detail::make_array_with; // should not collide
81 
82  constexpr auto actual = make_array_with<3>(make_item{});
83  constexpr auto expected = make_array<int>(4, 5, 6);
84  EXPECT_EQ(expected, actual);
85 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
FOLLY_ALWAYS_INLINE FOLLY_ATTR_VISIBILITY_HIDDEN constexpr auto make_array_with(MakeItem const &make, index_sequence< Index... >)
Definition: Array.h:64
constexpr auto make_array_with(MakeItem const &make)
Definition: Array.h:75