提交 07e1e38a 编写于 作者: S shilei

add

Signed-off-by: Nshilei <shilei91@huawei.com>
上级 a5552a66
...@@ -53,8 +53,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoLegal, Function | MediumT ...@@ -53,8 +53,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoLegal, Function | MediumT
AbilityInfo abilityInfo; AbilityInfo abilityInfo;
int result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo)); int result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo));
TEST_ASSERT_TRUE(result == 0); TEST_ASSERT_TRUE(result == 0);
abilityInfo.bundleName = "com.openharmony.testjsdemo"; char *name = "com.openharmony.testjsdemo";
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, "com.openharmony.testjsdemo"); size_t len = strlen(name);
abilityInfo.bundleName = (char *)malloc(len + 1);
TEST_ASSERT_NOT_NULL(abilityInfo.bundleName);
errno_t err = strncpy_s(abilityInfo.bundleName, len + 1, name, len);
TEST_ASSERT_EQUAL(err, EOK);
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, name);
ClearAbilityInfo(&abilityInfo); ClearAbilityInfo(&abilityInfo);
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, NULL); TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, NULL);
printf("------end testClearAbilityInfo------\n"); printf("------end testClearAbilityInfo------\n");
...@@ -71,9 +76,15 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoIllegal, Function | Mediu ...@@ -71,9 +76,15 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoIllegal, Function | Mediu
AbilityInfo abilityInfo = { 0 }; AbilityInfo abilityInfo = { 0 };
int result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo)); int result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo));
TEST_ASSERT_TRUE(result == 0); TEST_ASSERT_TRUE(result == 0);
abilityInfo.bundleName = "com.openharmony.testjsdemo"; char *name = "com.openharmony.testjsdemo";
size_t len = strlen(name);
abilityInfo.bundleName = (char *)malloc(len + 1);
TEST_ASSERT_NOT_NULL(abilityInfo.bundleName);
errno_t err = strncpy_s(abilityInfo.bundleName, len + 1, name, len);
TEST_ASSERT_EQUAL(err, EOK);
ClearAbilityInfo(NULL); ClearAbilityInfo(NULL);
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, "com.openharmony.testjsdemo"); TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, name);
free(abilityInfo.bundleName);
printf("------end testClearAbilityInfoIllegal------\n"); printf("------end testClearAbilityInfoIllegal------\n");
} }
...@@ -88,8 +99,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoLegal, Function | MediumTe ...@@ -88,8 +99,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoLegal, Function | MediumTe
BundleInfo bundleInfo = { 0 }; BundleInfo bundleInfo = { 0 };
int result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo)); int result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
TEST_ASSERT_TRUE(result == 0); TEST_ASSERT_TRUE(result == 0);
bundleInfo.bundleName = "com.openharmony.testjsdemo"; char *name = "com.openharmony.testjsdemo";
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, "com.openharmony.testjsdemo"); size_t len = strlen(name);
bundleInfo.bundleName = (char *)malloc(len + 1);
TEST_ASSERT_NOT_NULL(bundleInfo.bundleName);
errno_t err = strncpy_s(bundleInfo.bundleName, len + 1, name, len);
TEST_ASSERT_EQUAL(err, EOK);
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, name);
ClearBundleInfo(&bundleInfo); ClearBundleInfo(&bundleInfo);
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, NULL); TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, NULL);
printf("------end testClearBundleInfo------\n"); printf("------end testClearBundleInfo------\n");
...@@ -106,9 +122,15 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoIllegal, Function | Medium ...@@ -106,9 +122,15 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoIllegal, Function | Medium
BundleInfo bundleInfo; BundleInfo bundleInfo;
int result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo)); int result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
TEST_ASSERT_TRUE(result == 0); TEST_ASSERT_TRUE(result == 0);
bundleInfo.bundleName = "com.openharmony.testjsdemo"; char *name = "com.openharmony.testjsdemo";
size_t len = strlen(name);
bundleInfo.bundleName = (char *)malloc(len + 1);
TEST_ASSERT_NOT_NULL(bundleInfo.bundleName);
errno_t err = strncpy_s(bundleInfo.bundleName, len + 1, name, len);
TEST_ASSERT_EQUAL(err, EOK);
ClearBundleInfo(NULL); ClearBundleInfo(NULL);
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, "com.openharmony.testjsdemo"); TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, name);
free(bundleInfo.bundleName);
printf("------end testClearBundleInfoIllegal------\n"); printf("------end testClearBundleInfoIllegal------\n");
} }
...@@ -123,8 +145,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoLegal, Function | MediumTe ...@@ -123,8 +145,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoLegal, Function | MediumTe
ModuleInfo moduleInfo = { 0 }; ModuleInfo moduleInfo = { 0 };
int result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo)); int result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo));
TEST_ASSERT_TRUE(result == 0); TEST_ASSERT_TRUE(result == 0);
moduleInfo.moduleName = "test"; char *name = "test";
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, "test"); size_t len = strlen(name);
moduleInfo.moduleName = (char *)malloc(len + 1);
TEST_ASSERT_NOT_NULL(moduleInfo.moduleName);
errno_t err = strncpy_s(moduleInfo.moduleName, len + 1, name, len);
TEST_ASSERT_EQUAL(err, EOK);
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, name);
ClearModuleInfo(&moduleInfo); ClearModuleInfo(&moduleInfo);
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, NULL); TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, NULL);
printf("------end testClearModuleInfo------\n"); printf("------end testClearModuleInfo------\n");
...@@ -141,9 +168,15 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoIllegal, Function | Medium ...@@ -141,9 +168,15 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoIllegal, Function | Medium
ModuleInfo moduleInfo = { 0 }; ModuleInfo moduleInfo = { 0 };
int result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo)); int result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo));
TEST_ASSERT_TRUE(result == 0); TEST_ASSERT_TRUE(result == 0);
moduleInfo.moduleName = "test"; char *name = "test";
size_t len = strlen(name);
moduleInfo.moduleName = (char *)malloc(len + 1);
TEST_ASSERT_NOT_NULL(moduleInfo.moduleName);
errno_t err = strncpy_s(moduleInfo.moduleName, len + 1, name, len);
TEST_ASSERT_EQUAL(err, EOK);
ClearModuleInfo(NULL); ClearModuleInfo(NULL);
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, "test"); TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, name);
free(moduleInfo.moduleName);
printf("------end testClearModuleInfoIllegal------\n"); printf("------end testClearModuleInfoIllegal------\n");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册