• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef ABC2PROGRAM_TEST_CPP_SOURCES_ABC2PROGRAM_TEST_UTILS_H
17 #define ABC2PROGRAM_TEST_CPP_SOURCES_ABC2PROGRAM_TEST_UTILS_H
18 
19 #include <cstdlib>
20 #include <string>
21 #include <vector>
22 #include <set>
23 #include <cstdint>
24 #include <string_view>
25 
26 namespace panda::abc2program {
27 class Abc2ProgramTestUtils {
28 public:
29     static bool ValidateProgramStrings(const std::set<std::string> &program_strings);
30     static bool ValidateRecordNames(const std::vector<std::string> &record_names);
31     static bool ValidateLiteralArrayKeys(const std::vector<std::string> &literal_array_keys);
32     static bool ValidateLiteralsSizes(const std::set<size_t> &literals_sizes);
33     static bool ValidateDumpResult(const std::string &result_file_name, const std::string &expected_file_name);
34     static void RemoveDumpResultFile(const std::string &file_name);
35 private:
36     template <typename T>
37     static bool ValidateStrings(const T &strings, const T &expected_strings);
38     static bool ValidateLine(const std::string &result_line, const std::string &expected_line);
39     static bool ValidateLiteralArrayName(const std::string &result, const std::string &expected);
40     static std::set<std::string> helloworld_expected_program_strings_;
41     static std::vector<std::string> helloworld_expected_record_names_;
42     static std::vector<std::string> helloworld_expected_literal_array_keys_;
43     static std::set<size_t> helloworld_expected_literals_sizes_;
44 };  // class Abc2ProgramTestUtils
45 
46 }  // namespace panda::abc2program
47 
48 #endif  // ABC2PROGRAM_TEST_CPP_SOURCES_ABC2PROGRAM_TEST_UTILS_H