From 70f15fa8b72367edf014a18facc8f07f1d7dc1fe Mon Sep 17 00:00:00 2001 From: jaychao Date: Tue, 5 Dec 2023 13:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8DTDD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jaychao --- .../backup_utils/b_error/b_error_test.cpp | 272 ++++++++++++++++++ 1 file changed, 272 insertions(+) diff --git a/tests/unittests/backup_utils/b_error/b_error_test.cpp b/tests/unittests/backup_utils/b_error/b_error_test.cpp index be2638eae..d48c401d7 100644 --- a/tests/unittests/backup_utils/b_error/b_error_test.cpp +++ b/tests/unittests/backup_utils/b_error/b_error_test.cpp @@ -93,6 +93,98 @@ HWTEST_F(BErrorTest, b_error_construction_0500, testing::ext::TestSize.Level0) GTEST_LOG_(INFO) << "BErrorTest-end b_error_construction_0500"; } +/** + * @tc.number: SUB_backup_b_error_construction_0700 + * @tc.name: b_error_construction_0700 + * @tc.desc: Test function of construction interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_construction_0700, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_construction_0700"; + try { + throw BError(BError::Codes::UTILS_INVAL_FILE_HANDLE); + EXPECT_TRUE(false); + } catch (const BError &e) { + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BErrorTest-an exception occurred by construction."; + } + GTEST_LOG_(INFO) << "BErrorTest-end b_error_construction_0700"; +} + +/** + * @tc.number: SUB_backup_b_error_construction_0900 + * @tc.name: b_error_construction_0900 + * @tc.desc: Test function of construction interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_construction_0900, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_construction_0900"; + try { + throw BError(BError::Codes::UTILS_INVAL_TARBALL_ARG); + EXPECT_TRUE(false); + } catch (const BError &e) { + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BErrorTest-an exception occurred by construction."; + } + GTEST_LOG_(INFO) << "BErrorTest-end b_error_construction_0900"; +} + +/** + * @tc.number: SUB_backup_b_error_construction_0200 + * @tc.name: b_error_construction_0200 + * @tc.desc: Test function of construction interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_construction_0200, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_construction_0200"; + try { + throw BError(BError::Codes::UTILS_INVAL_PROCESS_ARG); + EXPECT_TRUE(false); + } catch (const BError &e) { + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BErrorTest-an exception occurred by construction."; + } + GTEST_LOG_(INFO) << "BErrorTest-end b_error_construction_0200"; +} + +/** + * @tc.number: SUB_backup_b_error_construction_0400 + * @tc.name: b_error_construction_0400 + * @tc.desc: Test function of construction interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_construction_0400, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_construction_0400"; + try { + throw BError(BError::Codes::UTILS_INTERRUPTED_PROCESS); + EXPECT_TRUE(false); + } catch (const BError &e) { + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BErrorTest-an exception occurred by construction."; + } + GTEST_LOG_(INFO) << "BErrorTest-end b_error_construction_0400"; +} + /** * @tc.number: SUB_backup_b_error_GetCode_0100 * @tc.name: b_error_GetCode_0100 @@ -111,6 +203,96 @@ HWTEST_F(BErrorTest, b_error_GetCode_0100, testing::ext::TestSize.Level0) GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetCode_0100"; } +/** + * @tc.number: SUB_backup_b_error_GetCode_0200 + * @tc.name: b_error_GetCode_0200 + * @tc.desc: Test function of GetCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetCode_0200, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetCode_0200"; + BError be(BError::Codes::UTILS_INVAL_JSON_ENTITY); + int ret = be.GetCode(); + EXPECT_EQ(ret, BError::BackupErrorCode::E_INVAL); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetCode_0200"; +} + +/** + * @tc.number: SUB_backup_b_error_GetCode_0300 + * @tc.name: b_error_GetCode_0300 + * @tc.desc: Test function of GetCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetCode_0300, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetCode_0300"; + BError be(BError::Codes::UTILS_INVAL_FILE_HANDLE); + int ret = be.GetCode(); + EXPECT_EQ(ret, BError::BackupErrorCode::E_INVAL); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetCode_0300"; +} + +/** + * @tc.number: SUB_backup_b_error_GetCode_0400 + * @tc.name: b_error_GetCode_0400 + * @tc.desc: Test function of GetCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetCode_0400, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetCode_0400"; + BError be(BError::Codes::UTILS_INVAL_TARBALL_ARG); + int ret = be.GetCode(); + EXPECT_EQ(ret, BError::BackupErrorCode::E_UKERR); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetCode_0400"; +} + +/** + * @tc.number: SUB_backup_b_error_GetCode_0500 + * @tc.name: b_error_GetCode_0500 + * @tc.desc: Test function of GetCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetCode_0500, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetCode_0500"; + BError be(BError::Codes::UTILS_INVAL_PROCESS_ARG); + int ret = be.GetCode(); + EXPECT_EQ(ret, BError::BackupErrorCode::E_UKERR); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetCode_0500"; +} + +/** + * @tc.number: SUB_backup_b_error_GetCode_0600 + * @tc.name: b_error_GetCode_0600 + * @tc.desc: Test function of GetCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetCode_0600, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetCode_0600"; + BError be(BError::Codes::UTILS_INTERRUPTED_PROCESS); + int ret = be.GetCode(); + EXPECT_EQ(ret, BError::BackupErrorCode::E_UKERR); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetCode_0600"; +} + /** * @tc.number: SUB_backup_b_error_GetRawCode_0100 * @tc.name: b_error_GetRawCode_0100 @@ -129,6 +311,96 @@ HWTEST_F(BErrorTest, b_error_GetRawCode_0100, testing::ext::TestSize.Level0) GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetRawCode_0100"; } +/** + * @tc.number: SUB_backup_b_error_GetRawCode_0200 + * @tc.name: b_error_GetRawCode_0200 + * @tc.desc: Test function of GetRawCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetRawCode_0200, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetRawCode_0200"; + BError be(BError::Codes::UTILS_INVAL_JSON_ENTITY); + BError::Codes result = be.GetRawCode(); + EXPECT_EQ(result, BError::Codes::UTILS_INVAL_JSON_ENTITY); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetRawCode_0200"; +} + +/** + * @tc.number: SUB_backup_b_error_GetRawCode_0300 + * @tc.name: b_error_GetRawCode_0300 + * @tc.desc: Test function of GetRawCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetRawCode_0300, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetRawCode_0300"; + BError be(BError::Codes::UTILS_INVAL_FILE_HANDLE); + BError::Codes result = be.GetRawCode(); + EXPECT_EQ(result, BError::Codes::UTILS_INVAL_FILE_HANDLE); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetRawCode_0300"; +} + +/** + * @tc.number: SUB_backup_b_error_GetRawCode_0400 + * @tc.name: b_error_GetRawCode_0400 + * @tc.desc: Test function of GetRawCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetRawCode_0400, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetRawCode_0400"; + BError be(BError::Codes::UTILS_INVAL_TARBALL_ARG); + BError::Codes result = be.GetRawCode(); + EXPECT_EQ(result, BError::Codes::UTILS_INVAL_TARBALL_ARG); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetRawCode_0400"; +} + +/** + * @tc.number: SUB_backup_b_error_GetRawCode_0500 + * @tc.name: b_error_GetRawCode_0500 + * @tc.desc: Test function of GetRawCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetRawCode_0500, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetRawCode_0500"; + BError be(BError::Codes::UTILS_INVAL_PROCESS_ARG); + BError::Codes result = be.GetRawCode(); + EXPECT_EQ(result, BError::Codes::UTILS_INVAL_PROCESS_ARG); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetRawCode_0500"; +} + +/** + * @tc.number: SUB_backup_b_error_GetRawCode_0600 + * @tc.name: b_error_GetRawCode_0600 + * @tc.desc: Test function of GetRawCode interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 0 + * @tc.require: I6F3GV + */ +HWTEST_F(BErrorTest, b_error_GetRawCode_0600, testing::ext::TestSize.Level0) +{ + GTEST_LOG_(INFO) << "BErrorTest-begin b_error_GetRawCode_0600"; + BError be(BError::Codes::UTILS_INTERRUPTED_PROCESS); + BError::Codes result = be.GetRawCode(); + EXPECT_EQ(result, BError::Codes::UTILS_INTERRUPTED_PROCESS); + GTEST_LOG_(INFO) << "BErrorTest-end b_error_GetRawCode_0600"; +} + /** * @tc.number: SUB_backup_b_error_what_0100 * @tc.name: b_error_what_0100 -- Gitee