• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 <string>
18 #include "disassembler.h"
19 
20 using namespace testing::ext;
21 
22 namespace panda::disasm {
23 static const std::string ETS_IMPLEMENTS_TAG = "ets_implements";
24 static const std::string ETS_IMPLEMENTS_VALUE_EXPECTED =
25     "L<packagename>/src/main/ets/<filepath>/I1;,L<packagename>/src/main/ets/<filepath>/I2;";
26 
27 class DisassemblerEtsImplementsLiteralTest : public testing::Test {
28 public:
SetUpTestCase(void)29     static void SetUpTestCase(void) {};
TearDownTestCase(void)30     static void TearDownTestCase(void) {};
SetUp()31     void SetUp() {};
TearDown()32     void TearDown() {};
33 
Find(std::stringstream & ss,const std::string & dst)34     bool Find(std::stringstream &ss, const std::string &dst)
35     {
36         return ss.str().find(dst) != std::string::npos;
37     }
38 };
39 
40 /**
41 * @tc.name: disassembler_ets_implements_literal_test_001
42 * @tc.desc: get and check ets_implements in literal array of abc file.
43 * @tc.type: FUNC
44 * @tc.require: file path and name
45 */
46 HWTEST_F(DisassemblerEtsImplementsLiteralTest, disassembler_ets_implements_literal_test_001, TestSize.Level1)
47 {
48     const std::string file_name = GRAPH_TEST_ABC_DIR "etsImplements.abc";
49 
50     panda::disasm::Disassembler disasm {};
51     disasm.Disassemble(file_name, true, true);
52     std::stringstream ss {};
53     disasm.Serialize(ss);
54     EXPECT_TRUE(Find(ss, ETS_IMPLEMENTS_TAG));
55     EXPECT_TRUE(Find(ss, ETS_IMPLEMENTS_VALUE_EXPECTED));
56 }
57 }  // namespace panda::disasm
58