|
| 1 | +// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: BSD-3-Clause |
| 4 | + |
| 5 | +#include <typeinfo> |
| 6 | + |
| 7 | +#include <gtest/gtest.h> |
| 8 | + |
| 9 | +#include <ginkgo/core/base/exception.hpp> |
| 10 | +#include <ginkgo/core/base/executor.hpp> |
| 11 | +#include <ginkgo/core/config/config.hpp> |
| 12 | +#include <ginkgo/core/matrix/identity.hpp> |
| 13 | + |
| 14 | +#include "cmake-build-debug/_deps/googletest-src/googletest/include/gtest/gtest-typed-test.h" |
| 15 | +#include "core/config/config_helper.hpp" |
| 16 | +#include "core/config/registry_accessor.hpp" |
| 17 | +#include "core/test/utils.hpp" |
| 18 | + |
| 19 | + |
| 20 | +using namespace gko::config; |
| 21 | + |
| 22 | + |
| 23 | +template <typename ValueType> |
| 24 | +class Identity : public ::testing::Test { |
| 25 | +protected: |
| 26 | + using value_type = ValueType; |
| 27 | + |
| 28 | + std::shared_ptr<const gko::Executor> exec = |
| 29 | + gko::ReferenceExecutor::create(); |
| 30 | + std::shared_ptr<const gko::matrix::Identity<value_type>> ans = |
| 31 | + gko::matrix::Identity<value_type>::create(exec, 4u); |
| 32 | +}; |
| 33 | + |
| 34 | +TYPED_TEST_SUITE(Identity, gko::test::ValueTypes, TypenameNameGenerator); |
| 35 | + |
| 36 | + |
| 37 | +TYPED_TEST(Identity, CanParse) |
| 38 | +{ |
| 39 | + using value_type = typename TestFixture::value_type; |
| 40 | + auto config = pnode({{"type", pnode("matrix::Identity")}}); |
| 41 | + |
| 42 | + auto res = parse(config, {}, make_type_descriptor<value_type>()) |
| 43 | + .on(this->exec) |
| 44 | + ->generate(this->ans); |
| 45 | + |
| 46 | + ASSERT_TRUE(dynamic_cast<gko::matrix::Identity<value_type>*>(res.get())); |
| 47 | + GKO_ASSERT_EQUAL_DIMENSIONS(res, this->ans); |
| 48 | +} |
0 commit comments