summaryrefslogtreecommitdiff
path: root/gentoobrowse-api/unittests/testMasks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gentoobrowse-api/unittests/testMasks.cpp')
-rw-r--r--gentoobrowse-api/unittests/testMasks.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/gentoobrowse-api/unittests/testMasks.cpp b/gentoobrowse-api/unittests/testMasks.cpp
new file mode 100644
index 0000000..8aba4ea
--- /dev/null
+++ b/gentoobrowse-api/unittests/testMasks.cpp
@@ -0,0 +1,52 @@
+#define BOOST_TEST_MODULE Masks
+#include <boost/test/unit_test.hpp>
+
+#include <mask.h>
+#include <fileUtils.h>
+#include <definedDirs.h>
+#include <portage-models.h>
+#include <compileTimeFormatter.h>
+#include <boost/algorithm/string/join.hpp>
+
+class MaskTester : public Portage::Utils::Masks {
+ protected:
+ void consume() const override
+ {
+ if (email && person) {
+ masks.push_back(new Gentoo::Mask(n, *person, *email, date,
+ boost::algorithm::join(message, " "),
+ Gentoo::StringList(atoms.begin(), atoms.end())));
+ }
+ }
+
+ public:
+ mutable Gentoo::Masks masks;
+};
+
+#define BOOST_CHECK_EQUAL_COLLECTION(a, ...) { \
+ auto __list__ = { __VA_ARGS__ }; \
+ BOOST_CHECK_EQUAL_COLLECTIONS(a.begin(), a.end(), __list__.begin(), __list__.end()); \
+}
+
+BOOST_FIXTURE_TEST_SUITE(mt, MaskTester)
+
+BOOST_AUTO_TEST_CASE(f1)
+{
+ AdHoc::FileUtils::MemMap f(rootDir / "fixtures" / "4156eb45cf3b0ce1d7125b84efd8688c2d6e831d" / "profiles" / "package.mask");
+ extract((const gchar *)f.data, f.getStat().st_size);
+ BOOST_CHECK_EQUAL(masks.size(), 151);
+ auto m = masks.front();
+ BOOST_CHECK(m->person);
+ BOOST_CHECK_EQUAL("James Le Cuirot", *m->person);
+ BOOST_CHECK(m->email);
+ BOOST_CHECK_EQUAL("chewi@gentoo.org", *m->email);
+ BOOST_CHECK_EQUAL("25 Apr 1016", m->dateadded);
+ BOOST_CHECK_EQUAL("Long dead upstream and no longer needed. Removal in 30 days.", m->message);
+ BOOST_CHECK_EQUAL_COLLECTION(m->atomspec,
+ "dev-java/charva",
+ "dev-java/jakarta-slide-webdavclient",
+ "dev-java/xml-im-exporter");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+