aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/tests.statusparagraphs.cpp
diff options
context:
space:
mode:
authorBarath Kannan <barathsotd@gmail.com>2017-11-06 00:33:04 +1100
committerBarath Kannan <barathsotd@gmail.com>2017-11-06 00:33:04 +1100
commitb959f70a9969551a132d691fbd12046d5ea0702e (patch)
treed15d129bd480b1ba173322a0e50140ccf1ff487a /toolsrc/src/tests.statusparagraphs.cpp
parent3a5b383bbec74dbaf0f1056e1a5d315e43d79375 (diff)
parent330b8d8bab6a3d07165bf7c05fea09a8e0d56348 (diff)
downloadvcpkg-b959f70a9969551a132d691fbd12046d5ea0702e.tar.gz
vcpkg-b959f70a9969551a132d691fbd12046d5ea0702e.zip
merge from master
Diffstat (limited to 'toolsrc/src/tests.statusparagraphs.cpp')
-rw-r--r--toolsrc/src/tests.statusparagraphs.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/toolsrc/src/tests.statusparagraphs.cpp b/toolsrc/src/tests.statusparagraphs.cpp
new file mode 100644
index 000000000..4cc1130b1
--- /dev/null
+++ b/toolsrc/src/tests.statusparagraphs.cpp
@@ -0,0 +1,85 @@
+#include <CppUnitTest.h>
+
+#include <vcpkg/base/util.h>
+#include <vcpkg/paragraphs.h>
+#include <vcpkg/statusparagraph.h>
+#include <vcpkg/statusparagraphs.h>
+
+using namespace Microsoft::VisualStudio::CppUnitTestFramework;
+
+using namespace vcpkg;
+using namespace vcpkg::Paragraphs;
+
+namespace UnitTest1
+{
+ class StatusParagraphsTests : public TestClass<StatusParagraphsTests>
+ {
+ TEST_METHOD(find_installed)
+ {
+ auto pghs = parse_paragraphs(R"(
+Package: ffmpeg
+Version: 3.3.3
+Architecture: x64-windows
+Multi-Arch: same
+Description:
+Status: install ok installed
+)");
+ Assert::IsTrue(!!pghs);
+ if (!pghs) return;
+
+ StatusParagraphs status_db(Util::fmap(
+ *pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
+
+ auto it = status_db.find_installed("ffmpeg", Triplet::X64_WINDOWS);
+ Assert::IsTrue(it != status_db.end());
+ }
+
+ TEST_METHOD(find_not_installed)
+ {
+ auto pghs = parse_paragraphs(R"(
+Package: ffmpeg
+Version: 3.3.3
+Architecture: x64-windows
+Multi-Arch: same
+Description:
+Status: purge ok not-installed
+)");
+ Assert::IsTrue(!!pghs);
+ if (!pghs) return;
+
+ StatusParagraphs status_db(Util::fmap(
+ *pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
+
+ auto it = status_db.find_installed("ffmpeg", Triplet::X64_WINDOWS);
+ Assert::IsTrue(it == status_db.end());
+ }
+
+ TEST_METHOD(find_with_feature_packages)
+ {
+ auto pghs = parse_paragraphs(R"(
+Package: ffmpeg
+Version: 3.3.3
+Architecture: x64-windows
+Multi-Arch: same
+Description:
+Status: install ok installed
+
+Package: ffmpeg
+Feature: openssl
+Depends: openssl
+Architecture: x64-windows
+Multi-Arch: same
+Description:
+Status: purge ok not-installed
+)");
+ Assert::IsTrue(!!pghs);
+ if (!pghs) return;
+
+ StatusParagraphs status_db(Util::fmap(
+ *pghs.get(), [](RawParagraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
+
+ auto it = status_db.find_installed("ffmpeg", Triplet::X64_WINDOWS);
+ Assert::IsTrue(it != status_db.end());
+ }
+ };
+} \ No newline at end of file