1 /*
2 * Copyright (c) 2021 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 "string_utils_test.h"
17
18 #include <climits>
19 #include <gtest/gtest.h>
20 #include <types.h>
21
22 #include "test_common.h"
23 #include "utils/string_utils.h"
24
25 using namespace OHOS::Global::Resource;
26 using namespace testing::ext;
27 using namespace OHOS::I18N;
28
29 class StringUtilsTest : public testing::Test {
30 public:
31 static void SetUpTestCase(void);
32
33 static void TearDownTestCase(void);
34
35 void SetUp();
36
37 void TearDown();
38 };
39
SetUpTestCase(void)40 void StringUtilsTest::SetUpTestCase(void)
41 {
42 // step 1: input testsuit setup step
43 g_logLevel = LOG_DEBUG;
44 }
45
TearDownTestCase(void)46 void StringUtilsTest::TearDownTestCase(void)
47 {
48 // step 2: input testsuit teardown step
49 }
50
SetUp()51 void StringUtilsTest::SetUp()
52 {
53 // step 3: input testcase setup step
54 }
55
TearDown()56 void StringUtilsTest::TearDown()
57 {
58 // step 4: input testcase teardown step
59 }
60
61 /*
62 * @tc.name: StringUtilsFuncTest001
63 * @tc.desc: Test FormatString, none file case.
64 * @tc.type: FUNC
65 */
66 HWTEST_F(StringUtilsTest, StringUtilsFuncTest001, TestSize.Level1)
67 {
68 std::string result = FormatString("%d", 10001);
69 EXPECT_EQ("10001", result);
70
71 result = FormatString("I'm %s, I'm %d", "cici", 5);
72 EXPECT_EQ("I'm cici, I'm 5", result);
73 }