Skip to content

Commit

Permalink
Tests: Update reference data for libyaml version 0.2.5.
Browse files Browse the repository at this point in the history
Libyaml does not emit trailing whitespace now.  Since we want
to work with older versions of libyaml too, we check against
reference output with and without trailing whitespace.

See: yaml/libyaml#186
  • Loading branch information
tlsa committed Jun 27, 2020
1 parent 466b095 commit 0e94726
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/units/save.c
Expand Up @@ -3476,7 +3476,7 @@ static bool test_save_sequence_null_values_int(
ttest_report_ctx_t *report,
const cyaml_config_t *config)
{
static const unsigned char ref[] =
static const unsigned char ref1[] =
"---\n"
"- 7\n"
"- 6\n"
Expand All @@ -3487,6 +3487,18 @@ static bool test_save_sequence_null_values_int(
"- \n"
"- 0\n"
"...\n";
/* As of libyaml 0.2.5, trailing spaces are not emitted. */
static const unsigned char ref2[] =
"---\n"
"- 7\n"
"- 6\n"
"- 5\n"
"-\n"
"- 3\n"
"- 2\n"
"-\n"
"- 0\n"
"...\n";
static const int d[] = { 7, 6, 5, 4, 3, 2, 1, 0 };
static const int *data[] = { d + 0, d + 1, d + 2, NULL,
d + 4, d + 5, NULL, d + 7, };
Expand Down Expand Up @@ -3515,11 +3527,12 @@ static bool test_save_sequence_null_values_int(
return ttest_fail(&tc, cyaml_strerror(err));
}

if (len != YAML_LEN(ref) || memcmp(ref, buffer, len) != 0) {
if ((len != YAML_LEN(ref1) || memcmp(ref1, buffer, len) != 0) &&
(len != YAML_LEN(ref2) || memcmp(ref2, buffer, len) != 0)) {
return ttest_fail(&tc, "Bad data:\n"
"EXPECTED (%zu):\n\n%.*s\n\n"
"GOT (%zu):\n\n%.*s\n",
YAML_LEN(ref), YAML_LEN(ref), ref,
YAML_LEN(ref1), YAML_LEN(ref1), ref1,
len, len, buffer);
}

Expand Down

0 comments on commit 0e94726

Please sign in to comment.