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_namespace.h"
18 
19 #include "ast/ast_interface_type.h"
20 #include "ast/ast_sequenceable_type.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 using namespace OHOS::Idl;
25 
26 namespace OHOS {
27 namespace idl {
28 class AstNamespaceUnitTest : public testing::Test {
29 public:
AstNamespaceUnitTest()30     AstNamespaceUnitTest() {}
31 
~AstNamespaceUnitTest()32     virtual ~AstNamespaceUnitTest() {}
33 
34     static void SetUpTestCase();
35 
36     static void TearDownTestCase();
37 
38     void SetUp();
39 
40     void TearDown();
41 };
42 
SetUpTestCase()43 void AstNamespaceUnitTest::SetUpTestCase() {}
44 
TearDownTestCase()45 void AstNamespaceUnitTest::TearDownTestCase() {}
46 
SetUp()47 void AstNamespaceUnitTest::SetUp() {}
48 
TearDown()49 void AstNamespaceUnitTest::TearDown() {}
50 
51 /*
52  * @tc.name: NamespaceTest_0100
53  * @tc.desc: test function in ASTNamespace.
54  * @tc.type: FUNC
55  * @tc.require:
56  */
57 HWTEST_F(AstNamespaceUnitTest, NamespaceTest_0100, Function | MediumTest | Level1)
58 {
59     GTEST_LOG_(INFO)
60         << "AstNamespaceUnitTest, NamespaceTest_0100, TestSize.Level1";
61     String nspaceStr = "";
62     size_t index = 3;
63     AutoPtr<ASTNamespace> nspace = new ASTNamespace(nspaceStr);
64     AutoPtr<ASTNamespace> findResult = nspace->FindNamespace(nspaceStr);
65     AutoPtr<ASTNamespace> getResult = nspace->GetNamespace(index);
66     AutoPtr<ASTInterfaceType> getInterfaceResult = nspace->GetInterface(index);
67     AutoPtr<ASTSequenceableType> getSequenceableResult = nspace->GetSequenceable(index);
68     EXPECT_EQ(findResult, nullptr);
69     EXPECT_EQ(getResult, nullptr);
70     EXPECT_EQ(getInterfaceResult, nullptr);
71     EXPECT_EQ(getSequenceableResult, nullptr);
72 }
73 } // namespace idl
74 } // namespace OHOS
75