2 * Copyright 2016-present Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include <folly/container/Array.h>
17 #include <folly/portability/GTest.h>
21 using folly::make_array;
23 TEST(make_array, base_case) {
24 auto arr = make_array<int>();
26 is_same<typename decltype(arr)::value_type, int>::value,
28 EXPECT_EQ(arr.size(), 0);
31 TEST(make_array, deduce_size_primitive) {
32 auto arr = make_array<int>(1, 2, 3, 4, 5);
34 is_same<typename decltype(arr)::value_type, int>::value,
36 EXPECT_EQ(arr.size(), 5);
39 TEST(make_array, deduce_size_class) {
40 auto arr = make_array<string>(string{"foo"}, string{"bar"});
42 is_same<typename decltype(arr)::value_type, std::string>::value,
44 EXPECT_EQ(arr.size(), 2);
45 EXPECT_EQ(arr[1], "bar");
48 TEST(make_array, deduce_everything) {
49 auto arr = make_array(string{"foo"}, string{"bar"});
51 is_same<typename decltype(arr)::value_type, std::string>::value,
53 EXPECT_EQ(arr.size(), 2);
54 EXPECT_EQ(arr[1], "bar");
57 TEST(make_array, fixed_common_type) {
58 auto arr = make_array<double>(1.0, 2.5f, 3, 4, 5);
60 is_same<typename decltype(arr)::value_type, double>::value,
62 EXPECT_EQ(arr.size(), 5);
65 TEST(make_array, deduced_common_type) {
66 auto arr = make_array(1.0, 2.5f, 3, 4, 5);
68 is_same<typename decltype(arr)::value_type, double>::value,
70 EXPECT_EQ(arr.size(), 5);