2017-04-28 09:55:00 +08:00
|
|
|
#include "BinaryParagraph.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
#include "CppUnitTest.h"
|
2016-11-08 08:06:36 +08:00
|
|
|
#include "Paragraphs.h"
|
2017-04-13 13:48:52 +08:00
|
|
|
#include "vcpkg_Strings.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-04-28 09:55:00 +08:00
|
|
|
#pragma comment(lib, "version")
|
|
|
|
#pragma comment(lib, "winhttp")
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
|
2017-01-06 06:27:36 +08:00
|
|
|
namespace Microsoft::VisualStudio::CppUnitTestFramework
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
template<>
|
2017-04-04 05:47:30 +08:00
|
|
|
inline std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t)
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
return ToString(static_cast<uint32_t>(t));
|
|
|
|
}
|
2017-01-06 06:27:36 +08:00
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-04-13 13:48:52 +08:00
|
|
|
namespace Strings = vcpkg::Strings;
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
namespace UnitTest1
|
|
|
|
{
|
2017-04-30 14:30:21 +08:00
|
|
|
class ControlParsing : public TestClass<ControlParsing>
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
TEST_METHOD(SourceParagraph_Construct_Minimum)
|
|
|
|
{
|
2017-06-20 06:06:15 +08:00
|
|
|
auto m_pgh =
|
|
|
|
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Source", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
2017-06-20 06:06:15 +08:00
|
|
|
}});
|
2017-06-06 06:58:47 +08:00
|
|
|
|
|
|
|
Assert::IsTrue(m_pgh.has_value());
|
|
|
|
auto& pgh = *m_pgh.get();
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual("zlib", pgh->core_paragraph->name.c_str());
|
|
|
|
Assert::AreEqual("1.2.8", pgh->core_paragraph->version.c_str());
|
|
|
|
Assert::AreEqual("", pgh->core_paragraph->maintainer.c_str());
|
|
|
|
Assert::AreEqual("", pgh->core_paragraph->description.c_str());
|
|
|
|
Assert::AreEqual(size_t(0), pgh->core_paragraph->depends.size());
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(SourceParagraph_Construct_Maximum)
|
|
|
|
{
|
2017-06-20 06:06:15 +08:00
|
|
|
auto m_pgh =
|
|
|
|
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
|
|
|
{"Source", "s"},
|
|
|
|
{"Version", "v"},
|
|
|
|
{"Maintainer", "m"},
|
|
|
|
{"Description", "d"},
|
|
|
|
{"Build-Depends", "bd"},
|
|
|
|
{"Supports", "x64"},
|
|
|
|
}});
|
2017-06-06 06:58:47 +08:00
|
|
|
Assert::IsTrue(m_pgh.has_value());
|
|
|
|
auto& pgh = *m_pgh.get();
|
|
|
|
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual("s", pgh->core_paragraph->name.c_str());
|
|
|
|
Assert::AreEqual("v", pgh->core_paragraph->version.c_str());
|
|
|
|
Assert::AreEqual("m", pgh->core_paragraph->maintainer.c_str());
|
|
|
|
Assert::AreEqual("d", pgh->core_paragraph->description.c_str());
|
|
|
|
Assert::AreEqual(size_t(1), pgh->core_paragraph->depends.size());
|
2017-07-26 12:29:31 +08:00
|
|
|
Assert::AreEqual("bd", pgh->core_paragraph->depends[0].name().c_str());
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual(size_t(1), pgh->core_paragraph->supports.size());
|
|
|
|
Assert::AreEqual("x64", pgh->core_paragraph->supports[0].c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(SourceParagraph_Two_Depends)
|
|
|
|
{
|
2017-06-20 06:06:15 +08:00
|
|
|
auto m_pgh =
|
|
|
|
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Source", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Build-Depends", "z, openssl"},
|
2017-06-20 06:06:15 +08:00
|
|
|
}});
|
2017-06-06 06:58:47 +08:00
|
|
|
Assert::IsTrue(m_pgh.has_value());
|
|
|
|
auto& pgh = *m_pgh.get();
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual(size_t(2), pgh->core_paragraph->depends.size());
|
2017-07-26 12:29:31 +08:00
|
|
|
Assert::AreEqual("z", pgh->core_paragraph->depends[0].name().c_str());
|
|
|
|
Assert::AreEqual("openssl", pgh->core_paragraph->depends[1].name().c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(SourceParagraph_Three_Depends)
|
|
|
|
{
|
2017-06-20 06:06:15 +08:00
|
|
|
auto m_pgh =
|
|
|
|
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Source", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Build-Depends", "z, openssl, xyz"},
|
2017-06-20 06:06:15 +08:00
|
|
|
}});
|
2017-06-06 06:58:47 +08:00
|
|
|
Assert::IsTrue(m_pgh.has_value());
|
|
|
|
auto& pgh = *m_pgh.get();
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual(size_t(3), pgh->core_paragraph->depends.size());
|
2017-07-26 12:29:31 +08:00
|
|
|
Assert::AreEqual("z", pgh->core_paragraph->depends[0].name().c_str());
|
|
|
|
Assert::AreEqual("openssl", pgh->core_paragraph->depends[1].name().c_str());
|
|
|
|
Assert::AreEqual("xyz", pgh->core_paragraph->depends[2].name().c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
|
2017-06-07 07:08:36 +08:00
|
|
|
TEST_METHOD(SourceParagraph_Three_Supports)
|
|
|
|
{
|
2017-06-20 06:06:15 +08:00
|
|
|
auto m_pgh =
|
|
|
|
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Source", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Supports", "x64, windows, uwp"},
|
2017-06-20 06:06:15 +08:00
|
|
|
}});
|
2017-06-07 07:08:36 +08:00
|
|
|
Assert::IsTrue(m_pgh.has_value());
|
|
|
|
auto& pgh = *m_pgh.get();
|
|
|
|
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual(size_t(3), pgh->core_paragraph->supports.size());
|
|
|
|
Assert::AreEqual("x64", pgh->core_paragraph->supports[0].c_str());
|
|
|
|
Assert::AreEqual("windows", pgh->core_paragraph->supports[1].c_str());
|
|
|
|
Assert::AreEqual("uwp", pgh->core_paragraph->supports[2].c_str());
|
2017-06-07 07:08:36 +08:00
|
|
|
}
|
|
|
|
|
2016-11-05 16:02:15 +08:00
|
|
|
TEST_METHOD(SourceParagraph_Construct_Qualified_Depends)
|
|
|
|
{
|
2017-06-20 06:06:15 +08:00
|
|
|
auto m_pgh =
|
|
|
|
vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Source", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Build-Depends", "libA (windows), libB (uwp)"},
|
2017-06-20 06:06:15 +08:00
|
|
|
}});
|
2017-06-06 06:58:47 +08:00
|
|
|
Assert::IsTrue(m_pgh.has_value());
|
|
|
|
auto& pgh = *m_pgh.get();
|
2016-11-05 16:02:15 +08:00
|
|
|
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual("zlib", pgh->core_paragraph->name.c_str());
|
|
|
|
Assert::AreEqual("1.2.8", pgh->core_paragraph->version.c_str());
|
|
|
|
Assert::AreEqual("", pgh->core_paragraph->maintainer.c_str());
|
|
|
|
Assert::AreEqual("", pgh->core_paragraph->description.c_str());
|
|
|
|
Assert::AreEqual(size_t(2), pgh->core_paragraph->depends.size());
|
2017-07-26 12:29:31 +08:00
|
|
|
Assert::AreEqual("libA", pgh->core_paragraph->depends[0].name().c_str());
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual("windows", pgh->core_paragraph->depends[0].qualifier.c_str());
|
2017-07-26 12:29:31 +08:00
|
|
|
Assert::AreEqual("libB", pgh->core_paragraph->depends[1].name().c_str());
|
2017-06-17 17:39:14 +08:00
|
|
|
Assert::AreEqual("uwp", pgh->core_paragraph->depends[1].qualifier.c_str());
|
2016-11-05 16:02:15 +08:00
|
|
|
}
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
TEST_METHOD(BinaryParagraph_Construct_Minimum)
|
|
|
|
{
|
|
|
|
vcpkg::BinaryParagraph pgh({
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Package", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Architecture", "x86-windows"},
|
|
|
|
{"Multi-Arch", "same"},
|
2016-09-19 11:50:08 +08:00
|
|
|
});
|
|
|
|
|
2016-10-05 06:16:07 +08:00
|
|
|
Assert::AreEqual("zlib", pgh.spec.name().c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual("1.2.8", pgh.version.c_str());
|
|
|
|
Assert::AreEqual("", pgh.maintainer.c_str());
|
|
|
|
Assert::AreEqual("", pgh.description.c_str());
|
2017-04-11 04:03:34 +08:00
|
|
|
Assert::AreEqual("x86-windows", pgh.spec.triplet().canonical_name().c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(0), pgh.depends.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(BinaryParagraph_Construct_Maximum)
|
|
|
|
{
|
2017-06-06 06:58:47 +08:00
|
|
|
vcpkg::BinaryParagraph pgh({
|
|
|
|
{"Package", "s"},
|
|
|
|
{"Version", "v"},
|
|
|
|
{"Architecture", "x86-windows"},
|
|
|
|
{"Multi-Arch", "same"},
|
|
|
|
{"Maintainer", "m"},
|
|
|
|
{"Description", "d"},
|
|
|
|
{"Depends", "bd"},
|
|
|
|
});
|
2016-10-05 06:16:07 +08:00
|
|
|
Assert::AreEqual("s", pgh.spec.name().c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual("v", pgh.version.c_str());
|
|
|
|
Assert::AreEqual("m", pgh.maintainer.c_str());
|
|
|
|
Assert::AreEqual("d", pgh.description.c_str());
|
|
|
|
Assert::AreEqual(size_t(1), pgh.depends.size());
|
|
|
|
Assert::AreEqual("bd", pgh.depends[0].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(BinaryParagraph_Three_Depends)
|
|
|
|
{
|
|
|
|
vcpkg::BinaryParagraph pgh({
|
2017-04-29 03:55:50 +08:00
|
|
|
{"Package", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Architecture", "x86-windows"},
|
|
|
|
{"Multi-Arch", "same"},
|
|
|
|
{"Depends", "a, b, c"},
|
2016-09-19 11:50:08 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
Assert::AreEqual(size_t(3), pgh.depends.size());
|
|
|
|
Assert::AreEqual("a", pgh.depends[0].c_str());
|
|
|
|
Assert::AreEqual("b", pgh.depends[1].c_str());
|
|
|
|
Assert::AreEqual("c", pgh.depends[2].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_empty)
|
|
|
|
{
|
|
|
|
const char* str = "";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::IsTrue(pghs.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_one_field)
|
|
|
|
{
|
|
|
|
const char* str = "f1: v1";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(1), pghs[0].size());
|
|
|
|
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_one_pgh)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: v1\n"
|
|
|
|
"f2: v2";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[0].size());
|
|
|
|
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
|
|
|
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_two_pgh)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: v1\n"
|
|
|
|
"f2: v2\n"
|
|
|
|
"\n"
|
|
|
|
"f3: v3\n"
|
|
|
|
"f4: v4";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(2), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[0].size());
|
|
|
|
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
|
|
|
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[1].size());
|
|
|
|
Assert::AreEqual("v3", pghs[1]["f3"].c_str());
|
|
|
|
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_field_names)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "1:\n"
|
|
|
|
"f:\n"
|
|
|
|
"F:\n"
|
|
|
|
"0:\n"
|
|
|
|
"F-2:\n";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(5), pghs[0].size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_multiple_blank_lines)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: v1\n"
|
|
|
|
"f2: v2\n"
|
|
|
|
"\n"
|
|
|
|
"\n"
|
|
|
|
"f3: v3\n"
|
|
|
|
"f4: v4";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(2), pghs.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_empty_fields)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1:\n"
|
|
|
|
"f2: ";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[0].size());
|
|
|
|
Assert::AreEqual("", pghs[0]["f1"].c_str());
|
|
|
|
Assert::AreEqual("", pghs[0]["f2"].c_str());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[0].size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_multiline_fields)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: simple\n"
|
|
|
|
" f1\r\n"
|
|
|
|
"f2:\r\n"
|
|
|
|
" f2\r\n"
|
|
|
|
" continue\r\n";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual("simple\n f1", pghs[0]["f1"].c_str());
|
|
|
|
Assert::AreEqual("\n f2\n continue", pghs[0]["f2"].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(parse_paragraphs_crlfs)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: v1\r\n"
|
|
|
|
"f2: v2\r\n"
|
|
|
|
"\r\n"
|
|
|
|
"f3: v3\r\n"
|
|
|
|
"f4: v4";
|
2017-04-01 07:23:48 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(2), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[0].size());
|
|
|
|
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
|
|
|
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[1].size());
|
|
|
|
Assert::AreEqual("v3", pghs[1]["f3"].c_str());
|
|
|
|
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
|
|
|
}
|
|
|
|
|
2017-03-31 07:05:21 +08:00
|
|
|
TEST_METHOD(parse_paragraphs_comment)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: v1\r\n"
|
|
|
|
"#comment\r\n"
|
|
|
|
"f2: v2\r\n"
|
|
|
|
"#comment\r\n"
|
|
|
|
"\r\n"
|
|
|
|
"#comment\r\n"
|
|
|
|
"f3: v3\r\n"
|
|
|
|
"#comment\r\n"
|
|
|
|
"f4: v4";
|
2017-03-31 07:05:21 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
|
|
|
Assert::AreEqual(size_t(2), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[0].size());
|
|
|
|
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
|
|
|
Assert::AreEqual("v2", pghs[0]["f2"].c_str());
|
|
|
|
Assert::AreEqual(size_t(2), pghs[1].size());
|
|
|
|
Assert::AreEqual("v3", pghs[1]["f3"].c_str());
|
|
|
|
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
|
|
|
}
|
|
|
|
|
2017-04-13 13:48:52 +08:00
|
|
|
TEST_METHOD(parse_comment_before_single_slashN)
|
|
|
|
{
|
2017-04-28 09:55:00 +08:00
|
|
|
const char* str = "f1: v1\r\n"
|
|
|
|
"#comment\n";
|
2017-04-13 13:48:52 +08:00
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
|
|
|
Assert::AreEqual(size_t(1), pghs[0].size());
|
|
|
|
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
|
|
|
}
|
2017-04-05 17:12:32 +08:00
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
TEST_METHOD(BinaryParagraph_serialize_min)
|
|
|
|
{
|
|
|
|
vcpkg::BinaryParagraph pgh({
|
2017-08-16 04:58:04 +08:00
|
|
|
{"Package", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Architecture", "x86-windows"},
|
|
|
|
{"Multi-Arch", "same"},
|
2016-09-19 11:50:08 +08:00
|
|
|
});
|
2017-04-13 13:48:52 +08:00
|
|
|
std::string ss = Strings::serialize(pgh);
|
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(4), pghs[0].size());
|
|
|
|
Assert::AreEqual("zlib", pghs[0]["Package"].c_str());
|
|
|
|
Assert::AreEqual("1.2.8", pghs[0]["Version"].c_str());
|
2016-11-05 16:02:15 +08:00
|
|
|
Assert::AreEqual("x86-windows", pghs[0]["Architecture"].c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual("same", pghs[0]["Multi-Arch"].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(BinaryParagraph_serialize_max)
|
|
|
|
{
|
|
|
|
vcpkg::BinaryParagraph pgh({
|
2017-04-29 03:55:50 +08:00
|
|
|
{"Package", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Architecture", "x86-windows"},
|
|
|
|
{"Description", "first line\n second line"},
|
|
|
|
{"Maintainer", "abc <abc@abc.abc>"},
|
|
|
|
{"Depends", "dep"},
|
|
|
|
{"Multi-Arch", "same"},
|
2016-09-19 11:50:08 +08:00
|
|
|
});
|
2017-04-13 13:48:52 +08:00
|
|
|
std::string ss = Strings::serialize(pgh);
|
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual(size_t(7), pghs[0].size());
|
|
|
|
Assert::AreEqual("zlib", pghs[0]["Package"].c_str());
|
|
|
|
Assert::AreEqual("1.2.8", pghs[0]["Version"].c_str());
|
2016-11-05 16:02:15 +08:00
|
|
|
Assert::AreEqual("x86-windows", pghs[0]["Architecture"].c_str());
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual("same", pghs[0]["Multi-Arch"].c_str());
|
|
|
|
Assert::AreEqual("first line\n second line", pghs[0]["Description"].c_str());
|
|
|
|
Assert::AreEqual("dep", pghs[0]["Depends"].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_METHOD(BinaryParagraph_serialize_multiple_deps)
|
|
|
|
{
|
|
|
|
vcpkg::BinaryParagraph pgh({
|
2017-04-29 03:55:50 +08:00
|
|
|
{"Package", "zlib"},
|
|
|
|
{"Version", "1.2.8"},
|
|
|
|
{"Architecture", "x86-windows"},
|
|
|
|
{"Multi-Arch", "same"},
|
|
|
|
{"Depends", "a, b, c"},
|
2016-09-19 11:50:08 +08:00
|
|
|
});
|
2017-04-13 13:48:52 +08:00
|
|
|
std::string ss = Strings::serialize(pgh);
|
|
|
|
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
|
2016-09-19 11:50:08 +08:00
|
|
|
Assert::AreEqual(size_t(1), pghs.size());
|
|
|
|
Assert::AreEqual("a, b, c", pghs[0]["Depends"].c_str());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|