mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 10:21:25 -04:00
add length argument of funcation EncodeOsSyscap.
Signed-off-by: yudechen <chenyude@huawei.com> Change-Id: If65b898671e0d035a578e34ba52c442b1a48de80
This commit is contained in:
@@ -14,11 +14,13 @@
|
||||
*/
|
||||
|
||||
#include"syscap_codec_test.h"
|
||||
#include <cstddef>
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace std;
|
||||
|
||||
namespace Syscap {
|
||||
constexpr size_t SYSCAP_STR_LEN_MAX = 128;
|
||||
void SyscapCodecTest::SetUpTestCase() {}
|
||||
|
||||
void SyscapCodecTest::TearDownTestCase() {}
|
||||
@@ -34,8 +36,9 @@ void SyscapCodecTest::TearDown() {}
|
||||
*/
|
||||
HWTEST_F(SyscapCodecTest, EncodeOsSyscap, TestSize.Level1)
|
||||
{
|
||||
char OsInput[MAX_SYSCAP_STR_LEN] = {0};
|
||||
EXPECT_TRUE(EncodeOsSyscap(OsInput));
|
||||
int pcidLen = SYSCAP_STR_LEN_MAX;
|
||||
char OsInput[SYSCAP_STR_LEN_MAX] = {0};
|
||||
EXPECT_TRUE(EncodeOsSyscap(OsInput, pcidLen));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -59,12 +62,12 @@ HWTEST_F(SyscapCodecTest, EncodePrivateSyscap, TestSize.Level1)
|
||||
HWTEST_F(SyscapCodecTest, DecodeOsSyscap, TestSize.Level1)
|
||||
{
|
||||
int osSyscap[32] = {1, 3, 3};
|
||||
char (*osOutput)[MAX_SYSCAP_STR_LEN] = NULL;
|
||||
char (*osOutput)[SYSCAP_STR_LEN_MAX] = NULL;
|
||||
int decodeOsCnt;
|
||||
char expectOsOutput001[] = "SystemCapability.Account.AppAccount";
|
||||
char expectOsOutput002[] = "SystemCapability.Account.OsAccount";
|
||||
EXPECT_TRUE(DecodeOsSyscap((char *)osSyscap, &osOutput, &decodeOsCnt));
|
||||
char (*tmpOsOutput)[MAX_SYSCAP_STR_LEN] = osOutput;
|
||||
char (*tmpOsOutput)[SYSCAP_STR_LEN_MAX] = osOutput;
|
||||
EXPECT_STREQ(*tmpOsOutput, expectOsOutput001);
|
||||
EXPECT_STREQ(*(tmpOsOutput + 1), expectOsOutput002);
|
||||
EXPECT_EQ(decodeOsCnt, 2);
|
||||
@@ -78,7 +81,7 @@ HWTEST_F(SyscapCodecTest, DecodeOsSyscap, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1)
|
||||
{
|
||||
char (*priOutput)[MAX_SYSCAP_STR_LEN] = NULL;
|
||||
char (*priOutput)[SYSCAP_STR_LEN_MAX] = NULL;
|
||||
char priSyscap[] = "Device.syscap1GEDR,Device.syscap2WREGW,Vendor.syscap3RGD,Vendor.syscap4RWEG,Vendor.syscap5REWGWE,";
|
||||
int decodePriCnt;
|
||||
char expectPriOutput001[] = "SystemCapability.Device.syscap1GEDR";
|
||||
@@ -87,7 +90,7 @@ HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1)
|
||||
char expectPriOutput004[] = "SystemCapability.Vendor.syscap4RWEG";
|
||||
char expectPriOutput005[] = "SystemCapability.Vendor.syscap5REWGWE";
|
||||
EXPECT_TRUE(DecodePrivateSyscap(priSyscap, &priOutput, &decodePriCnt));
|
||||
char (*tmpPtiOutput)[MAX_SYSCAP_STR_LEN] = priOutput;
|
||||
char (*tmpPtiOutput)[SYSCAP_STR_LEN_MAX] = priOutput;
|
||||
EXPECT_STREQ(*tmpPtiOutput++, expectPriOutput001);
|
||||
EXPECT_STREQ(*tmpPtiOutput++, expectPriOutput002);
|
||||
EXPECT_STREQ(*tmpPtiOutput++, expectPriOutput003);
|
||||
|
||||
Reference in New Issue
Block a user