提交 2a632608 编写于 作者: W wenfei

修改包管理测试用例

Signed-off-by: Nwenfei <wenfei9@huawei.com>
上级 59f0faeb
......@@ -53,8 +53,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoLegal, Function | MediumT
AbilityInfo abilityInfo;
int result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo));
TEST_ASSERT_TRUE(result == 0);
abilityInfo.bundleName = "com.openharmony.testjsdemo";
TEST_ASSERT_EQUAL_STRING(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);
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, name);
ClearAbilityInfo(&abilityInfo);
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, NULL);
printf("------end testClearAbilityInfo------\n");
......@@ -71,9 +76,14 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearAbilityInfoIllegal, Function | Mediu
AbilityInfo abilityInfo = { 0 };
int result = memset_s(&abilityInfo, sizeof(abilityInfo), 0, sizeof(abilityInfo));
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);
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, "com.openharmony.testjsdemo");
TEST_ASSERT_EQUAL_STRING(abilityInfo.bundleName, name);
printf("------end testClearAbilityInfoIllegal------\n");
}
......@@ -88,8 +98,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoLegal, Function | MediumTe
BundleInfo bundleInfo = { 0 };
int result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
TEST_ASSERT_TRUE(result == 0);
bundleInfo.bundleName = "com.openharmony.testjsdemo";
TEST_ASSERT_EQUAL_STRING(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);
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, name);
ClearBundleInfo(&bundleInfo);
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, NULL);
printf("------end testClearBundleInfo------\n");
......@@ -106,9 +121,14 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearBundleInfoIllegal, Function | Medium
BundleInfo bundleInfo;
int result = memset_s(&bundleInfo, sizeof(bundleInfo), 0, sizeof(bundleInfo));
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);
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, "com.openharmony.testjsdemo");
TEST_ASSERT_EQUAL_STRING(bundleInfo.bundleName, name);
printf("------end testClearBundleInfoIllegal------\n");
}
......@@ -123,8 +143,13 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoLegal, Function | MediumTe
ModuleInfo moduleInfo = { 0 };
int result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo));
TEST_ASSERT_TRUE(result == 0);
moduleInfo.moduleName = "test";
TEST_ASSERT_EQUAL_STRING(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);
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, name);
ClearModuleInfo(&moduleInfo);
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, NULL);
printf("------end testClearModuleInfo------\n");
......@@ -141,9 +166,14 @@ LITE_TEST_CASE(BundleMgrTestSuite, testClearModuleInfoIllegal, Function | Medium
ModuleInfo moduleInfo = { 0 };
int result = memset_s(&moduleInfo, sizeof(moduleInfo), 0, sizeof(moduleInfo));
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);
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, "test");
TEST_ASSERT_EQUAL_STRING(moduleInfo.moduleName, name);
printf("------end testClearModuleInfoIllegal------\n");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册