1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 *     Copyright 2017 Couchbase, Inc
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 */
17
18#include <gtest/gtest.h>
19#include <platform/make_array.h>
20#include <platform/sized_buffer.h>
21
22TEST(MakeArrayTest, Basic) {
23    // Just a simple smoke test to make sure its doing sensible things
24    constexpr auto number_array = cb::make_array(1, 2, 3, 4, 5);
25    EXPECT_EQ(4, number_array.at(3));
26    EXPECT_EQ(5u, number_array.size());
27
28    // Check non-primitives are handled nicely
29    constexpr auto string_array = cb::make_array(
30            "Hello"_ccb, "World!"_ccb, "Couchbase"_ccb, "Rules!"_ccb);
31    EXPECT_EQ(cb::const_char_buffer("Couchbase"), string_array.at(2));
32
33    // Check nesting works OK
34    constexpr auto nested_array =
35            cb::make_array(cb::make_array(1, 2, 3), cb::make_array(4, 5, 6));
36    EXPECT_EQ(4, nested_array.at(1).at(0));
37}
38