1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
/*
* GridTools
*
* Copyright (c) 2014-2023, ETH Zurich
* All rights reserved.
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <gridtools/sid/as_const.hpp>
#include <type_traits>
#include <gtest/gtest.h>
#include <gridtools/sid/concept.hpp>
#include <gridtools/sid/simple_ptr_holder.hpp>
#include <gridtools/sid/synthetic.hpp>
namespace gridtools {
namespace {
using sid::property;
TEST(as_const, smoke) {
double data = 42;
auto src = sid::synthetic().set<property::origin>(sid::host_device::simple_ptr_holder(&data));
auto testee = sid::as_const(src);
using testee_t = decltype(testee);
static_assert(is_sid<testee_t>());
static_assert(std::is_same_v<sid::ptr_type<testee_t>, double const *>);
EXPECT_EQ(sid::get_origin(src)(), sid::get_origin(testee)());
}
TEST(as_const, c_array) {
int src[3][2] = {{0, 1}, {10, 11}, {20, 21}};
auto testee = sid::as_const(src);
using testee_t = decltype(testee);
static_assert(is_sid<testee_t>());
static_assert(std::is_same_v<sid::ptr_type<testee_t>, int const *>);
EXPECT_EQ(sid::get_origin(src)(), sid::get_origin(testee)());
}
} // namespace
} // namespace gridtools
|