2 * Copyright (c) 2020 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 "luci/IR/Module.h"
19 #include <gtest/gtest.h>
21 TEST(ModuleTest, consturctor)
23 auto gs = luci::make_module();
30 auto m = luci::make_module();
31 auto g = loco::make_graph();
36 ASSERT_EQ(g_ptr, m->graph());
37 ASSERT_EQ(g_ptr, m->graph(0));
40 TEST(ModuleTest, add_more)
42 auto m = luci::make_module();
43 auto g1 = loco::make_graph();
44 auto g2 = loco::make_graph();
45 auto g3 = loco::make_graph();
46 auto g1_ptr = g1.get();
47 auto g2_ptr = g2.get();
48 auto g3_ptr = g3.get();
50 m->add(std::move(g1));
51 m->add(std::move(g2));
52 m->add(std::move(g3));
54 ASSERT_EQ(3, m->size());
55 ASSERT_EQ(g1_ptr, m->graph());
56 ASSERT_EQ(g1_ptr, m->graph(0));
57 ASSERT_EQ(g2_ptr, m->graph(1));
58 ASSERT_EQ(g3_ptr, m->graph(2));
61 TEST(ModuleTest, add_nullptr_NEG)
63 auto m = luci::make_module();
65 EXPECT_THROW(m->add(nullptr), std::invalid_argument);
68 TEST(ModuleTest, graph_index_overflow_NEG)
70 auto m = luci::make_module();
72 EXPECT_ANY_THROW(m->graph(100));