• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "lmir_builder.h"
17 #include "mir_builder.h"
18 #include "gtest/gtest.h"
19 #include <iostream>
20 using namespace std;
21 using namespace maple;
22 using namespace litecg;
23 namespace {
TEST(LiteCGGetTypeKind_FUNC,t01)24 TEST(LiteCGGetTypeKind_FUNC, t01)
25 {
26     MIRModule mirmodule("mirmodule");
27     LMIRBuilder *lmirBuilder_ptr = new LMIRBuilder(mirmodule);
28     MIRType mir_type(kTypeScalar, PTY_begin);
29 
30     MIRTypeKind input_ls[] = {kTypeScalar, kTypeArray, kTypePointer,
31                               kTypeFunction, kTypeVoid, kTypeByName, static_cast<MIRTypeKind>(900)};
32     LiteCGTypeKind output_ls[] = {kLiteCGTypeScalar, kLiteCGTypeArray,
33                                   kLiteCGTypePointer, kLiteCGTypeFunction,
34                                   kLiteCGTypeVoid, kLiteCGTypeByName, kLiteCGTypeUnknown};
35     for (int i = 0; i < sizeof(input_ls) / sizeof(input_ls[0]); i++)
36     {
37         mir_type.SetMIRTypeKind(input_ls[i]);
38         EXPECT_EQ(lmirBuilder_ptr->LiteCGGetTypeKind(&mir_type), output_ls[i]);
39     }
40 }
41 }  // namespace
42