| 1 | Fix build against libyaml 0.2.5.
|
| 2 |
|
| 3 | Taken from upstream:
|
| 4 | https://github.com/tlsa/libcyaml/commit/0e947264b947f51f7ea785068637c4bfce5d4171
|
| 5 |
|
| 6 | diff --git a/test/units/save.c b/test/units/save.c
|
| 7 | |
| 8 | |
| 9 | @@ -3476,7 +3476,7 @@ static bool test_save_sequence_null_values_int(
|
| 10 | ttest_report_ctx_t *report,
|
| 11 | const cyaml_config_t *config)
|
| 12 | {
|
| 13 | - static const unsigned char ref[] =
|
| 14 | + static const unsigned char ref1[] =
|
| 15 | "---\n"
|
| 16 | "- 7\n"
|
| 17 | "- 6\n"
|
| 18 | @@ -3487,6 +3487,18 @@ static bool test_save_sequence_null_values_int(
|
| 19 | "- \n"
|
| 20 | "- 0\n"
|
| 21 | "...\n";
|
| 22 | + /* As of libyaml 0.2.5, trailing spaces are not emitted. */
|
| 23 | + static const unsigned char ref2[] =
|
| 24 | + "---\n"
|
| 25 | + "- 7\n"
|
| 26 | + "- 6\n"
|
| 27 | + "- 5\n"
|
| 28 | + "-\n"
|
| 29 | + "- 3\n"
|
| 30 | + "- 2\n"
|
| 31 | + "-\n"
|
| 32 | + "- 0\n"
|
| 33 | + "...\n";
|
| 34 | static const int d[] = { 7, 6, 5, 4, 3, 2, 1, 0 };
|
| 35 | static const int *data[] = { d + 0, d + 1, d + 2, NULL,
|
| 36 | d + 4, d + 5, NULL, d + 7, };
|
| 37 | @@ -3515,11 +3527,12 @@ static bool test_save_sequence_null_values_int(
|
| 38 | return ttest_fail(&tc, cyaml_strerror(err));
|
| 39 | }
|
| 40 |
|
| 41 | - if (len != YAML_LEN(ref) || memcmp(ref, buffer, len) != 0) {
|
| 42 | + if ((len != YAML_LEN(ref1) || memcmp(ref1, buffer, len) != 0) &&
|
| 43 | + (len != YAML_LEN(ref2) || memcmp(ref2, buffer, len) != 0)) {
|
| 44 | return ttest_fail(&tc, "Bad data:\n"
|
| 45 | "EXPECTED (%zu):\n\n%.*s\n\n"
|
| 46 | "GOT (%zu):\n\n%.*s\n",
|
| 47 | - YAML_LEN(ref), YAML_LEN(ref), ref,
|
| 48 | + YAML_LEN(ref1), YAML_LEN(ref1), ref1,
|
| 49 | len, len, buffer);
|
| 50 | }
|
| 51 |
|