2017-11-12 11:47:56 +08:00
|
|
|
#include "tests.pch.h"
|
2017-10-31 18:47:35 +08:00
|
|
|
|
2018-01-23 18:36:39 +08:00
|
|
|
#include <tests.utils.h>
|
|
|
|
|
2017-10-31 18:47:35 +08:00
|
|
|
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)); }));
|
|
|
|
|
2018-01-23 18:36:39 +08:00
|
|
|
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
2017-10-31 18:47:35 +08:00
|
|
|
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)); }));
|
|
|
|
|
2018-01-23 18:36:39 +08:00
|
|
|
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
2017-10-31 18:47:35 +08:00
|
|
|
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)); }));
|
|
|
|
|
2018-01-23 18:36:39 +08:00
|
|
|
auto it = status_db.find_installed(unsafe_pspec("ffmpeg", Triplet::X64_WINDOWS));
|
2017-10-31 18:47:35 +08:00
|
|
|
Assert::IsTrue(it != status_db.end());
|
|
|
|
}
|
|
|
|
};
|
2018-01-23 18:36:39 +08:00
|
|
|
}
|