From b146df7c382298744457a6fc498d13c78327496d Mon Sep 17 00:00:00 2001 From: Tintin9529 Date: Sat, 21 Sep 2024 16:42:19 +0800 Subject: [PATCH] add pack_info_utils tdd Signed-off-by: Tintin9529 --- .../pack_info_utils_test.cpp | 351 ++++++++++++++++++ 1 file changed, 351 insertions(+) diff --git a/packing_tool/frameworks/test/unittest/json/pack_info_utils_test/pack_info_utils_test.cpp b/packing_tool/frameworks/test/unittest/json/pack_info_utils_test/pack_info_utils_test.cpp index 3bc03a7f..515962fe 100644 --- a/packing_tool/frameworks/test/unittest/json/pack_info_utils_test/pack_info_utils_test.cpp +++ b/packing_tool/frameworks/test/unittest/json/pack_info_utils_test/pack_info_utils_test.cpp @@ -135,6 +135,96 @@ const string PACKING_INFO_STR_2 = "{" "}" "]" "}"; + +const std::string PACKING_INFO_TEST_STRING_NOTHING = "{" +"}"; + +const std::string PACKING_INFO_TEST_STRING_ERROR_1 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}" + "}" +"}"; + +const std::string PACKING_INFO_TEST_STRING_ERROR_2 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}" + "}" +"}"; + +const std::string PACKING_INFO_TEST_STRING_ERROR_3 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"bundleType\": \"bundleApp\"" + "}" + "}" +"}"; + +const std::string PACKING_INFO_TEST_STRING_NOT_SAME_1 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.application\"," + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}" + "}" +"}"; + +const std::string PACKING_INFO_TEST_STRING_NOT_SAME_2 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 2000000," + "\"name\": \"2.0.0\"" + "}" + "}" + "}" +"}"; + +const std::string PACKING_INFO_TEST_STRING_ERROR_4 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}" + "}" +"}"; + +const std::string PACKING_INFO_TEST_STRING_ERROR_5 = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}," + "\"modules\" : []" + "}" +"}"; + } class PackInfoUtilsTest : public testing::Test { @@ -172,6 +262,182 @@ HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0100, Function | MediumTest | Leve EXPECT_TRUE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_STR_1, PACKING_INFO_STR_2, dstPackInfoJsonStr)); } +/* + * @tc.name: MergeTwoPackInfos_0200 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0200, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos("", PACKING_INFO_STR_2, dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0300 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0300, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_STR_1, "", dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0400 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0400, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_NOTHING, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0500 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0500, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_ERROR_1, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0600 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0600, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_STR_1, + PACKING_INFO_TEST_STRING_ERROR_1, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0700 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0700, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_ERROR_2, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0800 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0800, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_ERROR_3, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_0900 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_0900, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_STR_1, + PACKING_INFO_TEST_STRING_ERROR_3, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_1000 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_1000, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_NOT_SAME_1, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_1100 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_1100, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_NOT_SAME_2, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_1200 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_1200, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_ERROR_4, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfos_1300 + * @tc.desc: MergeTwoPackInfos. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfos_1300, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::string dstPackInfoJsonStr; + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfos(PACKING_INFO_TEST_STRING_ERROR_5, + PACKING_INFO_STR_2, + dstPackInfoJsonStr)); +} + /* * @tc.name: MergeTwoPackInfosByPackagePair_0100 * @tc.desc: MergeTwoPackInfosByPackagePair. @@ -188,4 +454,89 @@ HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfosByPackagePair_0100, Function | Medi EXPECT_TRUE(packInfoUtils.MergeTwoPackInfosByPackagePair(PACKING_INFO_STR_1, PACKING_INFO_STR_2, packagesMap, dstPackInfoJsonStr)); } + +/* + * @tc.name: MergeTwoPackInfosByPackagePair_0200 + * @tc.desc: MergeTwoPackInfosByPackagePair. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfosByPackagePair_0200, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::map packagesMap; + std::string dstPackInfoJsonStr = ""; + packagesMap.insert((make_pair("entry-default", "entry"))); + + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfosByPackagePair("", PACKING_INFO_STR_2, + packagesMap, dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfosByPackagePair_0300 + * @tc.desc: MergeTwoPackInfosByPackagePair. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfosByPackagePair_0300, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::map packagesMap; + std::string dstPackInfoJsonStr = ""; + packagesMap.insert((make_pair("entry-default", "entry"))); + + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfosByPackagePair(PACKING_INFO_STR_1, "", + packagesMap, dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfosByPackagePair_0400 + * @tc.desc: MergeTwoPackInfosByPackagePair. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfosByPackagePair_0400, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::map packagesMap; + std::string dstPackInfoJsonStr = ""; + packagesMap.insert((make_pair("entry-default", "entry"))); + + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfosByPackagePair(PACKING_INFO_TEST_STRING_NOTHING, PACKING_INFO_STR_2, + packagesMap, dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfosByPackagePair_0500 + * @tc.desc: MergeTwoPackInfosByPackagePair. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfosByPackagePair_0500, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::map packagesMap; + std::string dstPackInfoJsonStr = ""; + packagesMap.insert((make_pair("entry-default", "entry"))); + + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfosByPackagePair(PACKING_INFO_TEST_STRING_ERROR_4, PACKING_INFO_STR_2, + packagesMap, dstPackInfoJsonStr)); +} + +/* + * @tc.name: MergeTwoPackInfosByPackagePair_0600 + * @tc.desc: MergeTwoPackInfosByPackagePair. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PackInfoUtilsTest, MergeTwoPackInfosByPackagePair_0600, Function | MediumTest | Level1) +{ + OHOS::AppPackingTool::PackInfoUtils packInfoUtils; + std::map packagesMap; + std::string dstPackInfoJsonStr = ""; + packagesMap.insert((make_pair("entry-default", "entry"))); + + EXPECT_FALSE(packInfoUtils.MergeTwoPackInfosByPackagePair(PACKING_INFO_TEST_STRING_ERROR_5, PACKING_INFO_STR_2, + packagesMap, dstPackInfoJsonStr)); +} } -- Gitee