4 #include <UnitTest++/UnitTest++.h>
7 #include "ToGraphvizWriter.h"
9 // these test always pass, unless exceptions occur
10 //! TODO: try to initialize some variables only in one place
12 SUITE(ArticleToGraphvizWriterTests
)
14 using namespace WikiWalker
;
15 using namespace WikiWalker::CollectionUtils
;
17 TEST(WriteArticleWithMultipleLinks
)
19 std::ofstream
outfile("_artlinks.dot",
20 std::ofstream::out
| std::ofstream::trunc
);
24 auto al1
= std::make_shared
<Article
>("Animal"),
25 al2
= std::make_shared
<Article
>("Pig"),
26 al3
= std::make_shared
<Article
>("Equality");
31 atj
.output(&a
, outfile
);
36 TEST(WriteArticleCollectionDepthOne
)
38 std::ofstream
outfile("_artctree.dot",
39 std::ofstream::out
| std::ofstream::trunc
);
43 auto farm
= std::make_shared
<Article
>("Farm");
44 CollectionUtils::add(ac
, farm
);
46 auto animal
= std::make_shared
<Article
>("Animal");
47 farm
->addLink(animal
);
48 CollectionUtils::add(ac
, animal
);
50 auto pig
= std::make_shared
<Article
>("Pig");
52 CollectionUtils::add(ac
, pig
);
54 auto equa
= std::make_shared
<Article
>("Equality");
56 CollectionUtils::add(ac
, equa
);
58 atj
.output(ac
, outfile
);
63 TEST(WriteArticleCollectionDepthOne_WithInterlinks
)
65 std::ofstream
outfile("_artctree_interlink.dot",
66 std::ofstream::out
| std::ofstream::trunc
);
70 auto farm
= std::make_shared
<Article
>("Farm");
71 CollectionUtils::add(ac
, farm
);
73 auto animal
= std::make_shared
<Article
>("Animal");
74 farm
->addLink(animal
);
75 CollectionUtils::add(ac
, animal
);
77 auto pig
= std::make_shared
<Article
>("Pig");
80 CollectionUtils::add(ac
, pig
);
85 auto equa
= std::make_shared
<Article
>("Equality");
87 CollectionUtils::add(ac
, equa
);
89 atj
.output(ac
, outfile
);
94 TEST(WriteArticleCollectionDepthTwo
)
96 std::ofstream
outfile("_artc_deeptree.dot",
97 std::ofstream::out
| std::ofstream::trunc
);
101 auto farm
= std::make_shared
<Article
>("Farm");
102 CollectionUtils::add(ac
, farm
);
104 auto animal
= std::make_shared
<Article
>("Animal");
105 farm
->addLink(animal
);
106 CollectionUtils::add(ac
, animal
);
108 auto pig
= std::make_shared
<Article
>("Pig");
110 CollectionUtils::add(ac
, pig
);
112 auto equa
= std::make_shared
<Article
>("Equality");
114 CollectionUtils::add(ac
, equa
);
116 auto rights
= std::make_shared
<Article
>("Rights");
117 equa
->addLink(rights
);
118 CollectionUtils::add(ac
, rights
);
120 auto cat
= std::make_shared
<Article
>("Cat");
121 CollectionUtils::add(ac
, cat
);
122 animal
->addLink(cat
);
123 auto dog
= std::make_shared
<Article
>("Dog");
124 CollectionUtils::add(ac
, dog
);
125 animal
->addLink(dog
);
127 atj
.output(ac
, outfile
);