• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 #define private public
18 #define protected public
19 #include "sms_persist_helper.h"
20 #include "string_utils.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 using namespace testing::ext;
25 constexpr uint32_t EVENT_RELEASE_DATA_SHARE_HELPER = 10000;
26 
27 class SmsUtilsTest : public testing::Test {
28 public:
SetUpTestCase()29     static void SetUpTestCase()
30     {}
TearDownTestCase()31     static void TearDownTestCase()
32     {
33         DelayedSingleton<SmsPersistHelper>::GetInstance()->RemoveEvent(EVENT_RELEASE_DATA_SHARE_HELPER);
34     }
SetUp()35     void SetUp()
36     {}
TearDown()37     void TearDown()
38     {}
39 };
40 
41 /**
42  * @tc.number   Telephony_SmsUtilsTest_SmsUtilsTest_001
43  * @tc.name     SmsUtilsTest_001
44  * @tc.desc     Function test
45  */
46 HWTEST_F(SmsUtilsTest, SmsUtilsTest_001, Function | MediumTest | Level1)
47 {
48     std::string str = "Abcd0";
49     auto vect = StringUtils::HexToByteVector(str);
50     EXPECT_NE(vect.size(), 0);
51 }
52 
53 /**
54  * @tc.number   Telephony_SmsUtilsTest_SmsUtilsTest_002
55  * @tc.name     SmsUtilsTest_002
56  * @tc.desc     Function test
57  */
58 HWTEST_F(SmsUtilsTest, SmsUtilsTest_002, Function | MediumTest | Level1)
59 {
60     std::string str = "";
61     EXPECT_TRUE(StringUtils::IsEmpty(str));
62     str = "abc";
63     EXPECT_FALSE(StringUtils::IsEmpty(str));
64 }
65 }
66 }