1 /*
2  * Copyright (c) 2022 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 <gtest/gtest.h>
17 #include "ast/ast_node.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 using namespace OHOS::Idl;
22 
23 class AstNodeUnitTest : public testing::Test {
24 public:
AstNodeUnitTest()25     AstNodeUnitTest() {}
26 
~AstNodeUnitTest()27     virtual ~AstNodeUnitTest() {}
28 
29     static void SetUpTestCase();
30 
31     static void TearDownTestCase();
32 
33     void SetUp();
34 
35     void TearDown();
36 };
37 
SetUpTestCase()38 void AstNodeUnitTest::SetUpTestCase() {}
39 
TearDownTestCase()40 void AstNodeUnitTest::TearDownTestCase() {}
41 
SetUp()42 void AstNodeUnitTest::SetUp() {}
43 
TearDown()44 void AstNodeUnitTest::TearDown() {}
45 
46 /*
47  * @tc.name: ToStringTest_0100
48  * @tc.desc: test ToString in AstNodeUnitTest's ToString.
49  * @tc.type: FUNC
50  * @tc.require:
51  */
52 HWTEST_F(AstNodeUnitTest, ToStringTest_0100, Function | MediumTest | Level1)
53 {
54     GTEST_LOG_(INFO)
55         << "AstNodeUnitTest, ToStringTest_0100, TestSize.Level1";
56     std::shared_ptr<ASTNode> imageASTNode = std::make_shared<ASTNode>();
57     String result = imageASTNode->ToString();
58     String expectString = "ASTNode";
59 
60     ASSERT_STREQ(result, expectString);
61 }
62 
63 /*
64  * @tc.name: DumpTest_0100
65  * @tc.desc: test ToString in AstNodeUnitTest's Dump.
66  * @tc.type: FUNC
67  * @tc.require:
68  */
69 HWTEST_F(AstNodeUnitTest, DumpTest_0100, Function | MediumTest | Level1)
70 {
71     GTEST_LOG_(INFO)
72         << "AstNodeUnitTest, DumpTest_0100, TestSize.Level1";
73     std::shared_ptr<ASTNode> imageASTNode = std::make_shared<ASTNode>();
74     String prefix = "test";
75     String result = imageASTNode->Dump(prefix);
76     String expectString = prefix + "ASTNode";
77 
78     ASSERT_STREQ(result, expectString);
79 }
80