!2459 新增tdd用例

Merge pull request !2459 from dingxiaochen/master
This commit is contained in:
openharmony_ci 2024-11-18 02:26:38 +00:00 committed by Gitee
commit 0436b1750a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 161 additions and 0 deletions

View File

@ -1430,6 +1430,43 @@ HWTEST_F(SimTest, Telephony_Sim_TestTelProfileUtil_0100, Function | MediumTest |
EXPECT_NE(telProfileUtil->DeleteProfiles(), -1); EXPECT_NE(telProfileUtil->DeleteProfiles(), -1);
} }
/**
* @tc.number Telephony_Sim_TestTelProfileUtil_0101
* @tc.name TestTelProfileUtil
* @tc.desc Function test
*/
HWTEST_F(SimTest, Telephony_Sim_TestTelProfileUtil_0101, Function | MediumTest | Level3)
{
auto telProfileUtil = DelayedSingleton<TelProfileUtil>::GetInstance();
telProfileUtil->path_ = "";
std::string key = "test";
std::string key1 = "test1";
std::string value = "test";
std::string defValue = "";
int saveValue = 1;
int getValue = 1;
bool saveBool = true;
bool getBool = true;
int64_t longValue = 1;
int64_t getLongValue = 1;
float saveFloatValue = 1;
float getFloatValue = 1;
EXPECT_EQ(telProfileUtil->SaveString(key, value), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->ObtainString(key, defValue), "error");
EXPECT_EQ(telProfileUtil->SaveInt(key, saveValue), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->ObtainInt(key, getValue), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->SaveBool(key, saveBool), NativePreferences::E_ERROR);
EXPECT_TRUE(telProfileUtil->ObtainBool(key, getBool));
EXPECT_EQ(telProfileUtil->SaveLong(key, longValue), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->ObtainLong(key, getLongValue), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->SaveFloat(key1, saveFloatValue), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->ObtainFloat(key1, getFloatValue), NativePreferences::E_ERROR);
EXPECT_TRUE(telProfileUtil->IsExistKey(key));
EXPECT_EQ(telProfileUtil->RemoveKey(key), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->RemoveAll(), NativePreferences::E_ERROR);
EXPECT_EQ(telProfileUtil->RefreshSync(), NativePreferences::E_ERROR);
}
/** /**
* @tc.number Telephony_Sim_TestDump_0100 * @tc.number Telephony_Sim_TestDump_0100
* @tc.name TestDump * @tc.name TestDump

View File

@ -27,6 +27,7 @@
#include "vcard_photo_data.h" #include "vcard_photo_data.h"
#include "vcard_postal_data.h" #include "vcard_postal_data.h"
#include "vcard_relation_data.h" #include "vcard_relation_data.h"
#include "vcard_configuration.h"
#include "vcard_contact.h" #include "vcard_contact.h"
#include "vcard_constant.h" #include "vcard_constant.h"
#include "vcard_decoder_v21.h" #include "vcard_decoder_v21.h"
@ -574,6 +575,129 @@ HWTEST_F(ContactDataTest, VCardDecoderV30_UnescapeChar, Function | MediumTest |
EXPECT_STREQ(decoder.UnescapeChar('X').c_str(), "X"); EXPECT_STREQ(decoder.UnescapeChar('X').c_str(), "X");
} }
HWTEST_F(ContactDataTest, VCardDecoderV30_GetLine_001, Function | MediumTest | Level3)
{
VCardDecoderV30 decoder;
decoder.preLine_ = "";
EXPECT_STREQ(decoder.GetLine().c_str(), "");
decoder.preLine_ = "abc";
EXPECT_STREQ(decoder.preLine_.c_str(), "abc");
}
HWTEST_F(ContactDataTest, VCardDecoderV30_PeekLine_001, Function | MediumTest | Level3)
{
VCardDecoderV30 decoder;
decoder.preLine_ = "";
EXPECT_STREQ(decoder.GetLine().c_str(), "");
}
/**
* @tc.name : DealParamV30_ShouldHandleQuotedValues_WhenQuotedValuesArePresent
* @tc.number: VCardDecoderV30Test_001
* @tc.desc : Test DealParamV30 method when paramValue contains quoted values
*/
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_001, Function | MediumTest | Level3)
{
VCardDecoderV30 decoder;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
int32_t errorCode;
std::string param = "TEST_PARAM";
std::string paramValue = "\"quoted,value\"";
decoder.DealParamV30(param, paramValue, rawData, errorCode);
EXPECT_EQ(rawData->GetParameters(param).size(), 1);
}
/**
* @tc.name : DealParamV30_ShouldHandleNonQuotedValues_WhenNonQuotedValuesArePresent
* @tc.number: VCardDecoderV30Test_002
* @tc.desc : Test DealParamV30 method when paramValue contains non-quoted values
*/
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_002, Function | MediumTest | Level3)
{
VCardDecoderV30 decoder;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
int32_t errorCode;
std::string param = "TEST_PARAM";
std::string paramValue = "non,quoted,value";
decoder.DealParamV30(param, paramValue, rawData, errorCode);
EXPECT_EQ(rawData->GetParameters(param).size(), 3);
}
/**
* @tc.name : DealParamV30_ShouldHandleEmptyValues_WhenValueIsEmpty
* @tc.number: VCardDecoderV30Test_003
* @tc.desc : Test DealParamV30 method when paramValue is empty
*/
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_003, Function | MediumTest | Level3)
{
VCardDecoderV30 decoder;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
int32_t errorCode;
std::string param = "TEST_PARAM";
std::string paramValue = "";
decoder.DealParamV30(param, paramValue, rawData, errorCode);
EXPECT_EQ(rawData->GetParameters(param).size(), 0);
}
/**
* @tc.name : DealParamV30_ShouldHandleNonQuotedValuesWithTrailingComma_WhenTrailingCommaIsPresent
* @tc.number: VCardDecoderV30Test_004
* @tc.desc : Test DealParamV30 method when paramValue contains non-quoted values with trailing comma
*/
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_004, Function | MediumTest | Level3)
{
VCardDecoderV30 decoder;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
int32_t errorCode;
std::string param = "TEST_PARAM";
std::string paramValue = "non,quoted,value,";
decoder.DealParamV30(param, paramValue, rawData, errorCode);
EXPECT_EQ(rawData->GetParameters(param).size(), 3);
}
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParams_001, Function | MediumTest | Level3)
{
int32_t errorCode = TELEPHONY_ERR_VCARD_FILE_INVALID;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
VCardDecoderV30 decoder;
decoder.DealParams("invalid_params", rawData, errorCode);
ASSERT_EQ(errorCode, TELEPHONY_ERR_VCARD_FILE_INVALID);
}
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParams_002, Function | MediumTest | Level3)
{
int32_t errorCode = TELEPHONY_SUCCESS;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
VCardDecoderV30 decoder;
decoder.DealParams("valid_params=value", rawData, errorCode);
ASSERT_EQ(errorCode, TELEPHONY_SUCCESS);
}
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParams_003, Function | MediumTest | Level3)
{
int32_t errorCode = TELEPHONY_SUCCESS;
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
VCardDecoderV30 decoder;
decoder.DealParams("invalid_params", rawData, errorCode);
ASSERT_EQ(errorCode, TELEPHONY_SUCCESS);
}
HWTEST_F(ContactDataTest, VCardConfiguration_IsJapaneseDevice_001, Function | MediumTest | Level3)
{
int32_t vcardType = VCardConfiguration::VCARD_TYPE_V21_JAPANESE;
VCardConfiguration vCardConfig;
bool result = vCardConfig.IsJapaneseDevice(vcardType);
ASSERT_TRUE(result);
}
HWTEST_F(ContactDataTest, VCardConfiguration_IsJapaneseDevice_002, Function | MediumTest | Level3)
{
int32_t vcardType = 2;
VCardConfiguration vCardConfig;
bool result = vCardConfig.IsJapaneseDevice(vcardType);
ASSERT_FALSE(result);
}
HWTEST_F(ContactDataTest, VCardEncoder, Function | MediumTest | Level3) HWTEST_F(ContactDataTest, VCardEncoder, Function | MediumTest | Level3)
{ {
VCardEncoder encoder; VCardEncoder encoder;