From 6254448640530240dc9199bed60cd5568cbaf601 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 1 Aug 2017 16:42:22 +0300 Subject: Add manifest_parser::split_comment() and manifest_serializer::merge_comment() --- tests/manifest-parser/driver.cxx | 17 +++++++++++++++++ tests/manifest-serializer/driver.cxx | 8 ++++++++ 2 files changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/manifest-parser/driver.cxx b/tests/manifest-parser/driver.cxx index e480508..037df96 100644 --- a/tests/manifest-parser/driver.cxx +++ b/tests/manifest-parser/driver.cxx @@ -130,6 +130,23 @@ main () {{"","1"},{"a","x\\"},{"b",""},{"",""},{"",""}})); assert (test (":1\na:\\\nx\\\\\\\n\\\nb:", {{"","1"},{"a","x\\\\"},{"b",""},{"",""},{"",""}})); + + // Manifest value splitting (into the value/comment pair). + // + { + auto p (manifest_parser::split_comment ("value\\; text ; comment text")); + assert (p.first == "value; text" && p.second == "comment text"); + } + + { + auto p (manifest_parser::split_comment ("value")); + assert (p.first == "value" && p.second == ""); + } + + { + auto p (manifest_parser::split_comment ("; comment")); + assert (p.first == "" && p.second == "comment"); + } } static ostream& diff --git a/tests/manifest-serializer/driver.cxx b/tests/manifest-serializer/driver.cxx index 69c1c71..dad96bd 100644 --- a/tests/manifest-serializer/driver.cxx +++ b/tests/manifest-serializer/driver.cxx @@ -213,6 +213,14 @@ main () ": 1\na: c:\\\\\n")); assert (test ({{"","1"},{"a","c:\\\nd:\\"},{"",""},{"",""}}, ": 1\na: \\\nc:\\\\\nd:\\\\\n\\\n")); + + // Manifest value/comment merging. + // + assert (manifest_serializer::merge_comment ("value; text", "comment") == + "value\\; text; comment"); + + assert (manifest_serializer::merge_comment ("value text", "") == + "value text"); } static string -- cgit v1.1