[test] ensure covering yaml events tool failures

This commit is contained in:
Joao Paulo Magalhaes
2022-01-29 21:43:31 +00:00
parent c17e97324f
commit d073cc8e13
5 changed files with 21 additions and 12 deletions

View File

@@ -103,7 +103,7 @@ As part of the [new feature to track source locations](https://github.com/biojpp
### Fixes
- Ensure error messages do not wrap around the buffer when the YAML source line is too long ([PR#210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Ensure error is emitted on unclosed flow sequence characters eg `[[[` ([PR#210](https://github.com/biojppm/rapidyaml/pulls/210)).
- Ensure error is emitted on unclosed flow sequence characters eg `[[[` ([PR#210](https://github.com/biojppm/rapidyaml/pulls/210)). Same thing for `[]]`.
- Fix [#203](https://github.com/biojppm/rapidyaml/issues/203): when parsing, do not convert `null` or `~` to null scalar strings. Now the scalar strings contain the verbatim contents of the original scalar; to query whether a scalar value is null, use `Tree::key_is_null()/val_is_null()` and `NodeRef::key_is_null()/val_is_null()` which return true if it is empty or any of the unquoted strings `~`, `null`, `Null`, or `NULL`. ([PR#207](https://github.com/biojppm/rapidyaml/pulls/207)):
- Fix [#205](https://github.com/biojppm/rapidyaml/issues/205): fix parsing of escaped characters in double-quoted strings: `"\\\"\n\r\t\<TAB>\/\<SPC>\0\b\f\a\v\e\_\N\L\P"` ([PR#207](https://github.com/biojppm/rapidyaml/pulls/207)).
- Fix [#204](https://github.com/biojppm/rapidyaml/issues/204): add decoding of unicode codepoints `\x` `\u` `\U` in double-quoted scalars:

View File

@@ -3053,7 +3053,7 @@ void Parser::_end_stream()
{
_c4dbgpf("popping level: %zu (stack sz=%zu)", m_state->level, m_stack.size());
_RYML_CB_ASSERT(m_stack.m_callbacks, ! has_any(SSCL, &m_stack.top()));
if(has_all(RSEQ|EXPL|RVAL))
if(has_all(RSEQ|EXPL))
_err("closing ] not found");
_pop_level();
}

View File

@@ -124,24 +124,23 @@ if(RYML_TEST_TOOLS)
# events emitter
function(ryml_create_file name contents fileout)
set(filename ${CMAKE_CURRENT_BINARY_DIR}/${name})
file(WRITE "${filename}" "${contents}")
file(WRITE "${filename}" "${contents}
")
set("${fileout}" "${filename}" PARENT_SCOPE)
endfunction()
function(ryml_add_event_tool_test name expect_success contents)
ryml_create_file(${name}.yml "${contents}" file)
add_test(NAME ryml-test-tool-events-${name} COMMAND ${RYML_TGT_EVENTS} ${name}.yml)
if(UNIX)
#add_test(NAME ryml-test-tool-events-${name}-stdin COMMAND ${CMAKE_COMMAND} -E echo '${contents}' | ${RYML_TGT_EVENTS} -)
endif()
add_test(NAME ryml-test-tool-events-${name} COMMAND ${RYML_TGT_EVENTS} ${file})
if(NOT expect_success)
set_tests_properties(ryml-test-tool-events-${name} PROPERTIES WILL_FAIL TRUE)
#set_tests_properties(ryml-test-tool-events-${name}-stdin PROPERTIES WILL_FAIL TRUE)
endif()
endfunction()
ryml_get_target_exe(ryml-yaml-events RYML_TGT_EVENTS)
ryml_add_event_tool_test(success TRUE "{foo: bar, baz: [exactly]")
ryml_add_event_tool_test(success TRUE "{foo: bar, baz: [exactly]}")
ryml_add_event_tool_test(fail_squo FALSE "foo: 'bar")
ryml_add_event_tool_test(fail_badseq FALSE "[ a, b, c ] ]")
ryml_add_event_tool_test(fail_dquo FALSE "foo: \"bar")
ryml_add_event_tool_test(fail_seq1 FALSE "[ a, b, c ] ]")
ryml_add_event_tool_test(fail_seq2 FALSE "[ [a, b, c ]")
endif()

View File

@@ -3,7 +3,7 @@
namespace c4 {
namespace yml {
TEST(simple_seq, bad_seq)
TEST(simple_seq, bad_seq1)
{
Tree tree;
ExpectError::do_check(&tree, [&]{
@@ -14,6 +14,17 @@ TEST(simple_seq, bad_seq)
});
}
TEST(simple_seq, bad_seq2)
{
Tree tree;
ExpectError::do_check(&tree, [&]{
parse_in_arena(R"(
---
[ [ a, b, c ]
)", &tree);
});
}
TEST(simple_seq, two_nested_flow_seqs)
{
Tree tree = parse_in_arena("[[]]");

View File

@@ -43,7 +43,6 @@ int main(int argc, const char *argv[])
{
return 1;
}
return 0;
}