code cleanup

This commit is contained in:
Martin Brodbeck 2018-07-20 11:52:26 +02:00
parent 74719b762f
commit 6000bb3ef2
17 changed files with 65 additions and 67 deletions

View file

@ -15,7 +15,7 @@ BOOST_AUTO_TEST_CASE(check_is_sold)
Article article{};
BOOST_TEST(article.isSold() == false);
auto salePtr = std::make_shared<Sale>();
article.setSale(salePtr.get());
auto salePtr = std::make_unique<Sale>();
salePtr->addArticle(&article);
BOOST_TEST(article.isSold() == true);
}

View file

@ -30,11 +30,11 @@ BOOST_AUTO_TEST_CASE(store_sellers_succ)
auto b = std::make_unique<Seller>("Max", "Mustermann");
b->createUuid();
b->setSellerNo(2);
auto c = std::make_shared<Article>();
auto c = std::make_unique<Article>();
c->createUuid();
c->setPrice(500);
c->setDescription("Test");
b->addArticle(c);
b->addArticle(std::move(c));
BOOST_TEST(a->getUuid() != b->getUuid());
sellers.push_back(std::move(a));
sellers.push_back(std::move(b));

View file

@ -12,15 +12,15 @@ BOOST_AUTO_TEST_CASE(articles_sum)
const int NUM_ARTICLES = 30;
Seller seller("Max", "Mustermann", 1, NUM_ARTICLES);
std::vector<std::shared_ptr<Article>> articles{};
ArticlesVec articles{};
Sale sale{};
for(int i = 0; i < NUM_ARTICLES; ++i)
{
auto art = std::make_shared<Article>();
auto art = std::make_unique<Article>();
art->setPrice((i+1) * 10);
articles.push_back(art);
seller.addArticle(art);
articles.push_back(art.get());
seller.addArticle(std::move(art));
}
for(int i = 0; i < 10; ++i)
@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(remove_article) {
Sale sale{};
BOOST_TEST(art->isSold() == false);
sale.addArticle(art);
sale.addArticle(art.get());
BOOST_TEST(art->isSold() == true);
sale.removeArticle(art.get());
BOOST_TEST(art->isSold() == false);

View file

@ -30,10 +30,11 @@ BOOST_AUTO_TEST_CASE(create_many)
}
BOOST_AUTO_TEST_CASE(with_article) {
Seller seller("Max", "Mustermann");
auto article = std::make_shared<Article>();
Seller seller{};
auto article = std::make_unique<Article>();
article->setDescription("Test article");
seller.addArticle(article);
seller.addArticle(std::move(article));
BOOST_TEST((article == nullptr));
BOOST_TEST(seller.getArticles(false).at(0)->getDescription() == "Test article");
BOOST_TEST(seller.numArticlesSold() == 0);
}