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 #include <gmock/gmock.h>
16 #include <gtest/gtest.h>
17
18 #include "base.h"
19 #include "define.h"
20
21 using namespace testing::ext;
22 using namespace testing;
23
24 namespace Hdc {
25 class UpdateCmdLogSwitchTest : public ::testing::Test {
26 private:
27 static void SetUpTestCase(void);
28 static void TearDownTestCase(void);
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase()33 void UpdateCmdLogSwitchTest::SetUpTestCase() {}
TearDownTestCase()34 void UpdateCmdLogSwitchTest::TearDownTestCase() {}
SetUp()35 void UpdateCmdLogSwitchTest::SetUp() {}
TearDown()36 void UpdateCmdLogSwitchTest::TearDown() {}
37
38 HWTEST_F(UpdateCmdLogSwitchTest, UpdateCmdLogSwitch_12, TestSize.Level0) {
39 setenv(ENV_SERVER_CMD_LOG.c_str(), "12", 1);
40 Base::UpdateCmdLogSwitch();
41 EXPECT_FALSE(Base::GetCmdLogSwitch());
42 }
43
44 HWTEST_F(UpdateCmdLogSwitchTest, UpdateCmdLogSwitch_, TestSize.Level0) {
45 setenv(ENV_SERVER_CMD_LOG.c_str(), "", 1);
46 Base::UpdateCmdLogSwitch();
47 EXPECT_FALSE(Base::GetCmdLogSwitch());
48 }
49
50 HWTEST_F(UpdateCmdLogSwitchTest, UpdateCmdLogSwitch_1, TestSize.Level0) {
51 setenv(ENV_SERVER_CMD_LOG.c_str(), "1", 1);
52 Base::UpdateCmdLogSwitch();
53 EXPECT_TRUE(Base::GetCmdLogSwitch());
54 }
55
56 HWTEST_F(UpdateCmdLogSwitchTest, UpdateCmdLogSwitch_0, TestSize.Level0) {
57 setenv(ENV_SERVER_CMD_LOG.c_str(), "0", 1);
58 Base::UpdateCmdLogSwitch();
59 EXPECT_FALSE(Base::GetCmdLogSwitch());
60 }
61
62 HWTEST_F(UpdateCmdLogSwitchTest, UpdateCmdLogSwitch_a, TestSize.Level0) {
63 setenv(ENV_SERVER_CMD_LOG.c_str(), "a", 1);
64 Base::UpdateCmdLogSwitch();
65 EXPECT_FALSE(Base::GetCmdLogSwitch());
66 }
67
68 } // namespace Hdc