vcpkg/toolsrc/include/tests.utils.h

77 lines
2.7 KiB
C
Raw Normal View History

#pragma once
#include <CppUnitTest.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/packagespecparseresult.h>
#include <vcpkg/statusparagraph.h>
#include <vcpkg/triplet.h>
#include <memory>
namespace Microsoft::VisualStudio::CppUnitTestFramework
{
2018-04-26 09:14:24 +08:00
template<>
std::wstring ToString<vcpkg::Dependencies::InstallPlanType>(const vcpkg::Dependencies::InstallPlanType& t)
{
switch (t)
{
case vcpkg::Dependencies::InstallPlanType::ALREADY_INSTALLED: return L"ALREADY_INSTALLED";
case vcpkg::Dependencies::InstallPlanType::BUILD_AND_INSTALL: return L"BUILD_AND_INSTALL";
case vcpkg::Dependencies::InstallPlanType::EXCLUDED: return L"EXCLUDED";
case vcpkg::Dependencies::InstallPlanType::UNKNOWN: return L"UNKNOWN";
default: return ToString(static_cast<int>(t));
}
}
template<>
std::wstring ToString<vcpkg::Dependencies::RequestType>(const vcpkg::Dependencies::RequestType& t)
{
switch (t)
{
case vcpkg::Dependencies::RequestType::AUTO_SELECTED: return L"AUTO_SELECTED";
case vcpkg::Dependencies::RequestType::USER_REQUESTED: return L"USER_REQUESTED";
case vcpkg::Dependencies::RequestType::UNKNOWN: return L"UNKNOWN";
default: return ToString(static_cast<int>(t));
}
}
template<>
std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t)
{
return ToString(static_cast<uint32_t>(t));
}
template<>
std::wstring ToString<vcpkg::PackageSpec>(const vcpkg::PackageSpec& t)
{
return ToString(t.to_string());
}
}
std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name,
const char* depends = "",
[vcpkg] Implement Default-Features (#2697) * [vcpkg] Add Default-Feature to make_status_pgh utility function Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Parse "Default-Features" as dependencies and add test for parsing Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Document some methods and structures Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Add install_default_features_test Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Change install_default_features_test to not have preinstalled package * [vcpkg] Test install behaviour of default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Implement default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Test default features upgrade behavior Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Implement upgrade with default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Test behaviour of upgrade with default features in dependencies Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Make upgrade install new default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Move collecting of packages for which to prevent defaults Further down the line to create_feature_install_plan. Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Fix core missing from default features and potential inf loop Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Rename, fix and move some tests Signed-off-by: Squareys <squareys@googlemail.com>
2018-02-15 08:18:25 +08:00
const char* default_features = "",
const char* triplet = "x86-windows");
std::unique_ptr<vcpkg::StatusParagraph> make_status_feature_pgh(const char* name,
const char* feature,
const char* depends = "",
const char* triplet = "x86-windows");
template<class T, class S>
T&& unwrap(vcpkg::ExpectedT<T, S>&& p)
{
Assert::IsTrue(p.has_value());
return std::move(*p.get());
}
template<class T>
T&& unwrap(vcpkg::Optional<T>&& opt)
{
Assert::IsTrue(opt.has_value());
return std::move(*opt.get());
}
vcpkg::PackageSpec unsafe_pspec(std::string name, vcpkg::Triplet t = vcpkg::Triplet::X86_WINDOWS);