From 8dbf977b17b53c24a9b26ef81c0ffac86736adcd Mon Sep 17 00:00:00 2001 From: STELLSAN Date: Wed, 23 Oct 2024 21:30:55 +0300 Subject: [PATCH] code_coverage_fix --- .../test/test_HarryPotterBooks.cpp | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/nedelin_d_book_discount_lab2/test/test_HarryPotterBooks.cpp b/modules/nedelin_d_book_discount_lab2/test/test_HarryPotterBooks.cpp index ef1cc15e1..80283cdc6 100644 --- a/modules/nedelin_d_book_discount_lab2/test/test_HarryPotterBooks.cpp +++ b/modules/nedelin_d_book_discount_lab2/test/test_HarryPotterBooks.cpp @@ -3,11 +3,38 @@ #include #include "include/HarryPotterBooks.h" -TEST(Nedelin_HarryPotterBooksTest, EmptyInput) { +TEST(Nedelin_HarryPotterBooksTest, ConstructEmptyVector) { std::vector empty_books; EXPECT_THROW(HarryPotterBooks hpBooks(empty_books), std::invalid_argument); } +TEST(Nedelin_HarryPotterBooksTest, ConstructValidVector) { + std::vector books = { 1, 2, 3, 4, 5 }; + HarryPotterBooks hpBooks(books); + EXPECT_NO_THROW(hpBooks.calculateTotalPrice()); +} + +TEST(Nedelin_HarryPotterBooksTest, SetBooksWithEmptyVector) { + std::vector books = { 1, 2, 3, 4, 5 }; + HarryPotterBooks hpBooks(books); + std::vector empty_books; + EXPECT_THROW(hpBooks.setBooks(empty_books), std::invalid_argument); +} + +TEST(Nedelin_HarryPotterBooksTest, SetBooksWithValidVector) { + std::vector books = { 1, 2, 3, 4, 5 }; + HarryPotterBooks hpBooks(books); + std::vector books_2 = { 1, 1, 1, 1, 1 }; + hpBooks.setBooks(books_2); + EXPECT_EQ(hpBooks.getBooks(), books_2); +} + +TEST(Nedelin_HarryPotterBooksTest, GetBooksTest) { + std::vector books = { 1, 2, 3, 4, 5 }; + HarryPotterBooks hpBooks(books); + EXPECT_EQ(hpBooks.getBooks(), books); +} + TEST(Nedelin_HarryPotterBooksTest, SingleBook) { std::vector books = { 1, 0, 0, 0, 0 }; HarryPotterBooks hpBooks(books);