2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
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.
17 #include "nest/Module.h"
19 #include <gtest/gtest.h>
21 TEST(MODULE, create_var)
25 auto create = [](nest::Module &m) {
26 // This code will invoke 'VarContext &var(void)' method
27 return m.var().make();
30 auto check = [](const nest::Module &m) {
31 // This code will invoke 'const VarContext &var(void) const' method
32 ASSERT_EQ(1, m.var().count());
39 TEST(MODULE, create_domain)
43 auto create = [](nest::Module &m, std::initializer_list<uint32_t> dims) {
44 // This code will invoke 'DomainContext &domain(void)' method
45 return m.domain().make(dims);
48 auto check = [](const nest::Module &m) {
49 // This code will invoke 'const DomainContext &domain(void) const' method
50 ASSERT_EQ(1, m.domain().count());
61 auto ifm = m.domain().make({1, 3, 3});
63 auto var_ch = m.var().make();
64 auto var_row = m.var().make();
65 auto var_col = m.var().make();
67 m.push(ifm(var_ch, var_row, var_col));
69 ASSERT_EQ(1, m.block().size());
70 ASSERT_NE(m.block().at(0)->asPush(), nullptr);
77 auto ifm = m.domain().make({1});
78 auto ofm = m.domain().make({1});
80 auto ind = m.var().make();
85 ASSERT_EQ(ofm.id(), m.ret().id());
86 ASSERT_EQ(1, m.ret().sub().rank());
98 ASSERT_EQ(0, copy.var().count());