aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/tests.statusparagraphs.cpp
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-10-31 03:47:35 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-10-31 03:47:35 -0700
commita705df80b0f8db81b201492b4012e23e08a53694 (patch)
tree9cf54f40e8e08039842d5c893332b8ec9e8b9a66 /toolsrc/src/tests.statusparagraphs.cpp
parent925fab565a76c23e76329193bc25158608bc9fc6 (diff)
downloadvcpkg-a705df80b0f8db81b201492b4012e23e08a53694.tar.gz
vcpkg-a705df80b0f8db81b201492b4012e23e08a53694.zip
[vcpkg] Fix bug where packages with uninstalled features appear to be uninstalled.
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