• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #include "test_common.h"
17 
18 #include <climits>
19 #include <cstdio>
20 #include <cstdlib>
21 #include <unistd.h>
22 
23 #include "hilog_wrapper.h"
24 #include "utils/errors.h"
25 
26 #if defined(__linux__)
27 #include <malloc.h>
28 #endif
29 
30 namespace OHOS {
31 namespace Global {
32 namespace Resource {
FormatFullPath(const char * fileRelativePath)33 std::string FormatFullPath(const char *fileRelativePath)
34 {
35     const char *value = "/data/test";
36     std::string result(value);
37     result.append("/");
38     result.append(fileRelativePath);
39     return result;
40 }
41 
PrintIdValues(const HapResource::IdValues * idValues)42 void PrintIdValues(const HapResource::IdValues *idValues)
43 {
44     if (idValues == nullptr) {
45         return;
46     }
47     for (size_t i = 0; i < idValues->GetLimitPathsConst().size(); ++i) {
48         auto limitPath = idValues->GetLimitPathsConst()[i];
49         HILOG_DEBUG("%zu: folder is: %s, value: %s", i, limitPath->GetFolder().c_str(),
50             limitPath->GetIdItem()->ToString().c_str());
51     }
52 }
53 
PrintMapString(const std::map<std::string,std::string> & value)54 void PrintMapString(const std::map<std::string, std::string> &value)
55 {
56     auto iter = value.begin();
57     for (; iter != value.end(); ++iter) {
58         std::string key = iter->first;
59         std::string val = iter->second;
60         HILOG_DEBUG("%s : %s", key.c_str(), val.c_str());
61     }
62 }
63 
PrintVectorString(const std::vector<std::string> & value)64 void PrintVectorString(const std::vector<std::string> &value)
65 {
66     for (size_t i = 0; i < value.size(); ++i) {
67         std::string val = value[i];
68         HILOG_DEBUG("%zu : %s", i, val.c_str());
69     }
70 }
71 
CreateResConfig(const char * language,const char * script,const char * region)72 ResConfig *CreateResConfig(const char *language, const char *script, const char *region)
73 {
74     ResConfig *resConfig = CreateResConfig();
75     if (resConfig == nullptr) {
76         return nullptr;
77     }
78     resConfig->SetLocaleInfo(language, script, region);
79     return resConfig;
80 }
81 } // namespace Resource
82 } // namespace Global
83 } // namespace OHOS