13f4cbf05Sopenharmony_ci/*
23f4cbf05Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
33f4cbf05Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43f4cbf05Sopenharmony_ci * you may not use this file except in compliance with the License.
53f4cbf05Sopenharmony_ci * You may obtain a copy of the License at
63f4cbf05Sopenharmony_ci *
73f4cbf05Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83f4cbf05Sopenharmony_ci *
93f4cbf05Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103f4cbf05Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113f4cbf05Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123f4cbf05Sopenharmony_ci * See the License for the specific language governing permissions and
133f4cbf05Sopenharmony_ci * limitations under the License.
143f4cbf05Sopenharmony_ci */
153f4cbf05Sopenharmony_ci
163f4cbf05Sopenharmony_ci#include <gtest/gtest.h>
173f4cbf05Sopenharmony_ci#include "string_ex.h"
183f4cbf05Sopenharmony_ci#include <iostream>
193f4cbf05Sopenharmony_ci#include <securec.h>
203f4cbf05Sopenharmony_ci#include <string>
213f4cbf05Sopenharmony_ci
223f4cbf05Sopenharmony_ciusing namespace testing::ext;
233f4cbf05Sopenharmony_ciusing namespace std;
243f4cbf05Sopenharmony_ci
253f4cbf05Sopenharmony_cinamespace OHOS {
263f4cbf05Sopenharmony_cinamespace {
273f4cbf05Sopenharmony_ciclass UtilsStringTest : public testing::Test
283f4cbf05Sopenharmony_ci{
293f4cbf05Sopenharmony_cipublic :
303f4cbf05Sopenharmony_ci    static void SetUpTestCase(void);
313f4cbf05Sopenharmony_ci    static void TearDownTestCase(void);
323f4cbf05Sopenharmony_ci    void SetUp();
333f4cbf05Sopenharmony_ci    void TearDown();
343f4cbf05Sopenharmony_ci};
353f4cbf05Sopenharmony_ci
363f4cbf05Sopenharmony_civoid UtilsStringTest::SetUpTestCase(void)
373f4cbf05Sopenharmony_ci{
383f4cbf05Sopenharmony_ci}
393f4cbf05Sopenharmony_ci
403f4cbf05Sopenharmony_civoid UtilsStringTest::TearDownTestCase(void)
413f4cbf05Sopenharmony_ci{
423f4cbf05Sopenharmony_ci}
433f4cbf05Sopenharmony_ci
443f4cbf05Sopenharmony_civoid UtilsStringTest::SetUp(void)
453f4cbf05Sopenharmony_ci{
463f4cbf05Sopenharmony_ci}
473f4cbf05Sopenharmony_ci
483f4cbf05Sopenharmony_civoid UtilsStringTest::TearDown(void)
493f4cbf05Sopenharmony_ci{
503f4cbf05Sopenharmony_ci}
513f4cbf05Sopenharmony_ci
523f4cbf05Sopenharmony_ci/*
533f4cbf05Sopenharmony_ci* Feature: string_ex
543f4cbf05Sopenharmony_ci* Function: UpperStr
553f4cbf05Sopenharmony_ci* SubFunction: NA
563f4cbf05Sopenharmony_ci* FunctionPoints:
573f4cbf05Sopenharmony_ci* EnvConditions: NA
583f4cbf05Sopenharmony_ci* CaseDescription: test for convert all letters of str  to uppercase
593f4cbf05Sopenharmony_ci*/
603f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strupper_01, TestSize.Level0)
613f4cbf05Sopenharmony_ci{
623f4cbf05Sopenharmony_ci    string strBase = "strbase";
633f4cbf05Sopenharmony_ci    string strTemp = "STRBASE";
643f4cbf05Sopenharmony_ci    string result = UpperStr(strBase);
653f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
663f4cbf05Sopenharmony_ci
673f4cbf05Sopenharmony_ci    strBase = "StrBase";
683f4cbf05Sopenharmony_ci    result = UpperStr(strBase);
693f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
703f4cbf05Sopenharmony_ci}
713f4cbf05Sopenharmony_ci
723f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strupper_02, TestSize.Level0)
733f4cbf05Sopenharmony_ci{
743f4cbf05Sopenharmony_ci    string strBase = "";
753f4cbf05Sopenharmony_ci    string strTemp = "";
763f4cbf05Sopenharmony_ci    string result = UpperStr(strBase);
773f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
783f4cbf05Sopenharmony_ci}
793f4cbf05Sopenharmony_ci
803f4cbf05Sopenharmony_ci/*
813f4cbf05Sopenharmony_ci* Feature: string_ex
823f4cbf05Sopenharmony_ci* Function: LowerStr
833f4cbf05Sopenharmony_ci* SubFunction: NA
843f4cbf05Sopenharmony_ci* FunctionPoints:
853f4cbf05Sopenharmony_ci* EnvConditions: NA
863f4cbf05Sopenharmony_ci* CaseDescription: test for convert all letters of str  to lowercase
873f4cbf05Sopenharmony_ci*/
883f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strlower_01, TestSize.Level0)
893f4cbf05Sopenharmony_ci{
903f4cbf05Sopenharmony_ci    string strBase = "STRbase";
913f4cbf05Sopenharmony_ci    string strTemp = "strbase";
923f4cbf05Sopenharmony_ci    string result = LowerStr(strBase);
933f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
943f4cbf05Sopenharmony_ci
953f4cbf05Sopenharmony_ci    strBase = "StrBase";
963f4cbf05Sopenharmony_ci    result = LowerStr(strBase);
973f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
983f4cbf05Sopenharmony_ci}
993f4cbf05Sopenharmony_ci
1003f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strlower_02, TestSize.Level0)
1013f4cbf05Sopenharmony_ci{
1023f4cbf05Sopenharmony_ci    string strBase = "";
1033f4cbf05Sopenharmony_ci    string strTemp = "";
1043f4cbf05Sopenharmony_ci    string result = LowerStr(strBase);
1053f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
1063f4cbf05Sopenharmony_ci}
1073f4cbf05Sopenharmony_ci
1083f4cbf05Sopenharmony_ci/*
1093f4cbf05Sopenharmony_ci* Feature: string_ex
1103f4cbf05Sopenharmony_ci* Function: ReplaceStr
1113f4cbf05Sopenharmony_ci* SubFunction: NA
1123f4cbf05Sopenharmony_ci* FunctionPoints:
1133f4cbf05Sopenharmony_ci* EnvConditions: NA
1143f4cbf05Sopenharmony_ci* CaseDescription: test for replace src with dst int strBase
1153f4cbf05Sopenharmony_ci*/
1163f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strreplace_01, TestSize.Level0)
1173f4cbf05Sopenharmony_ci{
1183f4cbf05Sopenharmony_ci    string strBase = "test for replace";
1193f4cbf05Sopenharmony_ci    string src = "for";
1203f4cbf05Sopenharmony_ci    string dst = "with";
1213f4cbf05Sopenharmony_ci    string strTemp = "test with replace";
1223f4cbf05Sopenharmony_ci    string result = ReplaceStr(strBase, src, dst);
1233f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
1243f4cbf05Sopenharmony_ci
1253f4cbf05Sopenharmony_ci    src = "test for replace";
1263f4cbf05Sopenharmony_ci    dst = "test";
1273f4cbf05Sopenharmony_ci    strTemp = "test";
1283f4cbf05Sopenharmony_ci    result = ReplaceStr(strBase, src, dst);
1293f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
1303f4cbf05Sopenharmony_ci
1313f4cbf05Sopenharmony_ci    src = "";
1323f4cbf05Sopenharmony_ci    dst = "test";
1333f4cbf05Sopenharmony_ci    result = ReplaceStr(strBase, src, dst);
1343f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strBase);
1353f4cbf05Sopenharmony_ci
1363f4cbf05Sopenharmony_ci    src = "for";
1373f4cbf05Sopenharmony_ci    dst = "";
1383f4cbf05Sopenharmony_ci    strTemp = "test  replace";
1393f4cbf05Sopenharmony_ci    result = ReplaceStr(strBase, src, dst);
1403f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
1413f4cbf05Sopenharmony_ci}
1423f4cbf05Sopenharmony_ci
1433f4cbf05Sopenharmony_ci/*
1443f4cbf05Sopenharmony_ci* Feature: string_ex
1453f4cbf05Sopenharmony_ci* Function: TrimStr
1463f4cbf05Sopenharmony_ci* SubFunction: NA
1473f4cbf05Sopenharmony_ci* FunctionPoints:
1483f4cbf05Sopenharmony_ci* EnvConditions: NA
1493f4cbf05Sopenharmony_ci* CaseDescription: test for trim str front and end
1503f4cbf05Sopenharmony_ci*/
1513f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strtrim_01, TestSize.Level0)
1523f4cbf05Sopenharmony_ci{
1533f4cbf05Sopenharmony_ci    string strBase = "              test for trim ";
1543f4cbf05Sopenharmony_ci    string strTemp = "test for trim";
1553f4cbf05Sopenharmony_ci    string result = TrimStr(strBase);
1563f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
1573f4cbf05Sopenharmony_ci}
1583f4cbf05Sopenharmony_ci
1593f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strtrim_02, TestSize.Level0)
1603f4cbf05Sopenharmony_ci{
1613f4cbf05Sopenharmony_ci    string strBase = "test";
1623f4cbf05Sopenharmony_ci    string strTemp = "es";
1633f4cbf05Sopenharmony_ci    string result = TrimStr(strBase, 't');
1643f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strTemp);
1653f4cbf05Sopenharmony_ci}
1663f4cbf05Sopenharmony_ci
1673f4cbf05Sopenharmony_ci/*
1683f4cbf05Sopenharmony_ci* Feature: string_ex
1693f4cbf05Sopenharmony_ci* Function: SplitStr
1703f4cbf05Sopenharmony_ci* SubFunction: NA
1713f4cbf05Sopenharmony_ci* FunctionPoints:
1723f4cbf05Sopenharmony_ci* EnvConditions: NA
1733f4cbf05Sopenharmony_ci* CaseDescription: test for split str by strSep
1743f4cbf05Sopenharmony_ci*/
1753f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strsplit_01, TestSize.Level0)
1763f4cbf05Sopenharmony_ci{
1773f4cbf05Sopenharmony_ci    string strBase = "test for split";
1783f4cbf05Sopenharmony_ci    string strSep = " ";
1793f4cbf05Sopenharmony_ci    string splitResult[3] = { "test", "for", "split" };
1803f4cbf05Sopenharmony_ci    vector<string> strsRet;
1813f4cbf05Sopenharmony_ci    SplitStr(strBase, strSep, strsRet);
1823f4cbf05Sopenharmony_ci
1833f4cbf05Sopenharmony_ci    for (int i = 0; i < 3; i++)
1843f4cbf05Sopenharmony_ci    {
1853f4cbf05Sopenharmony_ci        EXPECT_EQ(splitResult[i], strsRet[i]);
1863f4cbf05Sopenharmony_ci    }
1873f4cbf05Sopenharmony_ci}
1883f4cbf05Sopenharmony_ci
1893f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strsplit_02, TestSize.Level0)
1903f4cbf05Sopenharmony_ci{
1913f4cbf05Sopenharmony_ci    string strBase = "test for split";
1923f4cbf05Sopenharmony_ci    string strSep = "for";
1933f4cbf05Sopenharmony_ci    string splitResult[2] = { "test", "split" };
1943f4cbf05Sopenharmony_ci    vector<string> strsRet;
1953f4cbf05Sopenharmony_ci    SplitStr(strBase, strSep, strsRet);
1963f4cbf05Sopenharmony_ci
1973f4cbf05Sopenharmony_ci    for (int i = 0; i < 2; i++)
1983f4cbf05Sopenharmony_ci    {
1993f4cbf05Sopenharmony_ci        EXPECT_EQ(splitResult[i], strsRet[i]);
2003f4cbf05Sopenharmony_ci    }
2013f4cbf05Sopenharmony_ci
2023f4cbf05Sopenharmony_ci    splitResult[0] = "test ";
2033f4cbf05Sopenharmony_ci    splitResult[1] = " split";
2043f4cbf05Sopenharmony_ci    SplitStr(strBase, strSep, strsRet, false, false);
2053f4cbf05Sopenharmony_ci    for (int i = 0; i < 2; i++)
2063f4cbf05Sopenharmony_ci    {
2073f4cbf05Sopenharmony_ci        EXPECT_EQ(splitResult[i], strsRet[i]);
2083f4cbf05Sopenharmony_ci    }
2093f4cbf05Sopenharmony_ci}
2103f4cbf05Sopenharmony_ci
2113f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strsplit_03, TestSize.Level0)
2123f4cbf05Sopenharmony_ci{
2133f4cbf05Sopenharmony_ci    string strBase = "test for for split";
2143f4cbf05Sopenharmony_ci    string strSep = "for";
2153f4cbf05Sopenharmony_ci    string splitResult[3] = { "test", "", "split" };
2163f4cbf05Sopenharmony_ci    vector<string> strsRet;
2173f4cbf05Sopenharmony_ci    SplitStr(strBase, strSep, strsRet, true);
2183f4cbf05Sopenharmony_ci    for (int i = 0; i < (int)strsRet.size(); i++)
2193f4cbf05Sopenharmony_ci    {
2203f4cbf05Sopenharmony_ci        EXPECT_EQ(splitResult[i], strsRet[i]);
2213f4cbf05Sopenharmony_ci    }
2223f4cbf05Sopenharmony_ci}
2233f4cbf05Sopenharmony_ci
2243f4cbf05Sopenharmony_ci/*
2253f4cbf05Sopenharmony_ci* Feature: string_ex
2263f4cbf05Sopenharmony_ci* Function: SplitStr
2273f4cbf05Sopenharmony_ci* SubFunction: NA
2283f4cbf05Sopenharmony_ci* FunctionPoints:
2293f4cbf05Sopenharmony_ci* EnvConditions: NA
2303f4cbf05Sopenharmony_ci* CaseDescription: test splitting a null string with a null seperator
2313f4cbf05Sopenharmony_ci*/
2323f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strsplit_04, TestSize.Level0)
2333f4cbf05Sopenharmony_ci{
2343f4cbf05Sopenharmony_ci    string strBase = "";
2353f4cbf05Sopenharmony_ci    string strSep = "";
2363f4cbf05Sopenharmony_ci    vector<string> strsRet1;
2373f4cbf05Sopenharmony_ci    SplitStr(strBase, strSep, strsRet1);
2383f4cbf05Sopenharmony_ci    EXPECT_EQ(strsRet1.size(), 0);
2393f4cbf05Sopenharmony_ci    vector<string> strsRet2;
2403f4cbf05Sopenharmony_ci    SplitStr(strBase, strSep, strsRet2, true);
2413f4cbf05Sopenharmony_ci    EXPECT_EQ(strsRet2[0], "");
2423f4cbf05Sopenharmony_ci}
2433f4cbf05Sopenharmony_ci
2443f4cbf05Sopenharmony_ci/*
2453f4cbf05Sopenharmony_ci* Feature: string_ex
2463f4cbf05Sopenharmony_ci* Function: IsNumericStr
2473f4cbf05Sopenharmony_ci* SubFunction: NA
2483f4cbf05Sopenharmony_ci* FunctionPoints:
2493f4cbf05Sopenharmony_ci* EnvConditions: NA
2503f4cbf05Sopenharmony_ci* CaseDescription: test for judge all characters of the string are numbers
2513f4cbf05Sopenharmony_ci*/
2523f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strisnumeric_01, TestSize.Level0)
2533f4cbf05Sopenharmony_ci{
2543f4cbf05Sopenharmony_ci    string strBase = "1234556";
2553f4cbf05Sopenharmony_ci    bool result = IsNumericStr(strBase);
2563f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
2573f4cbf05Sopenharmony_ci
2583f4cbf05Sopenharmony_ci    strBase = "1234,a";
2593f4cbf05Sopenharmony_ci    result = IsNumericStr(strBase);
2603f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
2613f4cbf05Sopenharmony_ci
2623f4cbf05Sopenharmony_ci    strBase = "";
2633f4cbf05Sopenharmony_ci    result = IsNumericStr(strBase);
2643f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
2653f4cbf05Sopenharmony_ci}
2663f4cbf05Sopenharmony_ci
2673f4cbf05Sopenharmony_ci/*
2683f4cbf05Sopenharmony_ci* Feature: string_ex
2693f4cbf05Sopenharmony_ci* Function: IsAlphaStr
2703f4cbf05Sopenharmony_ci* SubFunction: NA
2713f4cbf05Sopenharmony_ci* FunctionPoints:
2723f4cbf05Sopenharmony_ci* EnvConditions: NA
2733f4cbf05Sopenharmony_ci* CaseDescription: test for judge all characters of the string are alphabet
2743f4cbf05Sopenharmony_ci*/
2753f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strisalpha_01, TestSize.Level0)
2763f4cbf05Sopenharmony_ci{
2773f4cbf05Sopenharmony_ci    string strBase = "1234556";
2783f4cbf05Sopenharmony_ci    bool result = IsAlphaStr(strBase);
2793f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
2803f4cbf05Sopenharmony_ci
2813f4cbf05Sopenharmony_ci    strBase = "Acedafe";
2823f4cbf05Sopenharmony_ci    result = IsAlphaStr(strBase);
2833f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
2843f4cbf05Sopenharmony_ci
2853f4cbf05Sopenharmony_ci    strBase = "Acedafe  ";
2863f4cbf05Sopenharmony_ci    result = IsAlphaStr(strBase);
2873f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
2883f4cbf05Sopenharmony_ci
2893f4cbf05Sopenharmony_ci    strBase = "Acedafe3";
2903f4cbf05Sopenharmony_ci    result = IsAlphaStr(strBase);
2913f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
2923f4cbf05Sopenharmony_ci
2933f4cbf05Sopenharmony_ci    strBase = "";
2943f4cbf05Sopenharmony_ci    result = IsAlphaStr(strBase);
2953f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
2963f4cbf05Sopenharmony_ci}
2973f4cbf05Sopenharmony_ci
2983f4cbf05Sopenharmony_ci/*
2993f4cbf05Sopenharmony_ci* Feature: string_ex
3003f4cbf05Sopenharmony_ci* Function: IsUpperStr
3013f4cbf05Sopenharmony_ci* SubFunction: NA
3023f4cbf05Sopenharmony_ci* FunctionPoints:
3033f4cbf05Sopenharmony_ci* EnvConditions: NA
3043f4cbf05Sopenharmony_ci* CaseDescription: test for judge all characters of the string are uppercase
3053f4cbf05Sopenharmony_ci*/
3063f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_IsUpperStr_01, TestSize.Level0)
3073f4cbf05Sopenharmony_ci{
3083f4cbf05Sopenharmony_ci    string strBase = "ABSEFAD";
3093f4cbf05Sopenharmony_ci    bool result = IsUpperStr(strBase);
3103f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
3113f4cbf05Sopenharmony_ci
3123f4cbf05Sopenharmony_ci    strBase = "Afaefadf";
3133f4cbf05Sopenharmony_ci    result = IsUpperStr(strBase);
3143f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3153f4cbf05Sopenharmony_ci
3163f4cbf05Sopenharmony_ci    strBase = "12e13eaefd     ";
3173f4cbf05Sopenharmony_ci    result = IsUpperStr(strBase);
3183f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3193f4cbf05Sopenharmony_ci
3203f4cbf05Sopenharmony_ci    strBase = "";
3213f4cbf05Sopenharmony_ci    result = IsUpperStr(strBase);
3223f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3233f4cbf05Sopenharmony_ci}
3243f4cbf05Sopenharmony_ci
3253f4cbf05Sopenharmony_ci/*
3263f4cbf05Sopenharmony_ci* Feature: string_ex
3273f4cbf05Sopenharmony_ci* Function: IsLowerStr
3283f4cbf05Sopenharmony_ci* SubFunction: NA
3293f4cbf05Sopenharmony_ci* FunctionPoints:
3303f4cbf05Sopenharmony_ci* EnvConditions: NA
3313f4cbf05Sopenharmony_ci* CaseDescription: test for judge all characters of the string are lowercase
3323f4cbf05Sopenharmony_ci*/
3333f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_IsLowerStr_01, TestSize.Level0)
3343f4cbf05Sopenharmony_ci{
3353f4cbf05Sopenharmony_ci    string strBase = "testlower";
3363f4cbf05Sopenharmony_ci    bool result = IsLowerStr(strBase);
3373f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
3383f4cbf05Sopenharmony_ci
3393f4cbf05Sopenharmony_ci    strBase = "AAFDeadfkl";
3403f4cbf05Sopenharmony_ci    result = IsLowerStr(strBase);
3413f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3423f4cbf05Sopenharmony_ci
3433f4cbf05Sopenharmony_ci    strBase = "12e";
3443f4cbf05Sopenharmony_ci    result = IsLowerStr(strBase);
3453f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3463f4cbf05Sopenharmony_ci
3473f4cbf05Sopenharmony_ci    strBase = "";
3483f4cbf05Sopenharmony_ci    result = IsLowerStr(strBase);
3493f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3503f4cbf05Sopenharmony_ci}
3513f4cbf05Sopenharmony_ci
3523f4cbf05Sopenharmony_ci/*
3533f4cbf05Sopenharmony_ci* Feature: string_ex
3543f4cbf05Sopenharmony_ci* Function: IsSubStr
3553f4cbf05Sopenharmony_ci* SubFunction: NA
3563f4cbf05Sopenharmony_ci* FunctionPoints:
3573f4cbf05Sopenharmony_ci* EnvConditions: NA
3583f4cbf05Sopenharmony_ci* CaseDescription: test for judge the sub_str in base_str
3593f4cbf05Sopenharmony_ci*/
3603f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_IsSubStr_01, TestSize.Level0)
3613f4cbf05Sopenharmony_ci{
3623f4cbf05Sopenharmony_ci    string strBase = "test for issubstr";
3633f4cbf05Sopenharmony_ci    string strSub = "for";
3643f4cbf05Sopenharmony_ci    bool result = IsSubStr(strBase, strSub);
3653f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
3663f4cbf05Sopenharmony_ci
3673f4cbf05Sopenharmony_ci    strBase = "";
3683f4cbf05Sopenharmony_ci    strSub = "";
3693f4cbf05Sopenharmony_ci    result = IsSubStr(strBase, strSub);
3703f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3713f4cbf05Sopenharmony_ci
3723f4cbf05Sopenharmony_ci    strSub = "fori";
3733f4cbf05Sopenharmony_ci    result = IsSubStr(strBase, strSub);
3743f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3753f4cbf05Sopenharmony_ci}
3763f4cbf05Sopenharmony_ci
3773f4cbf05Sopenharmony_ci/*
3783f4cbf05Sopenharmony_ci* Feature: string_ex
3793f4cbf05Sopenharmony_ci* Function: IsSameTextStr
3803f4cbf05Sopenharmony_ci* SubFunction: NA
3813f4cbf05Sopenharmony_ci* FunctionPoints:
3823f4cbf05Sopenharmony_ci* EnvConditions: NA
3833f4cbf05Sopenharmony_ci* CaseDescription: test for judge the strFirst's letter is same with strSecond
3843f4cbf05Sopenharmony_ci*/
3853f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_IsSameTextStr_01, TestSize.Level0)
3863f4cbf05Sopenharmony_ci{
3873f4cbf05Sopenharmony_ci    string strFirst = "Test For StrSameText";
3883f4cbf05Sopenharmony_ci    string strSecond = "test for strsametext";
3893f4cbf05Sopenharmony_ci    bool result = IsSameTextStr(strFirst, strSecond);
3903f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
3913f4cbf05Sopenharmony_ci
3923f4cbf05Sopenharmony_ci    strSecond = "test for strsametex";
3933f4cbf05Sopenharmony_ci    result = IsSameTextStr(strFirst, strSecond);
3943f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
3953f4cbf05Sopenharmony_ci}
3963f4cbf05Sopenharmony_ci
3973f4cbf05Sopenharmony_ci/*
3983f4cbf05Sopenharmony_ci* Feature: string_ex
3993f4cbf05Sopenharmony_ci* Function: ToString
4003f4cbf05Sopenharmony_ci* SubFunction: NA
4013f4cbf05Sopenharmony_ci* FunctionPoints:
4023f4cbf05Sopenharmony_ci* EnvConditions: NA
4033f4cbf05Sopenharmony_ci* CaseDescription: test for convert int to str
4043f4cbf05Sopenharmony_ci*/
4053f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_ToString_01, TestSize.Level0)
4063f4cbf05Sopenharmony_ci{
4073f4cbf05Sopenharmony_ci    int ivalue = 12345;
4083f4cbf05Sopenharmony_ci    string strValue = "12345";
4093f4cbf05Sopenharmony_ci    string result = ToString(ivalue);
4103f4cbf05Sopenharmony_ci    EXPECT_EQ(result, strValue);
4113f4cbf05Sopenharmony_ci
4123f4cbf05Sopenharmony_ci    ivalue = -15;
4133f4cbf05Sopenharmony_ci    result = ToString(ivalue);
4143f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "-15");
4153f4cbf05Sopenharmony_ci}
4163f4cbf05Sopenharmony_ci
4173f4cbf05Sopenharmony_ci/*
4183f4cbf05Sopenharmony_ci* Feature: string_ex
4193f4cbf05Sopenharmony_ci* Function: StrToInt
4203f4cbf05Sopenharmony_ci* SubFunction: NA
4213f4cbf05Sopenharmony_ci* FunctionPoints:
4223f4cbf05Sopenharmony_ci* EnvConditions: NA
4233f4cbf05Sopenharmony_ci* CaseDescription: test for convert str to int
4243f4cbf05Sopenharmony_ci*/
4253f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_StrToInt_01, TestSize.Level0)
4263f4cbf05Sopenharmony_ci{
4273f4cbf05Sopenharmony_ci    string strValue = "12345";
4283f4cbf05Sopenharmony_ci    int iValue = 0;
4293f4cbf05Sopenharmony_ci    bool result = StrToInt(strValue, iValue);
4303f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
4313f4cbf05Sopenharmony_ci    EXPECT_EQ(iValue, 12345);
4323f4cbf05Sopenharmony_ci
4333f4cbf05Sopenharmony_ci    strValue = "123r54";
4343f4cbf05Sopenharmony_ci    result = StrToInt(strValue, iValue);
4353f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
4363f4cbf05Sopenharmony_ci}
4373f4cbf05Sopenharmony_ci
4383f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_StrToInt_02, TestSize.Level0)
4393f4cbf05Sopenharmony_ci{
4403f4cbf05Sopenharmony_ci    string strValue = "-12345";
4413f4cbf05Sopenharmony_ci    int iValue = 0;
4423f4cbf05Sopenharmony_ci    bool result = StrToInt(strValue, iValue);
4433f4cbf05Sopenharmony_ci    EXPECT_EQ(result, true);
4443f4cbf05Sopenharmony_ci    EXPECT_EQ(iValue, -12345);
4453f4cbf05Sopenharmony_ci
4463f4cbf05Sopenharmony_ci    strValue = "123=     54";
4473f4cbf05Sopenharmony_ci    result = StrToInt(strValue, iValue);
4483f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
4493f4cbf05Sopenharmony_ci
4503f4cbf05Sopenharmony_ci    string strvalue2;
4513f4cbf05Sopenharmony_ci    result = StrToInt(strvalue2, iValue);
4523f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
4533f4cbf05Sopenharmony_ci}
4543f4cbf05Sopenharmony_ci
4553f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_StrToInt_03, TestSize.Level0)
4563f4cbf05Sopenharmony_ci{
4573f4cbf05Sopenharmony_ci    string strValue = "2147483648";
4583f4cbf05Sopenharmony_ci    int ivalue = 0;
4593f4cbf05Sopenharmony_ci    bool result = StrToInt(strValue, ivalue);
4603f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
4613f4cbf05Sopenharmony_ci}
4623f4cbf05Sopenharmony_ci
4633f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_StrToInt_04, TestSize.Level0)
4643f4cbf05Sopenharmony_ci{
4653f4cbf05Sopenharmony_ci    string strValue = "             ";
4663f4cbf05Sopenharmony_ci    int iValue = 0;
4673f4cbf05Sopenharmony_ci    bool result = StrToInt(strValue, iValue);
4683f4cbf05Sopenharmony_ci    EXPECT_EQ(result, false);
4693f4cbf05Sopenharmony_ci}
4703f4cbf05Sopenharmony_ci
4713f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strcovertfailed_01, TestSize.Level0)
4723f4cbf05Sopenharmony_ci{
4733f4cbf05Sopenharmony_ci    char test[] = {192, 157, 47, 106, 97, 18, 97, 47, 115, 1, 2};
4743f4cbf05Sopenharmony_ci    string strValue(test);
4753f4cbf05Sopenharmony_ci
4763f4cbf05Sopenharmony_ci    bool ret = IsAsciiString(strValue);
4773f4cbf05Sopenharmony_ci    EXPECT_EQ(ret, false);
4783f4cbf05Sopenharmony_ci
4793f4cbf05Sopenharmony_ci    strValue = "1234";
4803f4cbf05Sopenharmony_ci    ret = IsAsciiString(strValue);
4813f4cbf05Sopenharmony_ci    EXPECT_EQ(ret, true);
4823f4cbf05Sopenharmony_ci
4833f4cbf05Sopenharmony_ci    strValue = "abcde";
4843f4cbf05Sopenharmony_ci    ret = IsAsciiString(strValue);
4853f4cbf05Sopenharmony_ci    EXPECT_EQ(ret, true);
4863f4cbf05Sopenharmony_ci}
4873f4cbf05Sopenharmony_ci
4883f4cbf05Sopenharmony_ci
4893f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strcovert_01, TestSize.Level0)
4903f4cbf05Sopenharmony_ci{
4913f4cbf05Sopenharmony_ci    string strValue = "hello world!";
4923f4cbf05Sopenharmony_ci    u16string str16 = Str8ToStr16(strValue);
4933f4cbf05Sopenharmony_ci    EXPECT_EQ(0, strValue.compare(Str16ToStr8(str16)));
4943f4cbf05Sopenharmony_ci}
4953f4cbf05Sopenharmony_ci
4963f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strcovert_02, TestSize.Level0)
4973f4cbf05Sopenharmony_ci{
4983f4cbf05Sopenharmony_ci    string str8Value = "hello world!";
4993f4cbf05Sopenharmony_ci    u16string str16Result = u"hello world!";
5003f4cbf05Sopenharmony_ci    u16string str16Value = Str8ToStr16(str8Value);
5013f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str16Result.compare(str16Value));
5023f4cbf05Sopenharmony_ci
5033f4cbf05Sopenharmony_ci    str16Result = u"你好";
5043f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Result);
5053f4cbf05Sopenharmony_ci    str16Value = Str8ToStr16(str8Result);
5063f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str16Result.compare(str16Value));
5073f4cbf05Sopenharmony_ci
5083f4cbf05Sopenharmony_ci
5093f4cbf05Sopenharmony_ci    str16Result = u"某某技术有限公司";
5103f4cbf05Sopenharmony_ci    str8Result = Str16ToStr8(str16Result);
5113f4cbf05Sopenharmony_ci    str16Value = Str8ToStr16(str8Result);
5123f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str16Result.compare(str16Value));
5133f4cbf05Sopenharmony_ci}
5143f4cbf05Sopenharmony_ci
5153f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strcovert_03, TestSize.Level0)
5163f4cbf05Sopenharmony_ci{
5173f4cbf05Sopenharmony_ci    string str8Value = "1234567890!@#$%^&*().";
5183f4cbf05Sopenharmony_ci    u16string str16Result = u"1234567890!@#$%^&*().";
5193f4cbf05Sopenharmony_ci    u16string str16Value = Str8ToStr16(str8Value);
5203f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str16Result.compare(str16Value));
5213f4cbf05Sopenharmony_ci
5223f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Value);
5233f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str8Result.compare(str8Value));
5243f4cbf05Sopenharmony_ci}
5253f4cbf05Sopenharmony_ci
5263f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_strcovert_04, TestSize.Level0)
5273f4cbf05Sopenharmony_ci{
5283f4cbf05Sopenharmony_ci    string str8Value = "1234567890!@#$%^&*().qazxswedcvfr,./;'][";
5293f4cbf05Sopenharmony_ci    u16string str16Result = u"1234567890!@#$%^&*().qazxswedcvfr,./;'][";
5303f4cbf05Sopenharmony_ci    u16string str16Value = Str8ToStr16(str8Value);
5313f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str16Result.compare(str16Value));
5323f4cbf05Sopenharmony_ci
5333f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Value);
5343f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str8Result.compare(str8Value));
5353f4cbf05Sopenharmony_ci}
5363f4cbf05Sopenharmony_ci
5373f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getintstrcovert_01, TestSize.Level0)
5383f4cbf05Sopenharmony_ci{
5393f4cbf05Sopenharmony_ci    u16string str16Value = u"你好";
5403f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Value);
5413f4cbf05Sopenharmony_ci    int str8Length = str8Result.length();
5423f4cbf05Sopenharmony_ci    int bufferLen = 255;
5433f4cbf05Sopenharmony_ci    char buffer[bufferLen];
5443f4cbf05Sopenharmony_ci    memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
5453f4cbf05Sopenharmony_ci    int int8Result = Char16ToChar8(str16Value, buffer, bufferLen);
5463f4cbf05Sopenharmony_ci
5473f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str8Result.compare(buffer));
5483f4cbf05Sopenharmony_ci    EXPECT_EQ(str8Length + 1, int8Result);
5493f4cbf05Sopenharmony_ci}
5503f4cbf05Sopenharmony_ci
5513f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getintstrcovert_02, TestSize.Level0)
5523f4cbf05Sopenharmony_ci{
5533f4cbf05Sopenharmony_ci    u16string str16Value = u"某某技术有限公司";
5543f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Value);
5553f4cbf05Sopenharmony_ci    int str8Length = str8Result.length();
5563f4cbf05Sopenharmony_ci    int bufferLen = 255;
5573f4cbf05Sopenharmony_ci    char buffer[bufferLen];
5583f4cbf05Sopenharmony_ci    memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
5593f4cbf05Sopenharmony_ci    int int8Result = Char16ToChar8(str16Value, buffer, bufferLen);
5603f4cbf05Sopenharmony_ci
5613f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str8Result.compare(buffer));
5623f4cbf05Sopenharmony_ci    EXPECT_EQ(str8Length + 1, int8Result);
5633f4cbf05Sopenharmony_ci}
5643f4cbf05Sopenharmony_ci
5653f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getintstrcovert_03, TestSize.Level0)
5663f4cbf05Sopenharmony_ci{
5673f4cbf05Sopenharmony_ci    u16string str16Value = u"hello world!";
5683f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Value);
5693f4cbf05Sopenharmony_ci    int str8Length = str8Result.length();
5703f4cbf05Sopenharmony_ci    int bufferLen = 255;
5713f4cbf05Sopenharmony_ci    char buffer[bufferLen];
5723f4cbf05Sopenharmony_ci    memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
5733f4cbf05Sopenharmony_ci    int int8Result = Char16ToChar8(str16Value, buffer, bufferLen);
5743f4cbf05Sopenharmony_ci
5753f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str8Result.compare(buffer));
5763f4cbf05Sopenharmony_ci    EXPECT_EQ(str8Length + 1, int8Result);
5773f4cbf05Sopenharmony_ci}
5783f4cbf05Sopenharmony_ci
5793f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getintstrcovert_04, TestSize.Level0)
5803f4cbf05Sopenharmony_ci{
5813f4cbf05Sopenharmony_ci    u16string str16Value = u"1234567890!@#$%^&*().";
5823f4cbf05Sopenharmony_ci    string str8Result = Str16ToStr8(str16Value);
5833f4cbf05Sopenharmony_ci    int str8Length = str8Result.length();
5843f4cbf05Sopenharmony_ci    int bufferLen = 255;
5853f4cbf05Sopenharmony_ci    char buffer[bufferLen];
5863f4cbf05Sopenharmony_ci    memset_s(buffer, sizeof(buffer), 0, sizeof(buffer));
5873f4cbf05Sopenharmony_ci    int int8Result = Char16ToChar8(str16Value, buffer, bufferLen);
5883f4cbf05Sopenharmony_ci
5893f4cbf05Sopenharmony_ci    EXPECT_EQ(0, str8Result.compare(buffer));
5903f4cbf05Sopenharmony_ci    EXPECT_EQ(str8Length + 1, int8Result);
5913f4cbf05Sopenharmony_ci}
5923f4cbf05Sopenharmony_ci
5933f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getsubstr_01, TestSize.Level0)
5943f4cbf05Sopenharmony_ci{
5953f4cbf05Sopenharmony_ci    string strBase = "test for {sub str} {sub str1}";
5963f4cbf05Sopenharmony_ci    string left = "{";
5973f4cbf05Sopenharmony_ci    string right = "}";
5983f4cbf05Sopenharmony_ci    string strResult = "sub str";
5993f4cbf05Sopenharmony_ci    string strValue;
6003f4cbf05Sopenharmony_ci    string::size_type pos = GetFirstSubStrBetween(strBase, left, right, strValue);
6013f4cbf05Sopenharmony_ci    EXPECT_EQ(17, (int)pos);
6023f4cbf05Sopenharmony_ci    EXPECT_EQ(strResult, strValue);
6033f4cbf05Sopenharmony_ci
6043f4cbf05Sopenharmony_ci    strBase = "test for sub str} {sub str1}";
6053f4cbf05Sopenharmony_ci    strResult = "sub str1";
6063f4cbf05Sopenharmony_ci    pos = GetFirstSubStrBetween(strBase, left, right, strValue);
6073f4cbf05Sopenharmony_ci    EXPECT_EQ(27, (int)pos);
6083f4cbf05Sopenharmony_ci    EXPECT_EQ(strResult, strValue);
6093f4cbf05Sopenharmony_ci}
6103f4cbf05Sopenharmony_ci
6113f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getsubstr_02, TestSize.Level0)
6123f4cbf05Sopenharmony_ci{
6133f4cbf05Sopenharmony_ci    string strBase = "test for} {sub str {sub str1";
6143f4cbf05Sopenharmony_ci    string left = "{";
6153f4cbf05Sopenharmony_ci    string right = "}";
6163f4cbf05Sopenharmony_ci    string strValue;
6173f4cbf05Sopenharmony_ci    string::size_type pos = GetFirstSubStrBetween(strBase, left, right, strValue);
6183f4cbf05Sopenharmony_ci    EXPECT_EQ(pos, string::npos);
6193f4cbf05Sopenharmony_ci}
6203f4cbf05Sopenharmony_ci
6213f4cbf05Sopenharmony_ci
6223f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getsubstr_03, TestSize.Level0)
6233f4cbf05Sopenharmony_ci{
6243f4cbf05Sopenharmony_ci    string strBase = "test for {sub str} {sub str1}";
6253f4cbf05Sopenharmony_ci    string left = "{";
6263f4cbf05Sopenharmony_ci    string right = "}";
6273f4cbf05Sopenharmony_ci    string strResult[2] = { "sub str", "sub str1" };
6283f4cbf05Sopenharmony_ci    vector<string> strValue;
6293f4cbf05Sopenharmony_ci    GetSubStrBetween(strBase, left, right, strValue);
6303f4cbf05Sopenharmony_ci    for (int i = 0; i < 2; i++) {
6313f4cbf05Sopenharmony_ci        EXPECT_EQ(strResult[i], strValue[i]);
6323f4cbf05Sopenharmony_ci    }
6333f4cbf05Sopenharmony_ci}
6343f4cbf05Sopenharmony_ci
6353f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, test_getsubstr_04, TestSize.Level0)
6363f4cbf05Sopenharmony_ci{
6373f4cbf05Sopenharmony_ci    string strBase = "test for } {sub str {sub str1";
6383f4cbf05Sopenharmony_ci    string left = "{";
6393f4cbf05Sopenharmony_ci    string right = "}";
6403f4cbf05Sopenharmony_ci    string strResult[2] = { "sub str", "sub str1" };
6413f4cbf05Sopenharmony_ci    vector<string> strValue;
6423f4cbf05Sopenharmony_ci    GetSubStrBetween(strBase, left, right, strValue);
6433f4cbf05Sopenharmony_ci    EXPECT_EQ(0, static_cast<int>(strValue.size()));
6443f4cbf05Sopenharmony_ci}
6453f4cbf05Sopenharmony_ci
6463f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, DexToHexString_01, TestSize.Level0)
6473f4cbf05Sopenharmony_ci{
6483f4cbf05Sopenharmony_ci    string result = DexToHexString(0);
6493f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "0");
6503f4cbf05Sopenharmony_ci
6513f4cbf05Sopenharmony_ci    result = DexToHexString(14);
6523f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "E");
6533f4cbf05Sopenharmony_ci
6543f4cbf05Sopenharmony_ci    result = DexToHexString(14, false);
6553f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "e");
6563f4cbf05Sopenharmony_ci
6573f4cbf05Sopenharmony_ci    result = DexToHexString(-14, false);
6583f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "fffffff2");
6593f4cbf05Sopenharmony_ci
6603f4cbf05Sopenharmony_ci    result = DexToHexString(-14);
6613f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "FFFFFFF2");
6623f4cbf05Sopenharmony_ci
6633f4cbf05Sopenharmony_ci    result = DexToHexString(11259375);
6643f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "ABCDEF");
6653f4cbf05Sopenharmony_ci
6663f4cbf05Sopenharmony_ci    result = DexToHexString(11259375, false);
6673f4cbf05Sopenharmony_ci    EXPECT_EQ(result, "abcdef");
6683f4cbf05Sopenharmony_ci}
6693f4cbf05Sopenharmony_ci
6703f4cbf05Sopenharmony_ciHWTEST_F(UtilsStringTest, GetUtf16ToUtf8Length, TestSize.Level0)
6713f4cbf05Sopenharmony_ci{
6723f4cbf05Sopenharmony_ci    string strValue = "hello world";
6733f4cbf05Sopenharmony_ci    u16string str16 = Str8ToStr16(strValue);
6743f4cbf05Sopenharmony_ci    GetUtf16ToUtf8Length(str16);
6753f4cbf05Sopenharmony_ci    ASSERT_EQ(strValue.length(), str16.length());
6763f4cbf05Sopenharmony_ci}
6773f4cbf05Sopenharmony_ci}  // namespace
6783f4cbf05Sopenharmony_ci}  // namespace OHOS