diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-04-06 23:47:48 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-04-08 16:51:41 +0300 |
commit | a16982956c5e87d9b2f238522d902df177ece98e (patch) | |
tree | 71f049508596a2004b872d8b5fbdeaf473148696 /tests | |
parent | 89659b66de7611e9a3f33e7354493ac1c540fe70 (diff) |
Add support for manifest_serializer long lines mode
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manifest-serializer/driver.cxx | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/tests/manifest-serializer/driver.cxx b/tests/manifest-serializer/driver.cxx index d6e538d..4cddb57 100644 --- a/tests/manifest-serializer/driver.cxx +++ b/tests/manifest-serializer/driver.cxx @@ -32,6 +32,7 @@ using pairs = vector<pair<string, string>>; static bool test (const pairs& manifest, const string& expected, + bool long_lines = false, manifest_serializer::filter_function f = {}); static bool @@ -178,7 +179,6 @@ main () assert (test ({{"","1"},{"a",l4},{"",""},{"",""}}, ": 1\na: " + e4 + "\n")); assert (test ({{"","1"},{"a",l5},{"",""},{"",""}}, ": 1\na: " + e5 + "\n")); - // Multi-line value. // string n ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); @@ -199,6 +199,20 @@ main () assert (test ({{"","1"},{"a"," x "},{"",""},{"",""}}, ": 1\na: \\\n x \n\\\n")); + // The long lines mode. + // + assert (test ({{"","1"},{"a",l1},{"",""},{"",""}}, + ": 1\na: " + l1 + "\n", + true /* long_lines */)); + + assert (test ({{"","1"},{"a", " abc\n" + l1 + "\ndef"},{"",""},{"",""}}, + ": 1\na: \\\n abc\n" + l1 + "\ndef\n\\\n", + true /* long_lines */)); + + assert (test ({{"","1"},{n,l1},{"",""},{"",""}}, + ": 1\n" + n + ": \\\n" + l1 + "\n\\\n", + true /* long_lines */)); + // Carriage return character. // assert (test ({{"","1"},{"a","x\ry"},{"",""},{"",""}}, @@ -241,15 +255,18 @@ main () // assert (test ({{"","1"},{"a","abc"},{"b","bca"},{"c","cab"},{"",""},{"",""}}, ": 1\na: abc\nc: cab\n", + false /* long_lines */, [] (const string& n, const string&) {return n != "b";})); } static string -serialize (const pairs& m, manifest_serializer::filter_function f = {}) +serialize (const pairs& m, + bool long_lines = false, + manifest_serializer::filter_function f = {}) { ostringstream os; os.exceptions (istream::failbit | istream::badbit); - manifest_serializer s (os, "", f); + manifest_serializer s (os, "", long_lines, f); for (const auto& p: m) { @@ -263,9 +280,12 @@ serialize (const pairs& m, manifest_serializer::filter_function f = {}) } static bool -test (const pairs& m, const string& e, manifest_serializer::filter_function f) +test (const pairs& m, + const string& e, + bool long_lines, + manifest_serializer::filter_function f) { - string r (serialize (m, f)); + string r (serialize (m, long_lines, f)); if (r != e) { |