• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #define private public
17 #define protected public
18 
19 #include <vector>
20 
21 #include "gsm_pdu_hex_value.h"
22 #include "gsm_sms_common_utils.h"
23 #include "gtest/gtest.h"
24 #include "ims_sms_client.h"
25 #include "sms_common_utils.h"
26 #include "sms_persist_helper.h"
27 #include "text_coder.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 using namespace testing::ext;
32 
33 namespace {
34 const std::string TEXT_SMS_CONTENT = "hello world";
35 const int BUF_SIZE = 2401;
36 const int TEXT_LENGTH = 2;
37 const int FILL_BITS = 2;
38 const int DIGIT_LEN = 3;
39 const int DIGIT_LEN2 = 6;
40 const unsigned char SRC_TEXT = 2;
41 } // namespace
42 
43 class BranchUtilsTest : public testing::Test {
44 public:
45     static void SetUpTestCase();
46     static void TearDownTestCase();
47     void SetUp();
48     void TearDown();
49 };
SetUpTestCase()50 void BranchUtilsTest::SetUpTestCase() {}
51 
52 constexpr uint32_t EVENT_RELEASE_DATA_SHARE_HELPER = 10000;
TearDownTestCase()53 void BranchUtilsTest::TearDownTestCase()
54 {
55     DelayedSingleton<ImsSmsClient>::GetInstance()->UnInit();
56     DelayedSingleton<SmsPersistHelper>::GetInstance()->RemoveEvent(EVENT_RELEASE_DATA_SHARE_HELPER);
57 }
58 
SetUp()59 void BranchUtilsTest::SetUp() {}
60 
TearDown()61 void BranchUtilsTest::TearDown() {}
62 
63 /**
64  * @tc.number   Telephony_SmsMmsGtest_TextCoder_0001
65  * @tc.name     Test TextCoder
66  * @tc.desc     Function test
67  */
68 HWTEST_F(BranchUtilsTest, TextCoder_0001, Function | MediumTest | Level1)
69 {
70     DataCodingScheme DataCodingScheme;
71     MsgLangInfo msgLangInfo;
72     unsigned char encodeData[BUF_SIZE];
73     MSG_LANGUAGE_ID_T langId = 0;
74     bool unknown = false;
75     unsigned short inText = 1;
76     const uint8_t *pMsgText = (const uint8_t *)TEXT_SMS_CONTENT.c_str();
77     uint8_t *pDestText = encodeData;
78     SmsCodingNationalType codingNational = SMS_CODING_NATIONAL_TYPE_DEFAULT;
79     EXPECT_GE(TextCoder::Instance().Utf8ToGsm7bit(pDestText, BUF_SIZE, const_cast<uint8_t *>(pMsgText), 0, langId), 0);
80     EXPECT_GE(TextCoder::Instance().CdmaUtf8ToAuto(pDestText, 1, pMsgText, 1, DataCodingScheme), -1);
81     EXPECT_GE(TextCoder::Instance().GsmUtf8ToAuto(pDestText, 1, pMsgText, 1,
82         DataCodingScheme, codingNational, langId), -1);
83     EXPECT_EQ(TextCoder::Instance().Utf8ToUcs2(pDestText, 1, pMsgText, -1), -1);
84     EXPECT_EQ(TextCoder::Instance().Utf8ToUcs2(pDestText, 0, pMsgText, -1), 0);
85     EXPECT_EQ(TextCoder::Instance().CdmaUtf8ToAuto(pDestText, 1, pMsgText, 0, DataCodingScheme), 0);
86     EXPECT_EQ(TextCoder::Instance().GsmUtf8ToAuto(pDestText, 1, pMsgText, 0,
87         DataCodingScheme, codingNational, langId), 0);
88     EXPECT_EQ(TextCoder::Instance().Gsm7bitToUtf8(pDestText, 0, pMsgText, 0, msgLangInfo), 0);
89     EXPECT_GE(TextCoder::Instance().ShiftjisToUtf8(pDestText, 1, pMsgText, -1), 0);
90     EXPECT_GE(TextCoder::Instance().Ucs2ToUtf8(pDestText, 1, pMsgText, -1), 0);
91     EXPECT_GE(TextCoder::Instance().EuckrToUtf8(pDestText, 1, pMsgText, -1), 0);
92     EXPECT_FALSE(TextCoder::Instance().Ucs2ToUtf8(pDestText, 0, pMsgText, 0));
93     EXPECT_FALSE(TextCoder::Instance().EuckrToUtf8(pDestText, 0, pMsgText, 1));
94     EXPECT_FALSE(TextCoder::Instance().ShiftjisToUtf8(pDestText, 0, pMsgText, 1));
95     EXPECT_EQ(TextCoder::Instance().Ucs2ToGsm7bit(pDestText, 0, pMsgText, 0, langId), -1);
96     EXPECT_GT(TextCoder::Instance().Ucs2ToGsm7bit(pDestText, 1, pMsgText, TEXT_LENGTH, langId), 0);
97     EXPECT_EQ(TextCoder::Instance().Ucs2ToGsm7bitAuto(pDestText, 0, pMsgText, 0, unknown, codingNational), -1);
98     EXPECT_GE(TextCoder::Instance().Ucs2ToGsm7bitAuto(pDestText, 1, pMsgText, 1, unknown, codingNational), 0);
99     EXPECT_EQ(TextCoder::Instance().Ucs2ToAscii(pDestText, 0, pMsgText, 0, unknown), -1);
100     EXPECT_GE(TextCoder::Instance().Ucs2ToAscii(pDestText, 1, pMsgText, 1, unknown), 0);
101     EXPECT_EQ(TextCoder::Instance().GetLangType(pMsgText, 0), MSG_DEFAULT_CHAR);
102     EXPECT_GE(TextCoder::Instance().GetLangType(pMsgText, 0), MSG_DEFAULT_CHAR);
103     EXPECT_EQ(TextCoder::Instance().FindGsm7bitExt(pDestText, 0, inText), 0);
104     EXPECT_GE(TextCoder::Instance().FindGsm7bitExt(pDestText, 1, inText), 0);
105     EXPECT_EQ(TextCoder::Instance().FindTurkish(pDestText, 0, inText), 0);
106     EXPECT_GE(TextCoder::Instance().FindTurkish(pDestText, 1, inText), 0);
107     EXPECT_EQ(TextCoder::Instance().FindSpanish(pDestText, 0, inText), 0);
108     EXPECT_GE(TextCoder::Instance().FindSpanish(pDestText, 1, inText), 0);
109     EXPECT_EQ(TextCoder::Instance().FindPortu(pDestText, 0, inText), 0);
110     EXPECT_GE(TextCoder::Instance().FindPortu(pDestText, 1, inText), 0);
111     EXPECT_GE(TextCoder::Instance().FindReplaceChar(inText), MSG_DEFAULT_CHAR);
112     auto extMap = TextCoder::Instance().Get7BitCodingExtMap(codingNational);
113     EXPECT_GE(extMap.size(), 0);
114 }
115 
116 /**
117  * @tc.number   Telephony_SmsMmsGtest_TextCoder_0002
118  * @tc.name     Test TextCoder
119  * @tc.desc     Function test
120  */
121 HWTEST_F(BranchUtilsTest, TextCoder_0002, Function | MediumTest | Level1)
122 {
123     MsgLangInfo pLangInfo;
124     pLangInfo.bLockingShift = true;
125     pLangInfo.bSingleShift = true;
126     unsigned char encodeData[BUF_SIZE];
127     unsigned short result = 1;
128     const uint8_t *pMsgText = (const uint8_t *)TEXT_SMS_CONTENT.c_str();
129     uint8_t *pDestText = encodeData;
130     EXPECT_EQ(TextCoder::Instance().Gsm7bitToUcs2(pDestText, 0, pMsgText, 0, pLangInfo), -1);
131     pLangInfo.lockingLang = MSG_ID_TURKISH_LANG;
132     EXPECT_GE(TextCoder::Instance().Gsm7bitToUcs2(pDestText, 1, pMsgText, 1, pLangInfo), 0);
133     EXPECT_GT(TextCoder::Instance().EscapeToUcs2(SRC_TEXT, pLangInfo), 0);
134     pLangInfo.lockingLang = MSG_ID_PORTUGUESE_LANG;
135     EXPECT_GE(TextCoder::Instance().Gsm7bitToUcs2(pDestText, 1, pMsgText, 1, pLangInfo), 0);
136     EXPECT_GT(TextCoder::Instance().EscapeToUcs2(SRC_TEXT, pLangInfo), 0);
137     pLangInfo.bLockingShift = false;
138     EXPECT_GE(TextCoder::Instance().Gsm7bitToUcs2(pDestText, 1, pMsgText, 1, pLangInfo), 0);
139     EXPECT_EQ(TextCoder::Instance().EscapeTurkishLockingToUcs2(pMsgText, 0, pLangInfo, result), 0);
140     EXPECT_EQ(TextCoder::Instance().EscapeTurkishLockingToUcs2(pMsgText, 1, pLangInfo, result), 0);
141     EXPECT_EQ(TextCoder::Instance().EscapePortuLockingToUcs2(pMsgText, 0, pLangInfo, result), 0);
142     EXPECT_EQ(TextCoder::Instance().EscapePortuLockingToUcs2(pMsgText, 1, pLangInfo, result), 0);
143     EXPECT_EQ(TextCoder::Instance().EscapeGsm7bitToUcs2(pMsgText, 0, pLangInfo, result), 0);
144     EXPECT_EQ(TextCoder::Instance().EscapeGsm7bitToUcs2(pMsgText, 1, pLangInfo, result), 0);
145     pLangInfo.singleLang = MSG_ID_SPANISH_LANG;
146     EXPECT_GT(TextCoder::Instance().EscapeToUcs2(SRC_TEXT, pLangInfo), 0);
147     pLangInfo.singleLang = MSG_ID_RESERVED_LANG;
148     EXPECT_GT(TextCoder::Instance().EscapeToUcs2(SRC_TEXT, pLangInfo), 0);
149     pLangInfo.bSingleShift = false;
150     EXPECT_GT(TextCoder::Instance().EscapeToUcs2(SRC_TEXT, pLangInfo), 0);
151     std::string convertCharseInput = "123ascQ世界!@";
152     std::string convertCharseOUtput = "";
153     std::string convertCharseOUtputContrasts = "123ascQ荳也阜!@";
154     uint32_t valLength = convertCharseInput.length();
155     EXPECT_GE(TextCoder::Instance().GetEncodeString(convertCharseOUtput, 17, valLength, convertCharseInput), true);
156     EXPECT_GE(convertCharseOUtput, convertCharseOUtputContrasts);
157 }
158 
159 /**
160  * @tc.number   Telephony_SmsMmsGtest_TextCoder_0003
161  * @tc.name     Test TextCoder
162  * @tc.desc     Function test
163  */
164 HWTEST_F(BranchUtilsTest, TextCoder_0003, Function | MediumTest | Level1)
165 {
166     MSG_LANGUAGE_ID_T langId = 0;
167     MsgLangInfo pLangInfo;
168     pLangInfo.bLockingShift = true;
169     pLangInfo.bSingleShift = true;
170     unsigned char encodeData[BUF_SIZE];
171     unsigned short result = 1;
172     const uint8_t *pMsgText = (const uint8_t *)TEXT_SMS_CONTENT.c_str();
173     uint8_t *pDestText = encodeData;
174     EXPECT_EQ(TextCoder::Instance().Utf8ToGsm7bit(nullptr, 0, nullptr, -1, langId), 0);
175     EXPECT_EQ(TextCoder::Instance().Utf8ToGsm7bit(nullptr, 1, pMsgText, -1, langId), 0);
176     EXPECT_EQ(TextCoder::Instance().Utf8ToGsm7bit(pDestText, 0, pMsgText, 0, langId), 0);
177     EXPECT_EQ(TextCoder::Instance().Utf8ToGsm7bit(pDestText, 0, pMsgText, 1, langId), 0);
178     EXPECT_EQ(TextCoder::Instance().Gsm7bitToUcs2(nullptr, 0, nullptr, -1, pLangInfo), -1);
179     EXPECT_EQ(TextCoder::Instance().Gsm7bitToUcs2(nullptr, 1, pMsgText, -1, pLangInfo), -1);
180     EXPECT_EQ(TextCoder::Instance().Gsm7bitToUcs2(pDestText, 0, pMsgText, 0, pLangInfo), -1);
181     EXPECT_EQ(TextCoder::Instance().Gsm7bitToUcs2(pDestText, 0, pMsgText, 1, pLangInfo), -1);
182     EXPECT_EQ(TextCoder::Instance().Utf8ToUcs2(nullptr, 0, nullptr, -1), 0);
183     EXPECT_EQ(TextCoder::Instance().Utf8ToUcs2(nullptr, 1, pMsgText, -1), 0);
184     EXPECT_EQ(TextCoder::Instance().Utf8ToUcs2(pDestText, 0, pMsgText, 0), 0);
185     EXPECT_EQ(TextCoder::Instance().Utf8ToUcs2(pDestText, 0, pMsgText, 1), 0);
186     EXPECT_EQ(TextCoder::Instance().Get7BitCodingExtMap(SMS_CODING_NATIONAL_TYPE_DEFAULT),
187         TextCoder::Instance().gsm7bitExtMap_);
188     EXPECT_EQ(TextCoder::Instance().Get7BitCodingExtMap(SMS_CODING_NATIONAL_TYPE_TURKISH),
189         TextCoder::Instance().turkishMap_);
190     EXPECT_EQ(TextCoder::Instance().Get7BitCodingExtMap(SMS_CODING_NATIONAL_TYPE_SPANISH),
191         TextCoder::Instance().spanishMap_);
192     EXPECT_EQ(TextCoder::Instance().Get7BitCodingExtMap(SMS_CODING_NATIONAL_TYPE_PORTUGUESE),
193         TextCoder::Instance().portuMap_);
194 }
195 
196 /**
197  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0001
198  * @tc.name     Test SmsCommonUtils
199  * @tc.desc     Function test
200  */
201 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0001, Function | MediumTest | Level1)
202 {
203     auto smsCommonUtils = std::make_shared<SmsCommonUtils>();
204     const unsigned char *userData = (const unsigned char *)TEXT_SMS_CONTENT.c_str();
205     const std::string str = "*#PPQQ";
206     const char *digit = (const char *)str.c_str();
207     unsigned char *packData = (unsigned char *)TEXT_SMS_CONTENT.c_str();
208     EXPECT_EQ(smsCommonUtils->Pack7bitChar(nullptr, 0, 0, nullptr, 0), 0);
209     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(nullptr, 1, 1, nullptr, 1), 0);
210     EXPECT_EQ(smsCommonUtils->Pack7bitChar(userData, 1, 0, packData, 1), 1);
211     EXPECT_EQ(smsCommonUtils->Pack7bitChar(userData, 1, 1, packData, 1), 1);
212     EXPECT_EQ(smsCommonUtils->Pack7bitChar(userData, 1, FILL_BITS, packData, 1), 1);
213     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(userData, 1, 0, packData, 1), 0);
214     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(userData, 1, FILL_BITS, packData, 1), 0);
215     EXPECT_EQ(smsCommonUtils->DigitToDtmfChar('*'), static_cast<char>(0x0B));
216     EXPECT_EQ(smsCommonUtils->DtmfCharToDigit(static_cast<char>(0x0B)), '*');
217 
218     auto gsmUtils = std::make_shared<GsmSmsCommonUtils>();
219     uint8_t len;
220     EXPECT_EQ(gsmUtils->DigitToBcd(digit, 1, nullptr, 0, len), 0);
221     EXPECT_EQ(gsmUtils->DigitToBcd(nullptr, 1, packData, 1, len), 0);
222     EXPECT_FALSE(gsmUtils->DigitToBcd(digit, DIGIT_LEN, packData, 1, len));
223     std::string digits;
224     EXPECT_EQ(gsmUtils->BcdToDigit(userData, 1, digits, 1), 0);
225     EXPECT_EQ(gsmUtils->BcdToDigit(nullptr, 1, digits, 1), 0);
226 }
227 
228 /**
229  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0002
230  * @tc.name     Test SmsCommonUtils DigitToBcd support for +*#
231  * @tc.desc     Function test
232  */
233 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0002, Function | MediumTest | Level1)
234 {
235     // input data with pure number
236     const std::string packDataStr = "hello world";
237     const std::string digitTestStr = "17288424569";
238     const char *digit = (const char *)digitTestStr.c_str();
239     unsigned char *packData = (unsigned char *)packDataStr.c_str();
240     auto gsmUtils = std::make_shared<GsmSmsCommonUtils>();
241     EXPECT_NE(gsmUtils, nullptr);
242     uint8_t len = static_cast<uint8_t>(DIGIT_LEN);
243     EXPECT_FALSE(gsmUtils->DigitToBcd(digit, DIGIT_LEN, packData, DIGIT_LEN, len));
244     EXPECT_FALSE(gsmUtils->DigitToBcd(digit, DIGIT_LEN, packData, DIGIT_LEN - 1, len));
245     len = 0;
246     EXPECT_TRUE(gsmUtils->DigitToBcd(digit, DIGIT_LEN2, packData, DIGIT_LEN2, len));
247     std::vector<uint8_t> userDataVec(packData, packData + DIGIT_LEN2);
248     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), 0x71) != userDataVec.end());
249     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), 0x82) != userDataVec.end());
250 }
251 
252 /**
253  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0003
254  * @tc.name     Test SmsCommonUtils DigitToBcd
255  * @tc.desc     Function test
256  */
257 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0003, Function | MediumTest | Level1)
258 {
259     // input data with number and +
260     const std::string packDataStr = "hello world";
261     const std::string digitTestStr = "+17288424569";
262     const char *digit = (const char *)digitTestStr.c_str();
263     unsigned char *packData = (unsigned char *)packDataStr.c_str();
264     auto gsmUtils = std::make_shared<GsmSmsCommonUtils>();
265     EXPECT_NE(gsmUtils, nullptr);
266     uint8_t len;
267     EXPECT_TRUE(gsmUtils->DigitToBcd(digit, DIGIT_LEN2, packData, DIGIT_LEN2, len));
268     std::vector<uint8_t> userDataVec(packData, packData + DIGIT_LEN2);
269     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), 0x78) != userDataVec.end());
270     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), 0x27) != userDataVec.end());
271 }
272 
273 /**
274  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0004
275  * @tc.name     Test SmsCommonUtils DigitToBcd
276  * @tc.desc     Function test
277  */
278 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0004, Function | MediumTest | Level1)
279 {
280     // input data with number and #
281     const std::string packDataStr = "hello world";
282     const std::string digitTestStr = "#17288424569";
283     const char *digit = (const char *)digitTestStr.c_str();
284     unsigned char *packData = (unsigned char *)packDataStr.c_str();
285     auto gsmUtils = std::make_shared<GsmSmsCommonUtils>();
286     EXPECT_NE(gsmUtils, nullptr);
287     uint8_t len;
288     EXPECT_TRUE(gsmUtils->DigitToBcd(digit, DIGIT_LEN2, packData, DIGIT_LEN2, len));
289     std::vector<uint8_t> userDataVec(packData, packData + DIGIT_LEN2);
290     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), 0x1b) != userDataVec.end());
291 }
292 
293 /**
294  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0005
295  * @tc.name     Test SmsCommonUtils DigitToBcd
296  * @tc.desc     Function test
297  */
298 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0005, Function | MediumTest | Level1)
299 {
300     // input data with # and *
301     const std::string packDataStr = "hello world";
302     const std::string digitTestStr = "*0#0765";
303     const char *digit = (const char *)digitTestStr.c_str();
304     unsigned char *packData = (unsigned char *)packDataStr.c_str();
305     auto gsmUtils = std::make_shared<GsmSmsCommonUtils>();
306     EXPECT_NE(gsmUtils, nullptr);
307     uint8_t len;
308     EXPECT_TRUE(gsmUtils->DigitToBcd(digit, DIGIT_LEN2, packData, DIGIT_LEN2, len));
309     std::vector<uint8_t> userDataVec(packData, packData + DIGIT_LEN2);
310     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), HEX_VALUE_0B) != userDataVec.end());
311     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(), HEX_VALUE_0A) != userDataVec.end());
312 }
313 
314 /**
315  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0006
316  * @tc.name     Test SmsCommonUtils DigitToBcd
317  * @tc.desc     Function test
318  */
319 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0006, Function | MediumTest | Level1)
320 {
321     // input data with # and *
322     const std::string packDataStr = "hello world";
323     const std::string digitTestStr = "*21#13105550020#";
324     const char *digit = (const char *)digitTestStr.c_str();
325     unsigned char *packData = (unsigned char *)packDataStr.c_str();
326     auto gsmUtils = std::make_shared<GsmSmsCommonUtils>();
327     EXPECT_NE(gsmUtils, nullptr);
328     uint8_t len;
329     EXPECT_TRUE(gsmUtils->DigitToBcd(digit, DIGIT_LEN2, packData, DIGIT_LEN2, len));
330     std::vector<uint8_t> userDataVec(packData, packData + DIGIT_LEN2);
331     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(),  0x2a) != userDataVec.end());
332     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(),  0xb1) != userDataVec.end());
333     EXPECT_TRUE(std::find(userDataVec.begin(), userDataVec.end(),  0x6f) != userDataVec.end());
334 }
335 
336 /**
337  * @tc.number   Telephony_SmsMmsGtest_SmsCommonUtils_0007
338  * @tc.name     Test SmsCommonUtils DigitToBcd
339  * @tc.desc     Function test
340  */
341 HWTEST_F(BranchUtilsTest, SmsCommonUtils_0007, Function | MediumTest | Level1)
342 {
343     auto smsCommonUtils = std::make_shared<SmsCommonUtils>();
344     const uint8_t *userData = reinterpret_cast<const uint8_t *>("hello");
345     uint8_t *packData = static_cast<uint8_t *>(malloc(1));
346     uint8_t *nullData = nullptr;
347     EXPECT_EQ(smsCommonUtils->Pack7bitChar(userData, 161, 0, packData, 1), 0);
348     EXPECT_EQ(smsCommonUtils->Pack7bitChar(nullptr, 161, 0, packData, 1), 0);
349     EXPECT_EQ(smsCommonUtils->Pack7bitChar(userData, 161, 0, nullData, 1), 0);
350     EXPECT_EQ(smsCommonUtils->Pack7bitChar(nullptr, 161, 0, packData, 1), 0);
351     EXPECT_EQ(smsCommonUtils->Pack7bitChar(nullptr, 0, 0, packData, 1), 0);
352     EXPECT_EQ(smsCommonUtils->Pack7bitChar(userData, 0, 0, nullData, 1), 0);
353     EXPECT_EQ(smsCommonUtils->Pack7bitChar(nullptr, 0, 0, packData, 1), 0);
354 
355     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(userData, 1, 0, packData, 1), 0);
356     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(nullptr, 1, 0, packData, 1), 0);
357     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(userData, 1, 0, nullData, 1), 0);
358     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(nullptr, 1, 0, packData, 1), 0);
359     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(nullptr, 0, 0, packData, 1), 0);
360     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(userData, 0, 0, nullData, 1), 0);
361     EXPECT_EQ(smsCommonUtils->Unpack7bitChar(nullptr, 0, 0, packData, 1), 0);
362 
363     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(userData, 1, 0, packData, 1), 0);
364     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(nullptr, 1, 0, packData, 1), 0);
365     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(userData, 1, 0, nullData, 1), 0);
366     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(nullptr, 1, 0, packData, 1), 0);
367     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(nullptr, 0, 0, packData, 1), 0);
368     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(userData, 0, 0, nullData, 1), 0);
369     EXPECT_EQ(smsCommonUtils->Unpack7bitCharForCBPdu(nullptr, 0, 0, packData, 1), 0);
370 
371     EXPECT_EQ(smsCommonUtils->DtmfCharToDigit(smsCommonUtils->DigitToDtmfChar('0')), '0');
372     EXPECT_EQ(smsCommonUtils->DtmfCharToDigit(smsCommonUtils->DigitToDtmfChar('#')), '#');
373     free(packData);
374 }
375 } // namespace Telephony
376 } // namespace OHOS
377