• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2022-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 #ifndef PANDA_RUNTIME_TESTS_OPTIONS_TEST_BASE_H
17 #define PANDA_RUNTIME_TESTS_OPTIONS_TEST_BASE_H
18 
19 #include <gtest/gtest.h>
20 #include <vector>
21 
22 #include "runtime/include/runtime_options.h"
23 #include "libpandabase/utils/pandargs.h"
24 
25 namespace panda::test {
26 class RuntimeOptionsTestBase : public testing::Test {
27 public:
RuntimeOptionsTestBase()28     RuntimeOptionsTestBase() : runtime_options_("AAA") {}
29     virtual ~RuntimeOptionsTestBase() = default;
30 
SetUp()31     void SetUp() override
32     {
33         runtime_options_.AddOptions(&pa_parser_);
34         LoadCorrectOptionsList();
35     }
36 
TearDown()37     void TearDown() override {}
38 
GetParser()39     panda::PandArgParser *GetParser()
40     {
41         return &pa_parser_;
42     }
43 
GetCorrectOptionsList()44     const std::vector<std::string> &GetCorrectOptionsList() const
45     {
46         return correct_options_list_;
47     }
48 
GetRuntimeOptions()49     RuntimeOptions *GetRuntimeOptions()
50     {
51         return &runtime_options_;
52     }
53 
54 protected:
AddTestingOption(std::string opt,std::string value)55     void AddTestingOption(std::string opt, std::string value)
56     {
57         correct_options_list_.push_back("--" + opt + "=" + value);
58     }
59 
60 private:
61     virtual void LoadCorrectOptionsList() = 0;
62 
63     RuntimeOptions runtime_options_;
64     panda::PandArgParser pa_parser_;
65     std::vector<std::string> correct_options_list_;
66 };
67 }  // namespace panda::test
68 
69 #endif  // PANDA_RUNTIME_TESTS_OPTIONS_TEST_BASE_H
70