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.
19 #include <gtest/gtest.h>
21 TEST(ShapeTest, basic_test)
24 onert::ir::Shape shape(3);
30 ASSERT_EQ(shape.rank(), 3);
31 ASSERT_EQ(shape.num_elements(), 6);
32 ASSERT_EQ(onert::ir::rankMaybeUnspecified(shape), false);
33 ASSERT_EQ(shape.hasUnspecifiedDims(), false);
36 onert::ir::Shape shape; // scalar or rank is unspecified
38 ASSERT_EQ(shape.rank(), 0);
39 ASSERT_EQ(shape.num_elements(), 1);
40 ASSERT_EQ(onert::ir::rankMaybeUnspecified(shape), true);
41 ASSERT_EQ(shape.hasUnspecifiedDims(), false);
45 TEST(ShapeTest, neg_basic_test)
48 onert::ir::Shape shape(2);
51 shape.dim(1) = onert::ir::Shape::UNSPECIFIED_DIM;
53 ASSERT_EQ(shape.rank(), 2);
54 ASSERT_EQ(onert::ir::rankMaybeUnspecified(shape), false);
55 ASSERT_EQ(shape.hasUnspecifiedDims(), true);
56 EXPECT_ANY_THROW(shape.num_elements());