3 #include <UnitTest++/UnitTest++.h>
6 #include "ArticleCollection.h"
10 using namespace WikiWalker
;
11 using namespace WikiWalker::CollectionUtils
;
13 TEST(MakeSureNoDuplicateArticlesExist
)
16 auto la1
= std::make_shared
<Article
>("King"),
17 la2
= std::make_shared
<Article
>("Queen"),
18 la3
= std::make_shared
<Article
>("Prince"),
19 la4
= std::make_shared
<Article
>("Queen");
21 CHECK(CollectionUtils::add(w
, la1
));
22 CHECK(CollectionUtils::add(w
, la2
));
23 CHECK_EQUAL(2, w
.size());
24 CHECK(CollectionUtils::add(w
, la3
));
25 CHECK_EQUAL(3, w
.size());
28 CHECK(!CollectionUtils::add(w
, la4
));
29 CHECK_EQUAL(3, w
.size());
32 TEST(CollectionIsCaseInsensitive
)
35 auto la1
= std::make_shared
<Article
>("King"),
36 la2
= std::make_shared
<Article
>("Queen"),
37 la3
= std::make_shared
<Article
>("Prince"),
38 la4
= std::make_shared
<Article
>("queen");
40 CollectionUtils::add(w
, la1
);
41 CollectionUtils::add(w
, la2
);
42 CHECK_EQUAL(2, w
.size());
43 CollectionUtils::add(w
, la3
);
44 CHECK_EQUAL(3, w
.size());
45 CollectionUtils::add(w
, la4
);
46 CHECK_EQUAL(4, w
.size());
49 TEST(GetArticle_Existing_MustNotBeNull
)
52 auto king
= std::make_shared
<Article
>("King");
53 CollectionUtils::add(w
, king
);
54 CHECK(CollectionUtils::get(w
, "King") != nullptr);
57 TEST(GetArticle_NonExisting_MustBeNull
)
60 auto la1
= std::make_shared
<Article
>("King");
61 CollectionUtils::add(w
, la1
);
62 CHECK(CollectionUtils::get(w
, "Queen") == nullptr);
65 ArticleCollection
GetArticleCollection()
68 CollectionUtils::add(ac
, std::make_shared
<Article
>("Foo"));
69 CollectionUtils::add(ac
, std::make_shared
<Article
>("Bar"));
73 TEST(ArticleCollection_CreationViaMoveConstructor
)
75 auto ac
= GetArticleCollection();
76 CHECK_EQUAL(2, ac
.size());
77 CHECK(CollectionUtils::get(ac
, "Foo") != nullptr);