• 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 
18 #define private public
19 #include "configuration.h"
20 #undef private
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class BaseConfigurationTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp();
32     void TearDown();
33 };
34 
SetUpTestCase()35 void BaseConfigurationTest::SetUpTestCase()
36 {
37 }
38 
TearDownTestCase()39 void BaseConfigurationTest::TearDownTestCase()
40 {
41 }
42 
SetUp()43 void BaseConfigurationTest::SetUp()
44 {
45 }
46 
TearDown()47 void BaseConfigurationTest::TearDown()
48 {
49 }
50 
51 /*
52  * Feature: Configuration
53  * Function: FilterDuplicates
54  * SubFunction: NA
55  * FunctionPoints:FilterDuplicates Configuration
56  * EnvConditions: NA
57  * CaseDescription: FilterDuplicates Configuratio, call FilterDuplicates function.
58  */
59 HWTEST_F(BaseConfigurationTest, Configuration_FilterDuplicates_001, TestSize.Level1)
60 {
61     AppExecFwk::Configuration config;
62     ASSERT_TRUE(config.configParameter_.empty());
63     auto configuration = std::make_shared<AppExecFwk::Configuration>();
64     configuration->FilterDuplicates(config);
65     config.configParameter_.emplace(std::make_pair("key1", "value1"));
66     configuration->configParameter_.emplace(std::make_pair("key1", "value1"));
67     configuration->FilterDuplicates(config);
68     EXPECT_EQ(configuration->configParameter_.size(), 0);
69 }
70 } // namespace AppExecFwk
71 } // namespace OHOS