mirror of
https://github.com/biojppm/rapidyaml.git
synced 2026-01-18 13:31:19 +01:00
refactor error API: update tests
This commit is contained in:
@@ -66,6 +66,7 @@ public:
|
||||
bool m_has_yaml_directive;
|
||||
extra::string m_arena;
|
||||
bool m_has_docs;
|
||||
csubstr m_src;
|
||||
|
||||
// undefined at the end
|
||||
#define _enable_(bits) _enable__<bits>()
|
||||
@@ -78,9 +79,9 @@ public:
|
||||
/** @name construction and resetting
|
||||
* @{ */
|
||||
|
||||
EventHandlerTestSuite() : EventHandlerStack(), m_sink(), m_val_buffers(), m_key_tag_buf(), m_val_tag_buf(), m_tag_directives(), m_has_yaml_directive(), m_arena(), m_has_docs() {}
|
||||
EventHandlerTestSuite(Callbacks const& cb) : EventHandlerStack(cb), m_sink(), m_val_buffers(), m_key_tag_buf(), m_val_tag_buf(), m_tag_directives(), m_has_yaml_directive(), m_arena(), m_has_docs() {}
|
||||
EventHandlerTestSuite(EventSink *sink, Callbacks const& cb) : EventHandlerStack(cb), m_sink(sink), m_val_buffers(), m_key_tag_buf(), m_val_tag_buf(), m_tag_directives(), m_has_yaml_directive(), m_arena(), m_has_docs()
|
||||
EventHandlerTestSuite() : EventHandlerStack(), m_sink(), m_val_buffers(), m_key_tag_buf(), m_val_tag_buf(), m_tag_directives(), m_has_yaml_directive(), m_arena(), m_has_docs(), m_src() {}
|
||||
EventHandlerTestSuite(Callbacks const& cb) : EventHandlerStack(cb), m_sink(), m_val_buffers(), m_key_tag_buf(), m_val_tag_buf(), m_tag_directives(), m_has_yaml_directive(), m_arena(), m_has_docs(), m_src() {}
|
||||
EventHandlerTestSuite(EventSink *sink, Callbacks const& cb) : EventHandlerStack(cb), m_sink(sink), m_val_buffers(), m_key_tag_buf(), m_val_tag_buf(), m_tag_directives(), m_has_yaml_directive(), m_arena(), m_has_docs(), m_src()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
@@ -100,6 +101,7 @@ public:
|
||||
m_key_tag_buf.resize(256);
|
||||
m_val_tag_buf.resize(256);
|
||||
m_has_docs = false;
|
||||
m_src = {};
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -109,15 +111,15 @@ public:
|
||||
/** @name parse events
|
||||
* @{ */
|
||||
|
||||
void start_parse(const char* filename, detail::pfn_relocate_arena relocate_arena, void *relocate_arena_data)
|
||||
void start_parse(const char* filename, csubstr src, detail::pfn_relocate_arena relocate_arena, void *relocate_arena_data)
|
||||
{
|
||||
this->_stack_start_parse(filename, relocate_arena, relocate_arena_data);
|
||||
this->_stack_start_parse(filename, src, relocate_arena, relocate_arena_data);
|
||||
}
|
||||
|
||||
void finish_parse()
|
||||
{
|
||||
if((_num_tag_directives() || m_has_yaml_directive) && !m_has_docs)
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "directives cannot be used without a document", {});
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "directives cannot be used without a document");
|
||||
this->_stack_finish_parse();
|
||||
}
|
||||
|
||||
@@ -213,7 +215,7 @@ public:
|
||||
|
||||
void begin_map_key_flow()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+MAP {}");
|
||||
_send_key_props_();
|
||||
_send_('\n');
|
||||
@@ -223,7 +225,7 @@ public:
|
||||
}
|
||||
void begin_map_key_block()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+MAP");
|
||||
_send_key_props_();
|
||||
_send_('\n');
|
||||
@@ -234,7 +236,7 @@ public:
|
||||
|
||||
void begin_map_val_flow()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+MAP {}");
|
||||
_send_val_props_();
|
||||
_send_('\n');
|
||||
@@ -244,7 +246,7 @@ public:
|
||||
}
|
||||
void begin_map_val_block()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+MAP");
|
||||
_send_val_props_();
|
||||
_send_('\n');
|
||||
@@ -268,7 +270,7 @@ public:
|
||||
|
||||
void begin_seq_key_flow()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+SEQ []");
|
||||
_send_key_props_();
|
||||
_send_('\n');
|
||||
@@ -278,7 +280,7 @@ public:
|
||||
}
|
||||
void begin_seq_key_block()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+SEQ");
|
||||
_send_key_props_();
|
||||
_send_('\n');
|
||||
@@ -289,7 +291,7 @@ public:
|
||||
|
||||
void begin_seq_val_flow()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+SEQ []");
|
||||
_send_val_props_();
|
||||
_send_('\n');
|
||||
@@ -299,7 +301,7 @@ public:
|
||||
}
|
||||
void begin_seq_val_block()
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !_has_any_(VAL));
|
||||
_send_("+SEQ");
|
||||
_send_val_props_();
|
||||
_send_('\n');
|
||||
@@ -323,7 +325,7 @@ public:
|
||||
|
||||
void add_sibling()
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, m_parent);
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, m_parent);
|
||||
_buf_flush_to_(m_curr->level, m_parent->level);
|
||||
m_curr->ev_data = {};
|
||||
}
|
||||
@@ -344,7 +346,7 @@ public:
|
||||
// create the map.
|
||||
// this will push a new level, and tmp is one further
|
||||
begin_map_val_flow();
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, tmp != m_curr->level);
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, tmp != m_curr->level);
|
||||
// now move the saved val as the first key
|
||||
_buf_flush_to_(tmp, m_curr->level);
|
||||
}
|
||||
@@ -360,22 +362,22 @@ public:
|
||||
EventSink &sink = _buf_();
|
||||
substr full = sink;(void)full;
|
||||
// interpolate +MAP\n after the last +DOC\n
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, full.len);
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, !full.count('\r'));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, full.len);
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, !full.count('\r'));
|
||||
size_t docpos = sink.find_last("+DOC\n");
|
||||
if(docpos != npos)
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, (m_stack.size() == 1u) ? (docpos >= 5u) : (docpos == 0u));
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, docpos + 5u < full.len);
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, (m_stack.size() == 1u) ? (docpos >= 5u) : (docpos == 0u));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, docpos + 5u < full.len);
|
||||
sink.insert("+MAP\n", docpos + 5u);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ... or interpolate +MAP\n after the last +DOC ---\n
|
||||
docpos = sink.find_last("+DOC ---\n");
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, docpos != npos);
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, (m_stack.size() == 1u) ? (docpos >= 5u) : (docpos == 0u));
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, docpos + 9u < full.len);
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, docpos != npos);
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, (m_stack.size() == 1u) ? (docpos >= 5u) : (docpos == 0u));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, docpos + 9u < full.len);
|
||||
sink.insert("+MAP\n", docpos + 9u);
|
||||
}
|
||||
_push();
|
||||
@@ -491,16 +493,16 @@ public:
|
||||
void set_key_anchor(csubstr anchor)
|
||||
{
|
||||
_c4dbgpf("node[{}]: set key anchor: [{}]~~~{}~~~", m_curr->node_id, anchor.len, anchor);
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, !_has_any_(KEYREF));
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, !anchor.begins_with('&'));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, !_has_any_(KEYREF));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, !anchor.begins_with('&'));
|
||||
_enable_(KEYANCH);
|
||||
m_curr->ev_data.m_key.anchor = anchor;
|
||||
}
|
||||
void set_val_anchor(csubstr anchor)
|
||||
{
|
||||
_c4dbgpf("node[{}]: set val anchor: [{}]~~~{}~~~", m_curr->node_id, anchor.len, anchor);
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, !_has_any_(VALREF));
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, !anchor.begins_with('&'));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, !_has_any_(VALREF));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, !anchor.begins_with('&'));
|
||||
_enable_(VALANCH);
|
||||
m_curr->ev_data.m_val.anchor = anchor;
|
||||
}
|
||||
@@ -509,8 +511,8 @@ public:
|
||||
{
|
||||
_c4dbgpf("node[{}]: set key ref: [{}]~~~{}~~~", m_curr->node_id, ref.len, ref);
|
||||
if(C4_UNLIKELY(_has_any_(KEYANCH)))
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "key cannot have both anchor and ref", m_curr->pos);
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, ref.begins_with('*'));
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "key cannot have both anchor and ref");
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, ref.begins_with('*'));
|
||||
_enable_(KEY|KEYREF);
|
||||
_send_("=ALI ");
|
||||
_send_(ref);
|
||||
@@ -520,8 +522,8 @@ public:
|
||||
{
|
||||
_c4dbgpf("node[{}]: set val ref: [{}]~~~{}~~~", m_curr->node_id, ref.len, ref);
|
||||
if(C4_UNLIKELY(_has_any_(VALANCH)))
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "val cannot have both anchor and ref", m_curr->pos);
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, ref.begins_with('*'));
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "val cannot have both anchor and ref");
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, ref.begins_with('*'));
|
||||
_enable_(VAL|VALREF);
|
||||
_send_("=ALI ");
|
||||
_send_(ref);
|
||||
@@ -557,20 +559,20 @@ public:
|
||||
|
||||
void add_directive(csubstr directive)
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, directive.begins_with('%'));
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, directive.begins_with('%'));
|
||||
if(directive.begins_with("%TAG"))
|
||||
{
|
||||
const id_type pos = _num_tag_directives();
|
||||
if(C4_UNLIKELY(pos >= RYML_MAX_TAG_DIRECTIVES))
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "too many directives", m_curr->pos);
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "too many directives");
|
||||
if(C4_UNLIKELY(!m_tag_directives[pos].create_from_str(directive)))
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "failed to add directive", m_curr->pos);
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "failed to add directive");
|
||||
}
|
||||
else if(directive.begins_with("%YAML"))
|
||||
{
|
||||
_c4dbgpf("%YAML directive! ignoring...: {}", directive);
|
||||
if(C4_UNLIKELY(m_has_yaml_directive))
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "multiple yaml directives", m_curr->pos);
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "multiple yaml directives");
|
||||
m_has_yaml_directive = true;
|
||||
}
|
||||
else
|
||||
@@ -655,19 +657,19 @@ public:
|
||||
|
||||
EventSink& _buf_() noexcept
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, m_curr->level < m_val_buffers.size());
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, m_curr->level < m_val_buffers.size());
|
||||
return m_val_buffers[m_curr->level];
|
||||
}
|
||||
|
||||
EventSink& _buf_(id_type level) noexcept
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, level < m_val_buffers.size());
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, level < m_val_buffers.size());
|
||||
return m_val_buffers[level];
|
||||
}
|
||||
|
||||
EventSink const& _buf_(id_type level) const noexcept
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, level < m_val_buffers.size());
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, level < m_val_buffers.size());
|
||||
return m_val_buffers[level];
|
||||
}
|
||||
|
||||
@@ -747,7 +749,7 @@ public:
|
||||
}
|
||||
void _send_tag_(csubstr tag)
|
||||
{
|
||||
_RYML_CB_ASSERT(m_stack.m_callbacks, !tag.empty());
|
||||
_RYML_ASSERT_BASIC_(m_stack.m_callbacks, !tag.empty());
|
||||
if(tag.str[0] == '<')
|
||||
{
|
||||
_send_(' ');
|
||||
@@ -797,7 +799,7 @@ public:
|
||||
}
|
||||
if(len > output->size())
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !retry);
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !retry);
|
||||
retry = true;
|
||||
output->resize(len);
|
||||
output->resize(output->capacity());
|
||||
@@ -810,7 +812,7 @@ public:
|
||||
{
|
||||
if(is_custom_tag(tag))
|
||||
{
|
||||
_RYML_CB_ERR_(m_stack.m_callbacks, "tag not found", m_curr->pos);
|
||||
_RYML_ERR_PARSE_(m_stack.m_callbacks, m_curr->pos, "tag not found");
|
||||
}
|
||||
}
|
||||
bool retry = false;
|
||||
@@ -818,7 +820,7 @@ public:
|
||||
csubstr result = normalize_tag_long(tag, *output);
|
||||
if(!result.str)
|
||||
{
|
||||
_RYML_CB_CHECK(m_stack.m_callbacks, !retry);
|
||||
_RYML_CHECK_BASIC_(m_stack.m_callbacks, !retry);
|
||||
retry = true;
|
||||
output->resize(result.len);
|
||||
output->resize(output->capacity());
|
||||
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
}
|
||||
C4_ALWAYS_INLINE void insert(char c, id_type pos)
|
||||
{
|
||||
RYML_ASSERT(pos <= m_size);
|
||||
_RYML_ASSERT_BASIC(pos <= m_size);
|
||||
if(pos < m_size)
|
||||
{
|
||||
if(C4_UNLIKELY(m_size == m_capacity))
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
}
|
||||
C4_NO_INLINE void insert(csubstr cs, id_type pos)
|
||||
{
|
||||
RYML_ASSERT(pos <= m_size);
|
||||
_RYML_ASSERT_BASIC(pos <= m_size);
|
||||
if(cs.len)
|
||||
{
|
||||
if(pos < m_size)
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
}
|
||||
C4_NO_INLINE size_t find_last(csubstr pattern) RYML_NOEXCEPT
|
||||
{
|
||||
RYML_ASSERT(pattern.len);
|
||||
_RYML_ASSERT_BASIC(pattern.len);
|
||||
if(m_size >= pattern.len)
|
||||
{
|
||||
for(size_t i = m_size - pattern.len; i != (size_t)-1; --i)
|
||||
@@ -203,14 +203,14 @@ public:
|
||||
|
||||
void _free()
|
||||
{
|
||||
RYML_ASSERT(m_str != nullptr); // this structure cannot be memset() to zero
|
||||
_RYML_ASSERT_BASIC(m_str != nullptr); // this structure cannot be memset() to zero
|
||||
if(m_str != m_buf)
|
||||
{
|
||||
_RYML_CB_FREE(get_callbacks(), m_str, char, (size_t)m_capacity);
|
||||
m_str = m_buf;
|
||||
m_capacity = sso_size;
|
||||
}
|
||||
RYML_ASSERT(m_capacity == sso_size);
|
||||
_RYML_ASSERT_BASIC(m_capacity == sso_size);
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
@@ -219,13 +219,13 @@ public:
|
||||
#if RYML_USE_ASSERT
|
||||
if(that->m_str != that->m_buf)
|
||||
{
|
||||
RYML_ASSERT(that->m_capacity > sso_size);
|
||||
RYML_ASSERT(that->m_size <= that->m_capacity);
|
||||
_RYML_ASSERT_BASIC(that->m_capacity > sso_size);
|
||||
_RYML_ASSERT_BASIC(that->m_size <= that->m_capacity);
|
||||
}
|
||||
else
|
||||
{
|
||||
RYML_ASSERT(that->m_capacity <= sso_size);
|
||||
RYML_ASSERT(that->m_size <= that->m_capacity);
|
||||
_RYML_ASSERT_BASIC(that->m_capacity <= sso_size);
|
||||
_RYML_ASSERT_BASIC(that->m_size <= that->m_capacity);
|
||||
}
|
||||
#endif
|
||||
memcpy(m_str, that->m_str, that->m_size);
|
||||
@@ -237,21 +237,21 @@ public:
|
||||
{
|
||||
if(that->m_str != that->m_buf)
|
||||
{
|
||||
RYML_ASSERT(that->m_capacity > sso_size);
|
||||
RYML_ASSERT(that->m_size <= that->m_capacity);
|
||||
_RYML_ASSERT_BASIC(that->m_capacity > sso_size);
|
||||
_RYML_ASSERT_BASIC(that->m_size <= that->m_capacity);
|
||||
m_str = that->m_str;
|
||||
}
|
||||
else
|
||||
{
|
||||
RYML_ASSERT(that->m_capacity <= sso_size);
|
||||
RYML_ASSERT(that->m_size <= that->m_capacity);
|
||||
_RYML_ASSERT_BASIC(that->m_capacity <= sso_size);
|
||||
_RYML_ASSERT_BASIC(that->m_size <= that->m_capacity);
|
||||
memcpy(m_buf, that->m_buf, that->m_size);
|
||||
m_str = m_buf;
|
||||
}
|
||||
m_size = that->m_size;
|
||||
m_capacity = that->m_capacity;
|
||||
// make sure no deallocation happens on destruction
|
||||
RYML_ASSERT(that->m_str != this->m_buf);
|
||||
_RYML_ASSERT_BASIC(that->m_str != this->m_buf);
|
||||
that->m_str = that->m_buf;
|
||||
that->m_capacity = sso_size;
|
||||
that->m_size = 0;
|
||||
@@ -328,7 +328,7 @@ public:
|
||||
|
||||
void _free()
|
||||
{
|
||||
RYML_ASSERT(m_arr != nullptr); // this structure cannot be memset() to zero
|
||||
_RYML_ASSERT_BASIC(m_arr != nullptr); // this structure cannot be memset() to zero
|
||||
for(id_type i = 0; i < m_size; ++i)
|
||||
m_arr[i].~string();
|
||||
if(m_arr != m_buf)
|
||||
@@ -337,7 +337,7 @@ public:
|
||||
m_arr = m_buf;
|
||||
m_capacity = sso_size;
|
||||
}
|
||||
RYML_ASSERT(m_capacity == sso_size);
|
||||
_RYML_ASSERT_BASIC(m_capacity == sso_size);
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
|
||||
string& emplace_back()
|
||||
{
|
||||
RYML_ASSERT(m_size < m_capacity);
|
||||
_RYML_ASSERT_BASIC(m_size < m_capacity);
|
||||
if(m_size == m_capacity)
|
||||
reserve(m_size + 1);
|
||||
string& ret = m_arr[m_size++];
|
||||
@@ -400,14 +400,14 @@ public:
|
||||
}
|
||||
string& operator[] (id_type i)
|
||||
{
|
||||
RYML_ASSERT(m_size <= m_capacity);
|
||||
RYML_ASSERT(i < m_size);
|
||||
_RYML_ASSERT_BASIC(m_size <= m_capacity);
|
||||
_RYML_ASSERT_BASIC(i < m_size);
|
||||
return m_arr[i];
|
||||
}
|
||||
string const& operator[] (id_type i) const
|
||||
{
|
||||
RYML_ASSERT(m_size <= m_capacity);
|
||||
RYML_ASSERT(i < m_size);
|
||||
_RYML_ASSERT_BASIC(m_size <= m_capacity);
|
||||
_RYML_ASSERT_BASIC(i < m_size);
|
||||
return m_arr[i];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,6 +16,8 @@ ryml_add_test_no_lib(ryml-test-quickstart-ints
|
||||
../samples/quickstart-ints.cpp
|
||||
../src_extra/c4/yml/extra/event_handler_ints.hpp
|
||||
../src_extra/c4/yml/extra/event_handler_ints.cpp
|
||||
../src_extra/c4/yml/extra/ints_utils.hpp
|
||||
../src_extra/c4/yml/extra/ints_utils.cpp
|
||||
INC_DIRS ../src_extra)
|
||||
|
||||
|
||||
|
||||
@@ -658,13 +658,13 @@ TEST(simple_anchor, resolve_nested)
|
||||
}
|
||||
{
|
||||
Tree t = parse_in_arena(yaml);
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_basic(&t, [&]{
|
||||
t.resolve(true);
|
||||
});
|
||||
}
|
||||
{
|
||||
Tree t = parse_in_arena(yaml);
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_basic(&t, [&]{
|
||||
t.resolve(false);
|
||||
});
|
||||
}
|
||||
@@ -862,7 +862,7 @@ N(MFS, L{N(KEY|VP, "*foo", AR(KEYREF, "foo"), "bar")})
|
||||
|
||||
ADD_CASE_TO_GROUP("anchor colon ambiguity 2", EXPECT_PARSE_ERROR,
|
||||
R"({*foo: bar})",
|
||||
LineCol(1, 8)
|
||||
Location(1, 8)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("merge example, unresolved",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <c4/format.hpp>
|
||||
#include <c4/yml/detail/checks.hpp>
|
||||
#include <c4/yml/detail/print.hpp>
|
||||
#include <c4/yml/parse_engine.def.hpp>
|
||||
#endif
|
||||
|
||||
#include "./test_lib/test_case.hpp"
|
||||
|
||||
@@ -123,13 +123,13 @@ void test_bom2(bom2spec const& spec, CreateFn &&createfn, TestFn &&testfn, bom2_
|
||||
}
|
||||
else
|
||||
{
|
||||
pfn_error orig = get_callbacks().m_error;
|
||||
ExpectError::check_error([&]{
|
||||
pfn_error_basic orig = get_callbacks().m_error_basic;
|
||||
ExpectError::check_error_basic([&]{
|
||||
Parser::handler_type handler;
|
||||
Parser parser(&handler);
|
||||
Tree tree;
|
||||
ASSERT_EQ((pfn_error)tree.callbacks().m_error, (pfn_error)parser.callbacks().m_error);
|
||||
ASSERT_NE((pfn_error)tree.callbacks().m_error, orig);
|
||||
ASSERT_EQ((pfn_error_basic)tree.callbacks().m_error_basic, (pfn_error_basic)parser.callbacks().m_error_basic);
|
||||
ASSERT_NE((pfn_error_basic)tree.callbacks().m_error_basic, orig);
|
||||
parse_in_arena(&parser, to_csubstr(buf), &tree);
|
||||
print_tree(tree);
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -381,7 +381,7 @@ R"(# the first : should cause a parse error
|
||||
b: 1
|
||||
c: 2
|
||||
)",
|
||||
LineCol(7, 6)
|
||||
Location(7, 6)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, multi doc, map-seq",
|
||||
@@ -415,7 +415,7 @@ R"(
|
||||
- c
|
||||
...
|
||||
)",
|
||||
LineCol(3, 6)
|
||||
Location(3, 6)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, multi doc, map-seq, no term",
|
||||
@@ -445,7 +445,7 @@ R"(
|
||||
- b
|
||||
- c
|
||||
)",
|
||||
LineCol(3, 6)
|
||||
Location(3, 6)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, multi doc, impl seq-map",
|
||||
@@ -471,7 +471,7 @@ R"(
|
||||
{a: 0, b: 1, c: 2}
|
||||
...
|
||||
)",
|
||||
LineCol(6, 7)
|
||||
Location(6, 7)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, multi doc, impl seq-map, no term",
|
||||
@@ -493,7 +493,7 @@ R"(
|
||||
---
|
||||
{a: 0, b: 1, c: 2}
|
||||
)",
|
||||
LineCol(5, 7)
|
||||
Location(5, 7)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, multi doc, impl map-seq",
|
||||
@@ -519,7 +519,7 @@ R"(
|
||||
[a, b, c]
|
||||
...
|
||||
)",
|
||||
LineCol(3, 7)
|
||||
Location(3, 7)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, multi doc, impl map-seq, no term",
|
||||
@@ -541,7 +541,7 @@ R"(
|
||||
---
|
||||
[a, b, c]
|
||||
)",
|
||||
LineCol(3, 7)
|
||||
Location(3, 7)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple doc, indented with empty lines", EXPECT_PARSE_ERROR,
|
||||
@@ -572,7 +572,7 @@ R"(
|
||||
d:
|
||||
some scalar
|
||||
)",
|
||||
LineCol(3, 7)
|
||||
Location(3, 7)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -216,14 +216,14 @@ void test_emits(Tree const& t, id_type id, std::string const& expected, std::str
|
||||
if(max_depth > 1)
|
||||
{
|
||||
EmitOptions opts = EmitOptions{}.max_depth(0);
|
||||
ExpectError::check_error(&t, [&]{ return emit2buf([&](substr buf){ return emit_yaml(t, id, opts, buf); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2buf([&](substr buf){ return emit_json(t, id, opts, buf); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2file([&](FILE *f){ return emit_yaml(t, id, opts, f); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2file([&](FILE *f){ return emit_json(t, id, opts, f); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_yaml(t, id, opts); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_json(t, id, opts); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emitrs_yaml<std::string>(t, id, opts); });
|
||||
ExpectError::check_error(&t, [&]{ return emitrs_json<std::string>(t, id, opts); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2buf([&](substr buf){ return emit_yaml(t, id, opts, buf); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2buf([&](substr buf){ return emit_json(t, id, opts, buf); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2file([&](FILE *f){ return emit_yaml(t, id, opts, f); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2file([&](FILE *f){ return emit_json(t, id, opts, f); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_yaml(t, id, opts); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_json(t, id, opts); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emitrs_yaml<std::string>(t, id, opts); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emitrs_json<std::string>(t, id, opts); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,14 +264,14 @@ void test_emits(Tree const& t, std::string const& expected, std::string const& e
|
||||
if(max_depth > 1)
|
||||
{
|
||||
EmitOptions opts = EmitOptions{}.max_depth(0);
|
||||
ExpectError::check_error(&t, [&]{ return emit2buf([&](substr buf){ return emit_yaml(t, opts, buf); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2buf([&](substr buf){ return emit_json(t, opts, buf); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2file([&](FILE *f){ return emit_yaml(t, opts, f); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2file([&](FILE *f){ return emit_json(t, opts, f); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_yaml(ConstNodeRef(&t), opts); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_json(ConstNodeRef(&t), opts); }); });
|
||||
ExpectError::check_error(&t, [&]{ return emitrs_yaml<std::string>(t, opts); });
|
||||
ExpectError::check_error(&t, [&]{ return emitrs_json<std::string>(t, opts); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2buf([&](substr buf){ return emit_yaml(t, opts, buf); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2buf([&](substr buf){ return emit_json(t, opts, buf); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2file([&](FILE *f){ return emit_yaml(t, opts, f); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2file([&](FILE *f){ return emit_json(t, opts, f); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_yaml(ConstNodeRef(&t), opts); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_json(ConstNodeRef(&t), opts); }); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emitrs_yaml<std::string>(t, opts); });
|
||||
ExpectError::check_error_basic(&t, [&]{ return emitrs_json<std::string>(t, opts); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,18 +312,18 @@ void test_emits(ConstNodeRef n, std::string const& expected, std::string const&
|
||||
if(max_depth > 1)
|
||||
{
|
||||
EmitOptions opts = EmitOptions{}.max_depth(0);
|
||||
ExpectError::check_error(n.tree(), [&]{
|
||||
ExpectError::check_error_basic(n.tree(), [&]{
|
||||
return emit2buf([&](substr buf){
|
||||
return emit_yaml(n, opts, buf);
|
||||
});
|
||||
});
|
||||
ExpectError::check_error(n.tree(), [&]{ return emit2buf([&](substr buf){ return emit_json(n, opts, buf); }); });
|
||||
ExpectError::check_error(n.tree(), [&]{ return emit2file([&](FILE *f){ return emit_yaml(n, opts, f); }); });
|
||||
ExpectError::check_error(n.tree(), [&]{ return emit2file([&](FILE *f){ return emit_json(n, opts, f); }); });
|
||||
ExpectError::check_error(n.tree(), [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_yaml(n, opts); }); });
|
||||
ExpectError::check_error(n.tree(), [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_json(n, opts); }); });
|
||||
ExpectError::check_error(n.tree(), [&]{ return emitrs_yaml<std::string>(n, opts); });
|
||||
ExpectError::check_error(n.tree(), [&]{ return emitrs_json<std::string>(n, opts); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emit2buf([&](substr buf){ return emit_json(n, opts, buf); }); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emit2file([&](FILE *f){ return emit_yaml(n, opts, f); }); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emit2file([&](FILE *f){ return emit_json(n, opts, f); }); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_yaml(n, opts); }); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emit2stream([&](std::ostringstream &oss){ oss << as_json(n, opts); }); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emitrs_yaml<std::string>(n, opts); });
|
||||
ExpectError::check_error_basic(n.tree(), [&]{ return emitrs_json<std::string>(n, opts); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1264,10 +1264,10 @@ TEST(emit, error_on_emit_yaml_to_short_buffer)
|
||||
const Tree tree = parse_in_arena(yaml);
|
||||
{
|
||||
char too_small[2];
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_yaml(tree, too_small);
|
||||
});
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_yaml(tree, too_small, /*error_on_excess*/true);
|
||||
});
|
||||
substr required = emit_yaml(tree, too_small, /*error_on_excess*/false);
|
||||
@@ -1278,10 +1278,10 @@ TEST(emit, error_on_emit_yaml_to_short_buffer)
|
||||
substr nothing;
|
||||
EXPECT_EQ(nothing.str, nullptr);
|
||||
EXPECT_EQ(nothing.len, 0u);
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_yaml(tree, nothing);
|
||||
});
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_yaml(tree, nothing, /*error_on_excess*/true);
|
||||
});
|
||||
substr required = emit_yaml(tree, nothing, /*error_on_excess*/false);
|
||||
@@ -1296,10 +1296,10 @@ TEST(emit, error_on_emit_json_to_short_buffer)
|
||||
const Tree tree = parse_in_arena(json);
|
||||
{
|
||||
char too_small[2];
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_json(tree, too_small);
|
||||
});
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_json(tree, too_small, /*error_on_excess*/true);
|
||||
});
|
||||
substr required = emit_json(tree, too_small, /*error_on_excess*/false);
|
||||
@@ -1310,10 +1310,10 @@ TEST(emit, error_on_emit_json_to_short_buffer)
|
||||
substr nothing;
|
||||
EXPECT_EQ(nothing.str, nullptr);
|
||||
EXPECT_EQ(nothing.len, 0u);
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_json(tree, nothing);
|
||||
});
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
emit_json(tree, nothing, /*error_on_excess*/true);
|
||||
});
|
||||
substr required = emit_json(tree, nothing, /*error_on_excess*/false);
|
||||
|
||||
@@ -271,7 +271,7 @@ R"(
|
||||
- ? :
|
||||
- ? :
|
||||
)",
|
||||
LineCol(2, 5)
|
||||
Location(2, 5)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("explicit key 2nd", HAS_CONTAINER_KEYS,
|
||||
@@ -279,7 +279,7 @@ R"(
|
||||
a simple key: a value
|
||||
? an explicit key: another value
|
||||
)",
|
||||
LineCol(3, 19)
|
||||
Location(3, 19)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("explicit key 1st", HAS_CONTAINER_KEYS,
|
||||
@@ -287,7 +287,7 @@ R"(
|
||||
? an explicit key: another value
|
||||
a simple key: a value
|
||||
)",
|
||||
LineCol(2, 19)
|
||||
Location(2, 19)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("explicit key nested in a map, 1st", HAS_CONTAINER_KEYS,
|
||||
@@ -297,7 +297,7 @@ map:
|
||||
a simple key: a value
|
||||
? an explicit key deindented: its value
|
||||
)",
|
||||
LineCol(3, 21)
|
||||
Location(3, 21)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("explicit key nested in a seq, 1st", HAS_CONTAINER_KEYS,
|
||||
@@ -306,7 +306,7 @@ R"(
|
||||
a simple key: a value
|
||||
- ? another explicit key: its value
|
||||
)",
|
||||
LineCol(2, 21)
|
||||
Location(2, 21)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("explicit block key, literal, clip",
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#include "test_lib/test_events_ints_helpers.hpp"
|
||||
#include <c4/yml/extra/event_handler_ints.hpp>
|
||||
|
||||
#ifndef _C4_YML_PARSE_ENGINE_DEF_HPP_
|
||||
#include <c4/yml/parse_engine.def.hpp>
|
||||
#endif
|
||||
|
||||
// NOLINTBEGIN(hicpp-signed-bitwise)
|
||||
|
||||
namespace c4 {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifdef RYML_SINGLE_HEADER
|
||||
#include "ryml_all.hpp"
|
||||
#else
|
||||
#include "c4/yml/error.hpp"
|
||||
#include "c4/yml/filter_processor.hpp"
|
||||
#include "c4/yml/event_handler_tree.hpp"
|
||||
#include "c4/yml/parse_engine.hpp"
|
||||
|
||||
@@ -34,46 +34,49 @@ bool report_errors = true;
|
||||
bool report_errors = false;
|
||||
#endif
|
||||
|
||||
inline void report_error(const char* msg, size_t length, c4::yml::Location loc, FILE *f)
|
||||
// watchout: VS2022 requires C4_NORETURN to come before inline
|
||||
[[noreturn]] void throwerr(c4::csubstr msg)
|
||||
{
|
||||
if(!report_errors)
|
||||
return;
|
||||
if(!loc.name.empty())
|
||||
{
|
||||
fwrite(loc.name.str, 1, loc.name.len, f);
|
||||
fputc(':', f);
|
||||
}
|
||||
fprintf(f, "%zu:", loc.line);
|
||||
if(loc.col)
|
||||
fprintf(f, "%zu:", loc.col);
|
||||
if(loc.offset)
|
||||
fprintf(f, " (%zuB):", loc.offset);
|
||||
fputc(' ', f);
|
||||
fprintf(f, "%.*s\n", static_cast<int>(length), msg);
|
||||
fflush(f);
|
||||
C4_IF_EXCEPTIONS(
|
||||
throw std::runtime_error({msg.str, msg.len});
|
||||
,
|
||||
jmp_msg.assign(msg.str, msg.len);
|
||||
std::longjmp(jmp_env, 1);
|
||||
);
|
||||
C4_UNREACHABLE_AFTER_ERR();
|
||||
}
|
||||
|
||||
// watchout: VS2022 requires C4_NORETURN to come before inline
|
||||
C4_NORETURN inline void errcallback(const char *msg, size_t msg_len, c4::yml::Location location, void *)
|
||||
void dump2stderr(c4::csubstr s)
|
||||
{
|
||||
report_error(msg, msg_len, location, stderr);
|
||||
C4_IF_EXCEPTIONS(
|
||||
throw std::runtime_error({msg, msg_len});
|
||||
,
|
||||
jmp_msg.assign(msg, msg_len);
|
||||
std::longjmp(jmp_env, 1);
|
||||
);
|
||||
if(s.len)
|
||||
{
|
||||
fwrite(s.str, 1, s.len, stderr);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
inline c4::yml::Callbacks create_custom_callbacks()
|
||||
{
|
||||
c4::set_error_flags(c4::ON_ERROR_CALLBACK);
|
||||
c4::set_error_callback([](const char *msg, size_t msg_len){
|
||||
errcallback(msg, msg_len, {}, nullptr);
|
||||
throwerr(c4::csubstr{msg, msg_len});
|
||||
});
|
||||
c4::yml::Callbacks callbacks = {};
|
||||
callbacks.m_error = errcallback;
|
||||
return callbacks;
|
||||
return c4::yml::Callbacks{}
|
||||
.set_error_basic([](c4::csubstr msg, c4::yml::ErrorDataBasic const& errdata, void *){
|
||||
if(report_errors)
|
||||
c4::yml::err_basic_format(dump2stderr, msg, errdata);
|
||||
throwerr(msg);
|
||||
})
|
||||
.set_error_parse([](c4::csubstr msg, c4::yml::ErrorDataParse const& errdata, void *){
|
||||
if(report_errors)
|
||||
c4::yml::err_parse_format(dump2stderr, msg, errdata);
|
||||
throwerr(msg);
|
||||
})
|
||||
.set_error_visit([](c4::csubstr msg, c4::yml::ErrorDataVisit const& errdata, void *){
|
||||
if(report_errors)
|
||||
c4::yml::err_visit_format(dump2stderr, msg, errdata);
|
||||
throwerr(msg);
|
||||
});
|
||||
}
|
||||
|
||||
namespace c4 {
|
||||
@@ -87,7 +90,7 @@ inline int fuzztest_parse_emit(uint32_t case_number, csubstr src)
|
||||
bool parse_success = false;
|
||||
C4_IF_EXCEPTIONS_(try, if(setjmp(jmp_env) == 0))
|
||||
{
|
||||
RYML_ASSERT(tree.empty());
|
||||
_RYML_ASSERT_BASIC(tree.empty());
|
||||
_if_dbg(_dbg_printf("in[{}]: [{}]~~~\n{}\n~~~\n", case_number, src.len, src); fflush(NULL));
|
||||
parse_in_arena(src, &tree);
|
||||
parse_success = true;
|
||||
|
||||
@@ -369,7 +369,7 @@ TEST(github, 31)
|
||||
}
|
||||
|
||||
{
|
||||
ExpectError::check_assertion(&tree, [&](){
|
||||
ExpectError::check_assert_basic(&tree, [&](){
|
||||
NodeRef lumi = plist.append_child();
|
||||
lumi << "Lumi";
|
||||
lumi |= MAP;
|
||||
@@ -377,7 +377,7 @@ TEST(github, 31)
|
||||
}
|
||||
|
||||
{
|
||||
ExpectError::check_assertion(&tree, [&](){
|
||||
ExpectError::check_assert_basic(&tree, [&](){
|
||||
NodeRef lumi = plist.append_child();
|
||||
lumi << "Lumi";
|
||||
lumi |= SEQ;
|
||||
@@ -385,7 +385,7 @@ TEST(github, 31)
|
||||
}
|
||||
|
||||
{
|
||||
ExpectError::check_assertion(&tree, [&](){
|
||||
ExpectError::check_assert_basic(&tree, [&](){
|
||||
NodeRef lumi = plist.append_child();
|
||||
lumi |= MAP;
|
||||
lumi << "Lumi";
|
||||
@@ -706,7 +706,7 @@ R"(
|
||||
- key1: true1
|
||||
MessageID1: 'MapRegion_HyrulePrairie1 '
|
||||
)",
|
||||
LineCol(4, 1)
|
||||
Location(4, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("github35/expected_error12", EXPECT_PARSE_ERROR,
|
||||
@@ -715,7 +715,7 @@ R"(
|
||||
- key2: true2
|
||||
MessageID2: "MapRegion_HyrulePrairie2 "
|
||||
)",
|
||||
LineCol(4, 1)
|
||||
Location(4, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("github35/expected_error21", EXPECT_PARSE_ERROR,
|
||||
@@ -724,7 +724,7 @@ R"(
|
||||
- key1: true1
|
||||
MessageID1: 'MapRegion_HyrulePrairie1 '
|
||||
)",
|
||||
LineCol(4, 15)
|
||||
Location(4, 15)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("github35/expected_error22", EXPECT_PARSE_ERROR,
|
||||
@@ -733,7 +733,7 @@ R"(
|
||||
- key2: true2
|
||||
MessageID2: "MapRegion_HyrulePrairie2 "
|
||||
)",
|
||||
LineCol(4, 15)
|
||||
Location(4, 15)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("github128/1", RESOLVE_REFS | EXPECT_RESOLVE_ERROR, "a: *invalid");
|
||||
|
||||
@@ -36,7 +36,7 @@ R"(a: plain
|
||||
scalar
|
||||
follows
|
||||
)",
|
||||
LineCol(2, 7)
|
||||
Location(2, 7)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar indentation, 2",
|
||||
@@ -52,7 +52,7 @@ R"(- plain
|
||||
scalar
|
||||
follows
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar indentation, 3",
|
||||
|
||||
@@ -495,119 +495,119 @@ quntity2: 95000000)");
|
||||
|
||||
TEST(parse_json, error_on_missing_seq_val)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("[foo, , ]");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_seq_val)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("[0 1, ]");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_seq_val_quoted)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("[\"0\" 1, ]");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_seq_val_quoted_2)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("[\"0\" \"1\", ]");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_seq_val_quoted_3)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("[0 \"1\", ]");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_map_val)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"key\": 0 1}");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_map_val_quoted)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"key\": 0 \"1\"}");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_map_val_quoted_2)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"key\": \"0\" 1}");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_double_map_val_quoted_3)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"key\": \"0\" \"1\"}");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_missing_seq_term)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("[foo, ");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_missing_map_val)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"foo\": }");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_missing_map_term)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"foo\": 0");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_missing_map_colon)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"foo\" }");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_bad_map_val)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{\"foo\": , }");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_wrong_key_character)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{'foo': 1}");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_unquoted_key_character)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("{foo: 1}");
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_json, error_on_bare_keyval)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_json_in_arena("\"fails\": true");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ struct CallbacksTester
|
||||
{
|
||||
_c4dbgpf("size: alloc={} dealloc={}", alloc_size, dealloc_size);
|
||||
_c4dbgpf("count: #allocs={} #deallocs={}", num_allocs, num_deallocs);
|
||||
RYML_CHECK(num_allocs == num_deallocs);
|
||||
RYML_CHECK(alloc_size == dealloc_size);
|
||||
_RYML_CHECK_BASIC(num_allocs == num_deallocs);
|
||||
_RYML_CHECK_BASIC(alloc_size == dealloc_size);
|
||||
}
|
||||
|
||||
Callbacks callbacks() const
|
||||
@@ -63,14 +63,14 @@ struct CallbacksTester
|
||||
void *ptr = &memory_pool[alloc_size];
|
||||
alloc_size += len;
|
||||
++num_allocs;
|
||||
RYML_CHECK(alloc_size < memory_pool.size());
|
||||
_RYML_CHECK_BASIC(alloc_size < memory_pool.size());
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void free(void *mem, size_t len)
|
||||
{
|
||||
RYML_CHECK((char*)mem >= &memory_pool.front() && (char*)mem < &memory_pool.back());
|
||||
RYML_CHECK((char*)mem+len >= &memory_pool.front() && (char*)mem+len <= &memory_pool.back());
|
||||
_RYML_CHECK_BASIC((char*)mem >= &memory_pool.front() && (char*)mem < &memory_pool.back());
|
||||
_RYML_CHECK_BASIC((char*)mem+len >= &memory_pool.front() && (char*)mem+len <= &memory_pool.back());
|
||||
_c4dbgpf("free[{}]={}B", num_deallocs, len);
|
||||
dealloc_size += len;
|
||||
++num_deallocs;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "./test_lib/test_case.hpp"
|
||||
#ifndef RYML_SINGLE_HEADER
|
||||
#include "c4/yml/common.hpp"
|
||||
#include "c4/yml/error.def.hpp"
|
||||
#include "c4/format.hpp"
|
||||
#include "c4/span.hpp"
|
||||
#include "c4/yml/std/std.hpp"
|
||||
@@ -164,42 +165,73 @@ void test_arena_not_shared(Tree const& a, Tree const& b)
|
||||
|
||||
// ensure coverage of the default callback report
|
||||
#ifndef RYML_NO_DEFAULT_CALLBACKS
|
||||
extern void report_error_impl(const char* msg, size_t len, Location loc, FILE *file);
|
||||
extern void report_error_parse_impl(csubstr msg, Location loc, FILE *file);
|
||||
#endif
|
||||
|
||||
std::string format_error(const char* msg, size_t len, Location loc)
|
||||
std::string format_error_basic(csubstr msg, ErrorDataBasic const& errdata)
|
||||
{
|
||||
// ensure coverage of the default callback report
|
||||
#ifndef RYML_NO_DEFAULT_CALLBACKS
|
||||
report_error_impl(msg, len, loc, nullptr);
|
||||
#endif
|
||||
std::string out;
|
||||
if(!loc)
|
||||
{
|
||||
out.assign(msg, len);
|
||||
return out;
|
||||
}
|
||||
if(!loc.name.empty())
|
||||
c4::formatrs_append(&out, "{}:", loc.name);
|
||||
c4::formatrs_append(&out, "{}:{}:", loc.line, loc.col);
|
||||
if(loc.offset)
|
||||
c4::formatrs_append(&out, " (@{}B):", loc.offset);
|
||||
c4::formatrs_append(&out, "{}:", csubstr(msg, len));
|
||||
err_basic_format([&](csubstr s){
|
||||
out.append(s.str, s.len);
|
||||
}, msg, errdata);
|
||||
return out;
|
||||
}
|
||||
|
||||
struct ExpectedError C4_IF_EXCEPTIONS_( : public std::runtime_error, )
|
||||
std::string format_error_parse(csubstr msg, ErrorDataParse const& errdata)
|
||||
{
|
||||
C4_IF_EXCEPTIONS_( ,
|
||||
std::string smsg;
|
||||
const char *what() const { return smsg.c_str(); }
|
||||
ExpectedError() = default;
|
||||
)
|
||||
Location error_location;
|
||||
ExpectedError(const char* msg, size_t len, Location loc)
|
||||
: C4_IF_EXCEPTIONS_(std::runtime_error(format_error(msg, len, loc)),
|
||||
smsg(format_error(msg, len, loc)))
|
||||
, error_location(loc)
|
||||
std::string out;
|
||||
err_parse_format([&](csubstr s){
|
||||
out.append(s.str, s.len);
|
||||
}, msg, errdata);
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string format_error_visit(csubstr msg, ErrorDataVisit const& errdata)
|
||||
{
|
||||
std::string out;
|
||||
err_visit_format([&](csubstr s){
|
||||
out.append(s.str, s.len);
|
||||
}, msg, errdata);
|
||||
return out;
|
||||
}
|
||||
|
||||
struct ExpectedErrorBasic C4_IF_EXCEPTIONS_( : public std::exception, )
|
||||
{
|
||||
std::string smsg;
|
||||
C4_IF_EXCEPTIONS_(const char *what() const noexcept override { return smsg.c_str(); }, )
|
||||
ExpectedErrorBasic() = default;
|
||||
ExpectedErrorBasic(csubstr msg, ErrorDataBasic const& errdata_)
|
||||
:
|
||||
C4_IF_EXCEPTIONS_(std::exception() C4_COMMA,)
|
||||
smsg(format_error_basic(msg, errdata_))
|
||||
{
|
||||
}
|
||||
ExpectedErrorBasic(std::string s)
|
||||
:
|
||||
C4_IF_EXCEPTIONS_(std::exception() C4_COMMA,)
|
||||
smsg(std::move(s))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct ExpectedErrorParse : public ExpectedErrorBasic
|
||||
{
|
||||
ErrorDataParse errdata;
|
||||
ExpectedErrorParse() = default;
|
||||
ExpectedErrorParse(csubstr msg, ErrorDataParse const& errdata_)
|
||||
: ExpectedErrorBasic(format_error_parse(msg, errdata_))
|
||||
, errdata(errdata_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct ExpectedErrorVisit : public ExpectedErrorBasic
|
||||
{
|
||||
ErrorDataVisit errdata;
|
||||
ExpectedErrorVisit() = default;
|
||||
ExpectedErrorVisit(csubstr msg, ErrorDataVisit const& errdata_)
|
||||
: ExpectedErrorBasic(format_error_visit(msg, errdata_))
|
||||
, errdata(errdata_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -208,8 +240,10 @@ struct ExpectedError C4_IF_EXCEPTIONS_( : public std::runtime_error, )
|
||||
//-----------------------------------------------------------------------------
|
||||
C4_IF_EXCEPTIONS_(
|
||||
,
|
||||
std::jmp_buf s_jmp_env_expect_error = {};
|
||||
ExpectedError s_jmp_err = {};
|
||||
std::jmp_buf s_jmp_env_expect_error;
|
||||
ExpectedErrorBasic s_jmp_err_basic = {};
|
||||
ExpectedErrorParse s_jmp_err_parse = {};
|
||||
ExpectedErrorVisit s_jmp_err_visit = {};
|
||||
)
|
||||
|
||||
ExpectError::ExpectError(Tree *tree, Location loc)
|
||||
@@ -219,34 +253,56 @@ ExpectError::ExpectError(Tree *tree, Location loc)
|
||||
, m_tree_prev(tree ? tree->callbacks() : m_glob_prev)
|
||||
, expected_location(loc)
|
||||
{
|
||||
auto err = [](const char* msg, size_t len, Location errloc, void *this_) {
|
||||
_c4dbgpf("called error callback! (withlocation={})", bool(errloc));
|
||||
auto errb = [](csubstr msg, ErrorDataBasic const& errdata, void *this_) {
|
||||
_c4dbgp("called basic error callback!");
|
||||
((ExpectError*)this_)->m_got_an_error = true; // assign in here to ensure the exception was thrown here
|
||||
C4_IF_EXCEPTIONS(
|
||||
throw ExpectedError(msg, len, errloc);
|
||||
throw ExpectedErrorBasic(msg, errdata);
|
||||
,
|
||||
s_jmp_err = ExpectedError(msg, len, errloc);
|
||||
s_jmp_err_basic = ExpectedErrorBasic(msg, errdata);
|
||||
std::longjmp(s_jmp_env_expect_error, 1);
|
||||
);
|
||||
C4_UNREACHABLE_AFTER_ERR();
|
||||
};
|
||||
pfn_error perr = err;
|
||||
#ifdef RYML_NO_DEFAULT_CALLBACKS
|
||||
c4::yml::Callbacks tcb((void*)this, nullptr, nullptr, perr);
|
||||
c4::yml::Callbacks gcb((void*)this, nullptr, nullptr, perr);
|
||||
#else
|
||||
c4::yml::Callbacks tcb((void*)this, tree ? m_tree_prev.m_allocate : nullptr, tree ? m_tree_prev.m_free : nullptr, perr);
|
||||
c4::yml::Callbacks gcb((void*)this, m_glob_prev.m_allocate, m_glob_prev.m_free, perr);
|
||||
#endif
|
||||
auto errp = [](csubstr msg, ErrorDataParse const& errdata, void *this_) {
|
||||
_c4dbgpf("called parse error callback! (withlocation={})", bool(errdata.ymlloc));
|
||||
((ExpectError*)this_)->m_got_an_error = true; // assign in here to ensure the exception was thrown here
|
||||
C4_IF_EXCEPTIONS(
|
||||
throw ExpectedErrorParse(msg, errdata);
|
||||
,
|
||||
s_jmp_err_parse = ExpectedErrorParse(msg, errdata);
|
||||
std::longjmp(s_jmp_env_expect_error, 1);
|
||||
);
|
||||
C4_UNREACHABLE_AFTER_ERR();
|
||||
};
|
||||
auto errv = [](csubstr msg, ErrorDataVisit const& errdata, void *this_) {
|
||||
_c4dbgp("called visit error callback!");
|
||||
((ExpectError*)this_)->m_got_an_error = true; // assign in here to ensure the exception was thrown here
|
||||
C4_IF_EXCEPTIONS(
|
||||
throw ExpectedErrorVisit(msg, errdata);
|
||||
,
|
||||
s_jmp_err_visit = ExpectedErrorVisit(msg, errdata);
|
||||
std::longjmp(s_jmp_env_expect_error, 1);
|
||||
);
|
||||
C4_UNREACHABLE_AFTER_ERR();
|
||||
};
|
||||
c4::yml::Callbacks tcb;
|
||||
c4::yml::Callbacks gcb;
|
||||
tcb.set_user_data((void*)this).set_error_basic(errb).set_error_parse(errp).set_error_visit(errv);
|
||||
gcb.set_user_data((void*)this).set_error_basic(errb).set_error_parse(errp).set_error_visit(errv);
|
||||
if(tree)
|
||||
{
|
||||
_c4dbgpf("setting error callback: tree err={}", c4::fmt::hex(perr));
|
||||
_c4dbgpf("setting error callback: tree err={}", c4::fmt::hex((void const*)&errp));
|
||||
tree->callbacks(tcb);
|
||||
EXPECT_EQ(tree->callbacks().m_error, perr);
|
||||
EXPECT_EQ(tree->callbacks().m_error_basic, errb);
|
||||
EXPECT_EQ(tree->callbacks().m_error_parse, errp);
|
||||
EXPECT_EQ(tree->callbacks().m_error_visit, errv);
|
||||
}
|
||||
_c4dbgpf("setting error callback: global err={}", c4::fmt::hex(perr));
|
||||
_c4dbgpf("setting error callback: global err={}", c4::fmt::hex((void const*)&errp));
|
||||
set_callbacks(gcb);
|
||||
EXPECT_EQ(get_callbacks().m_error, perr);
|
||||
EXPECT_EQ(get_callbacks().m_error_basic, errb);
|
||||
EXPECT_EQ(get_callbacks().m_error_parse, errp);
|
||||
EXPECT_EQ(get_callbacks().m_error_visit, errv);
|
||||
}
|
||||
|
||||
ExpectError::~ExpectError()
|
||||
@@ -260,7 +316,7 @@ ExpectError::~ExpectError()
|
||||
set_callbacks(m_tree_prev);
|
||||
}
|
||||
|
||||
void ExpectError::check_success(Tree *tree, std::function<void()> fn)
|
||||
void ExpectError::check_success(Tree *tree, fntestref fn)
|
||||
{
|
||||
Location expected_location = {};
|
||||
auto context = ExpectError(tree, expected_location);
|
||||
@@ -270,44 +326,89 @@ void ExpectError::check_success(Tree *tree, std::function<void()> fn)
|
||||
fn();
|
||||
_c4dbgp("check expected success: success!");
|
||||
}
|
||||
C4_IF_EXCEPTIONS_(catch(ExpectedError const&), else)
|
||||
C4_IF_EXCEPTIONS_(catch(ExpectedErrorParse const&), else)
|
||||
{
|
||||
FAIL() << "check expected success: failed!";
|
||||
}
|
||||
ASSERT_FALSE(context.m_got_an_error);
|
||||
}
|
||||
|
||||
void ExpectError::check_error(Tree const* tree, std::function<void()> fn, Location expected_location)
|
||||
void ExpectError::check_error_basic(Tree const* tree, fntestref fn)
|
||||
{
|
||||
check_error(const_cast<Tree*>(tree), fn, expected_location);
|
||||
check_error_basic(const_cast<Tree*>(tree), fn);
|
||||
}
|
||||
|
||||
void ExpectError::check_error(Tree *tree, std::function<void()> fn, Location expected_location)
|
||||
void ExpectError::check_error_parse(Tree const* tree, fntestref fn, Location const& expected_location)
|
||||
{
|
||||
auto context = ExpectError(tree, expected_location);
|
||||
check_error_parse(const_cast<Tree*>(tree), fn, expected_location);
|
||||
}
|
||||
|
||||
void ExpectError::check_error_visit(Tree const* tree, fntestref fn, id_type expected_id)
|
||||
{
|
||||
check_error_visit(const_cast<Tree*>(tree), fn, expected_id);
|
||||
}
|
||||
|
||||
void ExpectError::check_error_basic(Tree *tree, fntestref fn)
|
||||
{
|
||||
auto context = ExpectError(tree);
|
||||
C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0))
|
||||
{
|
||||
_c4dbgp("check expected error");
|
||||
_c4dbgp("check expected basic error");
|
||||
fn();
|
||||
_c4dbgp("check expected error: failed!");
|
||||
_c4dbgp("check expected basic error: failed!");
|
||||
}
|
||||
C4_IF_EXCEPTIONS_(catch(ExpectedError const& e), else)
|
||||
C4_IF_EXCEPTIONS_(catch(ExpectedErrorBasic const& e), else)
|
||||
{
|
||||
C4_IF_EXCEPTIONS_( , ExpectedError const& e = s_jmp_err);
|
||||
C4_IF_EXCEPTIONS_( , ExpectedErrorBasic const& e = s_jmp_err_basic);
|
||||
(void)e;
|
||||
#if defined(RYML_DBG)
|
||||
std::cout << "---------------\n";
|
||||
std::cout << "got an expected error:\n" << e.what() << "\n";
|
||||
std::cout << "got an expected parse error:\n" << e.what() << "\n";
|
||||
std::cout << "---------------\n";
|
||||
#endif
|
||||
if(context.expected_location)
|
||||
}
|
||||
C4_IF_EXCEPTIONS_(catch(...)
|
||||
{
|
||||
_c4dbgp("---------------\n"
|
||||
"got an unexpected exception!\n"
|
||||
"---------------\n");
|
||||
}, )
|
||||
EXPECT_TRUE(context.m_got_an_error);
|
||||
}
|
||||
|
||||
void ExpectError::check_error_parse(Tree *tree, fntestref fn, Location const& expected_location)
|
||||
{
|
||||
ExpectError context(tree, expected_location);
|
||||
C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0))
|
||||
{
|
||||
_c4dbgp("check expected parse error");
|
||||
fn();
|
||||
_c4dbgp("check expected parse error: failed!");
|
||||
}
|
||||
C4_IF_EXCEPTIONS_(catch(ExpectedErrorParse const& e), else)
|
||||
{
|
||||
C4_IF_EXCEPTIONS_( , ExpectedErrorParse const& e = s_jmp_err_parse);
|
||||
(void)e;
|
||||
#if defined(RYML_DBG)
|
||||
std::cout << "---------------\n";
|
||||
std::cout << "got an expected parse error:\n" << e.what() << "\n";
|
||||
std::cout << "---------------\n";
|
||||
#endif
|
||||
if(expected_location)
|
||||
{
|
||||
_c4dbgp("checking expected location...");
|
||||
EXPECT_EQ(static_cast<bool>(e.error_location), static_cast<bool>(context.expected_location));
|
||||
EXPECT_EQ(e.error_location.line, context.expected_location.line);
|
||||
EXPECT_EQ(e.error_location.col, context.expected_location.col);
|
||||
if(context.expected_location.offset)
|
||||
EXPECT_EQ(static_cast<bool>(e.errdata.ymlloc), static_cast<bool>(context.expected_location));
|
||||
if(context.expected_location.line != npos)
|
||||
{
|
||||
EXPECT_EQ(e.error_location.offset, context.expected_location.offset);
|
||||
EXPECT_EQ(e.errdata.ymlloc.line, context.expected_location.line);
|
||||
}
|
||||
if(context.expected_location.col != npos)
|
||||
{
|
||||
EXPECT_EQ(e.errdata.ymlloc.col, context.expected_location.col);
|
||||
}
|
||||
if(context.expected_location.offset != npos)
|
||||
{
|
||||
EXPECT_EQ(e.errdata.ymlloc.offset, context.expected_location.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,10 +421,59 @@ void ExpectError::check_error(Tree *tree, std::function<void()> fn, Location exp
|
||||
EXPECT_TRUE(context.m_got_an_error);
|
||||
}
|
||||
|
||||
void ExpectError::check_assertion(Tree *tree, std::function<void()> fn, Location expected_location)
|
||||
void ExpectError::check_error_visit(Tree *tree, fntestref fn, id_type id)
|
||||
{
|
||||
auto context = ExpectError(tree);
|
||||
C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0))
|
||||
{
|
||||
_c4dbgp("check expected visit error");
|
||||
fn();
|
||||
_c4dbgp("check expected visit error: failed!");
|
||||
}
|
||||
C4_IF_EXCEPTIONS_(catch(ExpectedErrorVisit const& e), else)
|
||||
{
|
||||
C4_IF_EXCEPTIONS_( , ExpectedErrorVisit const& e = s_jmp_err_visit);
|
||||
(void)e;
|
||||
#if defined(RYML_DBG)
|
||||
std::cout << "---------------\n";
|
||||
std::cout << "got an expected visit error:\n" << e.what() << "\n";
|
||||
std::cout << "---------------\n";
|
||||
#endif
|
||||
EXPECT_EQ(e.errdata.tree, tree);
|
||||
if(id != npos)
|
||||
{
|
||||
EXPECT_EQ(e.errdata.node, id);
|
||||
}
|
||||
}
|
||||
C4_IF_EXCEPTIONS_(catch(std::exception const& exc)
|
||||
{
|
||||
std::cout << "---------------\n";
|
||||
std::cout << "got an unexpected exception!:\n" << exc.what() << "\n";
|
||||
std::cout << "---------------\n";
|
||||
}, )
|
||||
C4_IF_EXCEPTIONS_(catch(...)
|
||||
{
|
||||
std::cout << "---------------\n";
|
||||
std::cout << "got an unexpected exception!\n";
|
||||
std::cout << "---------------\n";
|
||||
}, )
|
||||
EXPECT_TRUE(context.m_got_an_error);
|
||||
}
|
||||
|
||||
void ExpectError::check_assert_basic(Tree *tree, fntestref fn)
|
||||
{
|
||||
#if RYML_USE_ASSERT
|
||||
ExpectError::check_error(tree, fn, expected_location);
|
||||
ExpectError::check_error_basic(tree, fn);
|
||||
#else
|
||||
C4_UNUSED(tree);
|
||||
C4_UNUSED(fn);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExpectError::check_assert_parse(Tree *tree, fntestref fn, Location const& expected_location)
|
||||
{
|
||||
#if RYML_USE_ASSERT
|
||||
ExpectError::check_error_parse(tree, fn, expected_location);
|
||||
#else
|
||||
C4_UNUSED(tree);
|
||||
C4_UNUSED(fn);
|
||||
@@ -331,6 +481,17 @@ void ExpectError::check_assertion(Tree *tree, std::function<void()> fn, Location
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExpectError::check_assert_visit(Tree *tree, fntestref fn, id_type id)
|
||||
{
|
||||
#if RYML_USE_ASSERT
|
||||
ExpectError::check_error_visit(tree, fn, id);
|
||||
#else
|
||||
C4_UNUSED(tree);
|
||||
C4_UNUSED(fn);
|
||||
C4_UNUSED(id);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -348,7 +509,7 @@ void print_path(ConstNodeRef const& n)
|
||||
else
|
||||
{
|
||||
int ret = snprintf(buf, sizeof(buf), "/%zu", p.has_parent() ? (size_t)p.parent().child_pos(p) : (size_t)0);
|
||||
RYML_ASSERT(ret >= 0);
|
||||
_RYML_ASSERT_BASIC(ret >= 0);
|
||||
len += static_cast<size_t>(ret);
|
||||
}
|
||||
p = p.parent();
|
||||
@@ -362,18 +523,18 @@ void print_path(ConstNodeRef const& n)
|
||||
{
|
||||
size_t tl = p.key().len;
|
||||
int ret = snprintf(buf + pos - tl, tl, "%.*s", (int)tl, p.key().str);
|
||||
RYML_ASSERT(ret >= 0);
|
||||
_RYML_ASSERT_BASIC(ret >= 0);
|
||||
pos -= static_cast<size_t>(ret);
|
||||
}
|
||||
else if(p.has_parent())
|
||||
{
|
||||
pos = (size_t)p.parent().child_pos(p);
|
||||
int ret = snprintf(buf, 0, "/%zu", pos);
|
||||
RYML_ASSERT(ret >= 0);
|
||||
_RYML_ASSERT_BASIC(ret >= 0);
|
||||
size_t tl = static_cast<size_t>(ret);
|
||||
RYML_ASSERT(pos >= tl);
|
||||
_RYML_ASSERT_BASIC(pos >= tl);
|
||||
ret = snprintf(buf + static_cast<size_t>(pos - tl), tl, "/%zu", pos);
|
||||
RYML_ASSERT(ret >= 0);
|
||||
_RYML_ASSERT_BASIC(ret >= 0);
|
||||
pos -= static_cast<size_t>(ret);
|
||||
}
|
||||
p = p.parent();
|
||||
@@ -711,7 +872,7 @@ CaseData* get_data(csubstr name)
|
||||
{
|
||||
cd = &m[name];
|
||||
Case const* c = get_case(name);
|
||||
RYML_CHECK(c->src.find("\n\r") == csubstr::npos);
|
||||
_RYML_CHECK_BASIC(c->src.find("\n\r") == csubstr::npos);
|
||||
{
|
||||
std::string tmp;
|
||||
replace_all("\r", "", c->src, &tmp);
|
||||
|
||||
@@ -103,7 +103,9 @@ inline void PrintTo(Callbacks const& cb, ::std::ostream* os)
|
||||
<< "userdata." << (void*)cb.m_user_data << ','
|
||||
<< "allocate." << RYML_GNUC_EXTENSION (void*)cb.m_allocate << ','
|
||||
<< "free." << RYML_GNUC_EXTENSION (void*)cb.m_free << ','
|
||||
<< "error." << RYML_GNUC_EXTENSION (void*)cb.m_error << '}';
|
||||
<< "error_basic." << RYML_GNUC_EXTENSION (void*)cb.m_error_basic << '}'
|
||||
<< "error_parse." << RYML_GNUC_EXTENSION (void*)cb.m_error_parse << '}'
|
||||
<< "error_visit." << RYML_GNUC_EXTENSION (void*)cb.m_error_visit << '}';
|
||||
#undef RYML_GNUC_EXTENSION
|
||||
}
|
||||
|
||||
@@ -225,14 +227,14 @@ void test_check_emit_check(csubstr yaml, CheckFn &&check_fn)
|
||||
|
||||
inline c4::substr replace_all(c4::csubstr pattern, c4::csubstr repl, c4::csubstr subject, std::string *dst)
|
||||
{
|
||||
RYML_CHECK(!subject.overlaps(to_csubstr(*dst)));
|
||||
_RYML_CHECK_BASIC(!subject.overlaps(to_csubstr(*dst)));
|
||||
size_t ret = subject.replace_all(to_substr(*dst), pattern, repl);
|
||||
if(ret != dst->size())
|
||||
{
|
||||
dst->resize(ret);
|
||||
ret = subject.replace_all(to_substr(*dst), pattern, repl);
|
||||
}
|
||||
RYML_CHECK(ret == dst->size());
|
||||
_RYML_CHECK_BASIC(ret == dst->size());
|
||||
return c4::to_substr(*dst);
|
||||
}
|
||||
|
||||
@@ -253,13 +255,28 @@ struct ExpectError
|
||||
ExpectError(Tree *tree, Location loc={});
|
||||
~ExpectError();
|
||||
|
||||
static void check_error( std::function<void()> fn, Location expected={}) { check_error((const Tree*)nullptr, fn, expected); }
|
||||
static void check_error(Tree *tree, std::function<void()> fn, Location expected={});
|
||||
static void check_error(Tree const *tree, std::function<void()> fn, Location expected={});
|
||||
static void check_assertion( std::function<void()> fn, Location expected={}) { check_assertion(nullptr, fn, expected); }
|
||||
static void check_assertion(Tree *tree, std::function<void()> fn, Location expected={});
|
||||
static void check_success( std::function<void()> fn) { check_success(nullptr, fn); };
|
||||
static void check_success(Tree *tree, std::function<void()> fn);
|
||||
using fntestref = std::function<void()> const&;
|
||||
|
||||
static void check_success( fntestref fn) { check_success(nullptr, fn); };
|
||||
static void check_success(Tree *tree, fntestref fn);
|
||||
|
||||
static void check_error_basic( fntestref fn) { check_error_basic((const Tree*)nullptr, fn); }
|
||||
static void check_error_basic(Tree *tree, fntestref fn);
|
||||
static void check_error_basic(Tree const *tree, fntestref fn);
|
||||
static void check_assert_basic( fntestref fn) { check_assert_parse(nullptr, fn); }
|
||||
static void check_assert_basic(Tree *tree, fntestref fn);
|
||||
|
||||
static void check_error_parse( fntestref fn, Location const& expected={}) { check_error_parse((const Tree*)nullptr, fn, expected); }
|
||||
static void check_error_parse(Tree *tree, fntestref fn, Location const& expected={});
|
||||
static void check_error_parse(Tree const *tree, fntestref fn, Location const& expected={});
|
||||
static void check_assert_parse( fntestref fn, Location const& expected={}) { check_assert_parse(nullptr, fn, expected); }
|
||||
static void check_assert_parse(Tree *tree, fntestref fn, Location const& expected={});
|
||||
|
||||
static void check_error_visit( fntestref fn, id_type id=npos) { check_error_visit((const Tree*)nullptr, fn, id); }
|
||||
static void check_error_visit(Tree *tree, fntestref fn, id_type id=npos);
|
||||
static void check_error_visit(Tree const *tree, fntestref fn, id_type id=npos);
|
||||
static void check_assert_visit( fntestref fn, id_type id=npos) { check_assert_visit(nullptr, fn, id); }
|
||||
static void check_assert_visit(Tree *tree, fntestref fn, id_type id=npos);
|
||||
};
|
||||
|
||||
|
||||
@@ -287,12 +304,12 @@ struct Case
|
||||
TestCaseFlags_e flags;
|
||||
Location expected_location;
|
||||
|
||||
//! create a standard test case: name, source and expected CaseNode structure
|
||||
template<class... Args> Case(csubstr file, int line, const char *name_, const char *src_, Args&& ...args) : filelinebuf(catrs<std::string>(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::forward<Args>(args)...), flags(), expected_location() {}
|
||||
//! create a test case with explicit flags: name, source flags, and expected CaseNode structure
|
||||
template<class... Args> Case(csubstr file, int line, const char *name_, int f_, const char *src_, Args&& ...args) : filelinebuf(catrs<std::string>(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::forward<Args>(args)...), flags((TestCaseFlags_e)f_), expected_location() {}
|
||||
//! create a test case with an error on an expected location
|
||||
Case(csubstr file, int line, const char *name_, int f_, const char *src_, LineCol loc) : filelinebuf(catrs<std::string>(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(), flags((TestCaseFlags_e)f_), expected_location(name, loc.line, loc.col) {}
|
||||
Case(csubstr file, int line, const char *name_, int f_, const char *src_, Location const& loc={}) : filelinebuf(catrs<std::string>(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(), flags((TestCaseFlags_e)f_), expected_location(name, loc.line, loc.col) {}
|
||||
//! create a standard test case: name, source and expected CaseNode structure
|
||||
Case(csubstr file, int line, const char *name_, const char *src_, TestCaseNode&& node) : /* */filelinebuf(catrs<std::string>(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::move(node)), flags(), expected_location() {}
|
||||
//! create a test case with explicit flags: name, source flags, and expected CaseNode structure
|
||||
Case(csubstr file, int line, const char *name_, int f_, const char *src_, TestCaseNode&& node) : /* */filelinebuf(catrs<std::string>(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::move(node)), flags((TestCaseFlags_e)f_), expected_location() {}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
TestCaseNode(TestCaseNode const& that) noexcept { _copy(that); }
|
||||
|
||||
TestCaseNode& operator= (TestCaseNode && that) noexcept { _move(std::move(that)); return *this; }
|
||||
TestCaseNode& operator= (TestCaseNode const& that) noexcept { _copy(that); return *this; }
|
||||
TestCaseNode& operator= (TestCaseNode const& that) noexcept { if(&that != this) _copy(that); return *this; }
|
||||
|
||||
~TestCaseNode() = default;
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
template<size_t N> explicit TestCaseNode(const char (&v)[N] , AnchorRef const& arv) : type((arv.type|VAL )), key(), key_tag(), key_anchor(), val(v ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); }
|
||||
explicit TestCaseNode(TaggedScalar const& v, AnchorRef const& arv) : type((arv.type|VAL|VALTAG)), key(), key_tag(), key_anchor(), val(v.scalar), val_tag(v.tag), val_anchor(arv), children(), parent(nullptr) { _set_parent(); }
|
||||
explicit TestCaseNode(std::nullptr_t , AnchorRef const& arv) : type((arv.type|VAL )), key(), key_tag(), key_anchor(), val( ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); }
|
||||
explicit TestCaseNode( AnchorRef const& arv) : type((arv.type|VAL )), key(), key_tag(), key_anchor(), val(arv.str ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); RYML_ASSERT(arv.type == VALREF); }
|
||||
explicit TestCaseNode( AnchorRef const& arv) : type((arv.type|VAL )), key(), key_tag(), key_anchor(), val(arv.str ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); _RYML_ASSERT_BASIC(arv.type == VALREF); }
|
||||
|
||||
|
||||
// val, explicit type
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
explicit TestCaseNode(std::nullptr_t , TaggedScalar const& v) : type((KEYVAL |VALTAG )), key( ), key_tag( ), key_anchor( ), val(v.scalar), val_tag(v.tag), val_anchor( ), children(), parent(nullptr) { _set_parent(); }
|
||||
explicit TestCaseNode(TaggedScalar const& k, std::nullptr_t ) : type((KEYVAL|KEYTAG )), key(k.scalar), key_tag(k.tag), key_anchor( ), val( ), val_tag( ), val_anchor( ), children(), parent(nullptr) { _set_parent(); }
|
||||
explicit TestCaseNode(std::nullptr_t , std::nullptr_t ) : type((KEYVAL )), key( ), key_tag( ), key_anchor( ), val( ), val_tag( ), val_anchor( ), children(), parent(nullptr) { _set_parent(); }
|
||||
explicit TestCaseNode(AnchorRef const& ark, AnchorRef const& arv) : type((KEYVAL|ark.type|arv.type)), key(ark.str ), key_tag( ), key_anchor(ark), val(arv.str ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); RYML_ASSERT(ark.type == KEYREF); RYML_ASSERT(arv.type == VALREF); }
|
||||
explicit TestCaseNode(AnchorRef const& ark, AnchorRef const& arv) : type((KEYVAL|ark.type|arv.type)), key(ark.str ), key_tag( ), key_anchor(ark), val(arv.str ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); _RYML_ASSERT_BASIC(ark.type == KEYREF); _RYML_ASSERT_BASIC(arv.type == VALREF); }
|
||||
// keyval, with val anchor/ref
|
||||
template<size_t N, size_t M> explicit TestCaseNode(const char (&k)[N] , const char (&v)[M] , AnchorRef const& arv) : type((arv.type|KEYVAL )), key(k ), key_tag( ), key_anchor(), val(v ), val_tag( ), val_anchor(arv), children(), parent(nullptr) { _set_parent(); }
|
||||
template<size_t N> explicit TestCaseNode(const char (&k)[N] , TaggedScalar const& v, AnchorRef const& arv) : type((arv.type|KEYVAL|VALTAG )), key(k ), key_tag( ), key_anchor(), val(v.scalar), val_tag(v.tag), val_anchor(arv), children(), parent(nullptr) { _set_parent(); }
|
||||
|
||||
@@ -43,7 +43,7 @@ std::vector<std::string> inject_comments(std::string const& src_)
|
||||
|
||||
void test_expected_error_testsuite_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location)
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
extra::EventHandlerTestSuite::EventSink sink;
|
||||
extra::EventHandlerTestSuite handler(&sink);
|
||||
handler.reset();
|
||||
@@ -55,7 +55,7 @@ void test_expected_error_testsuite_from_yaml(std::string const& parsed_yaml, Loc
|
||||
|
||||
void test_expected_error_ints_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location)
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
extra::EventHandlerInts handler{};
|
||||
handler.reset(to_csubstr(parsed_yaml), substr{}, nullptr, 0);
|
||||
ParseEngine<extra::EventHandlerInts> parser(&handler);
|
||||
@@ -67,7 +67,7 @@ void test_expected_error_ints_from_yaml(std::string const& parsed_yaml, Location
|
||||
void test_expected_error_tree_from_yaml(std::string const& parsed_yaml, Location const& expected_error_location)
|
||||
{
|
||||
Tree tree = {};
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
EventHandlerTree handler(&tree, tree.root_id());
|
||||
ASSERT_EQ(&tree, handler.m_tree);
|
||||
ParseEngine<EventHandlerTree> parser(&handler);
|
||||
@@ -257,7 +257,7 @@ csubstr parse_anchor_and_tag(csubstr tokens, OptionalScalar *anchor, OptionalSca
|
||||
if(tokens.begins_with('<'))
|
||||
{
|
||||
size_t pos = tokens.find('>');
|
||||
RYML_ASSERT(pos != (size_t)csubstr::npos);
|
||||
_RYML_ASSERT_BASIC(pos != (size_t)csubstr::npos);
|
||||
*tag = tokens.first(pos + 1);
|
||||
tokens = tokens.right_of(pos).triml(' ');
|
||||
_c4dbgpf("tag: {}", tag->maybe_get());
|
||||
|
||||
@@ -32,7 +32,7 @@ struct OptionalScalar
|
||||
operator csubstr() const { return get(); }
|
||||
operator bool() const { return was_set; }
|
||||
void operator= (csubstr v) { val = v; was_set = true; }
|
||||
csubstr get() const { RYML_ASSERT(was_set); return val; }
|
||||
csubstr get() const { _RYML_ASSERT_BASIC(was_set); return val; }
|
||||
csubstr maybe_get() const { return was_set ? val : csubstr(""); }
|
||||
};
|
||||
|
||||
@@ -54,17 +54,17 @@ struct EngineEvtTestCase
|
||||
EngineEvtTestCase( std::string p, std::string e, std::string ev) : test_case_flags( ), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, std::string p, std::string e, std::string ev) : test_case_flags(tf), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, std::string p , std::string ev) : test_case_flags(tf), expected_error_location( ), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) {}
|
||||
EngineEvtTestCase( Location linecol_, std::string p , std::string ev) : test_case_flags( ), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p, std::string e, std::string ev) : test_case_flags(tf), expected_error_location(linecol_), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p , std::string ev) : test_case_flags(tf), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { RYML_ASSERT(linecol_); }
|
||||
EngineEvtTestCase( Location linecol_, std::string p , std::string ev) : test_case_flags( ), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { _RYML_ASSERT_BASIC(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p, std::string e, std::string ev) : test_case_flags(tf), expected_error_location(linecol_), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { _RYML_ASSERT_BASIC(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p , std::string ev) : test_case_flags(tf), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(), expected_ints_enabled(false) { _RYML_ASSERT_BASIC(linecol_); }
|
||||
|
||||
EngineEvtTestCase( std::string s , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location( ), parsed(s ), emitted(std::move(s)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
|
||||
EngineEvtTestCase( std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location( ), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location( ), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) {}
|
||||
EngineEvtTestCase( Location linecol_, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed( p), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { RYML_ASSERT(linecol_); }
|
||||
EngineEvtTestCase( Location linecol_, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags( ), expected_error_location(linecol_), parsed(p ), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { _RYML_ASSERT_BASIC(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p, std::string e, std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed(std::move(p)), emitted(std::move(e)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { _RYML_ASSERT_BASIC(linecol_); }
|
||||
EngineEvtTestCase(TestCaseFlags_e tf, Location linecol_, std::string p , std::string ev, std::vector<extra::IntEventWithScalar> ints) : test_case_flags(tf), expected_error_location(linecol_), parsed( p), emitted(std::move(p)), expected_events(std::move(ev)), expected_ints(std::move(ints)), expected_ints_enabled(true) { _RYML_ASSERT_BASIC(linecol_); }
|
||||
TestCaseFlags_e test_case_flags;
|
||||
Location expected_error_location;
|
||||
std::string parsed;
|
||||
@@ -165,7 +165,7 @@ struct TransformToSourceBufferOrArena
|
||||
size_t pos = src.find(s);
|
||||
if(pos != csubstr::npos)
|
||||
{
|
||||
RYML_ASSERT(pos + s.len <= src.len);
|
||||
_RYML_ASSERT_BASIC(pos + s.len <= src.len);
|
||||
return src.sub(pos, s.len);
|
||||
}
|
||||
substr dst = handler->alloc_arena(s.len);
|
||||
@@ -237,7 +237,7 @@ C4_NO_INLINE void test_engine_tree_from_events(EngineEvtTestCase const& tc)
|
||||
{
|
||||
if(tc.test_case_flags & HAS_CONTAINER_KEYS)
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
Tree tree = {};
|
||||
EventHandlerTree handler(&tree, tree.root_id());
|
||||
EventProducerFn<EventHandlerTree> event_producer;
|
||||
|
||||
@@ -25,7 +25,7 @@ void YmlTestCase::_test_parse_using_ryml(CaseDataLineEndings *cd)
|
||||
|
||||
if(c->flags & (EXPECT_PARSE_ERROR|HAS_CONTAINER_KEYS))
|
||||
{
|
||||
ExpectError::check_error(&cd->parsed_tree, [this, cd]{
|
||||
ExpectError::check_error_parse(&cd->parsed_tree, [this, cd](){
|
||||
parse_in_place(c->fileline, cd->src, &cd->parsed_tree);
|
||||
// if this point was reached, then it means that the expected
|
||||
// error failed to occur. So print debugging info.
|
||||
@@ -60,7 +60,7 @@ void YmlTestCase::_test_parse_using_ryml(CaseDataLineEndings *cd)
|
||||
{
|
||||
if(c->flags & EXPECT_RESOLVE_ERROR)
|
||||
{
|
||||
ExpectError::check_error(&cd->parsed_tree, [&]{
|
||||
ExpectError::check_error_parse(&cd->parsed_tree, [&]{
|
||||
cd->parsed_tree.resolve();
|
||||
// if this point was reached, then it means that the expected
|
||||
// error failed to occur. So print debugging info.
|
||||
@@ -144,7 +144,7 @@ void YmlTestCase::_test_parse_using_ints(CaseDataLineEndings *cd)
|
||||
if(c->flags & EXPECT_PARSE_ERROR)
|
||||
{
|
||||
SCOPED_TRACE("expect error");
|
||||
ExpectError::check_error(&cd->parsed_tree, [&]{
|
||||
ExpectError::check_error_parse(&cd->parsed_tree, [&]{
|
||||
_parse_events_ints(c->fileline, s, &cd->parsed_ints, &cd->arena_ints);
|
||||
printints(); // error failed to occur. So print debugging info.
|
||||
}, c->expected_location);
|
||||
|
||||
@@ -195,8 +195,8 @@ struct CaseAdderGcc4_8
|
||||
const int line;
|
||||
|
||||
template<typename... Args>
|
||||
void operator ()(Args... parameters) const {
|
||||
group_cases->emplace_back(csubstr(file), line, parameters...);
|
||||
void operator ()(Args &&... parameters) const {
|
||||
group_cases->emplace_back(csubstr(file), line, std::forward<Args>(parameters)...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ TEST(locations, default_is_no_location)
|
||||
TEST(locations, error_is_triggered_querying_with_locations_disabled)
|
||||
{
|
||||
bool parsed_ok = false;
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_basic([&]{
|
||||
Parser::handler_type evt_handler = {};
|
||||
Parser parser(&evt_handler, ParserOptions().locations(false));
|
||||
Tree t = parse_in_arena(&parser, "test", "foo: bar");
|
||||
|
||||
@@ -275,7 +275,7 @@ TEST(simple_map, test_suite_UT92_0)
|
||||
TEST(simple_map, test_suite_UT92_1)
|
||||
{
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
csubstr yaml = R"(
|
||||
- { matches
|
||||
% : 20 }
|
||||
@@ -294,7 +294,7 @@ TEST(simple_map, test_suite_UT92_1)
|
||||
TEST(simple_map, two_nested_flow_maps_not_accepted_because_of_container_key)
|
||||
{
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
parse_in_arena("{{}}", &tree);
|
||||
});
|
||||
}
|
||||
@@ -309,7 +309,7 @@ TEST(simple_map, many_unmatched_brackets)
|
||||
for(size_t i = src.size(); i < num_brackets; ++i)
|
||||
src += '{';
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
parse_in_place(to_substr(src), &tree);
|
||||
});
|
||||
}
|
||||
@@ -405,7 +405,7 @@ x6:
|
||||
});
|
||||
}
|
||||
|
||||
void verify_error_is_reported(csubstr case_name, csubstr yaml, LineCol lc={})
|
||||
void verify_error_is_reported(csubstr case_name, csubstr yaml, Location lc={})
|
||||
{
|
||||
SCOPED_TRACE(case_name);
|
||||
SCOPED_TRACE(yaml);
|
||||
@@ -413,14 +413,14 @@ void verify_error_is_reported(csubstr case_name, csubstr yaml, LineCol lc={})
|
||||
Location loc = {};
|
||||
loc.line = lc.line;
|
||||
loc.col = lc.col;
|
||||
ExpectError::check_error(&tree, [&](){
|
||||
ExpectError::check_error_parse(&tree, [&](){
|
||||
parse_in_arena(yaml, &tree);
|
||||
}, loc);
|
||||
}
|
||||
|
||||
TEST(simple_map, no_map_key_flow)
|
||||
{
|
||||
verify_error_is_reported("map key", R"({ first: Sammy, last: Sosa }: foo)", LineCol{1,29});
|
||||
verify_error_is_reported("map key", R"({ first: Sammy, last: Sosa }: foo)", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, no_map_key_block)
|
||||
@@ -430,12 +430,12 @@ TEST(simple_map, no_map_key_block)
|
||||
last: Sosa
|
||||
:
|
||||
foo
|
||||
)", LineCol{2,9});
|
||||
)", Location{2,9});
|
||||
}
|
||||
|
||||
TEST(simple_map, no_seq_key_flow)
|
||||
{
|
||||
verify_error_is_reported("seq key", R"([Sammy, Sosa]: foo)", LineCol{1, 14});
|
||||
verify_error_is_reported("seq key", R"([Sammy, Sosa]: foo)", Location{1, 14});
|
||||
}
|
||||
|
||||
TEST(simple_map, no_seq_key_block)
|
||||
@@ -445,7 +445,7 @@ TEST(simple_map, no_seq_key_block)
|
||||
- Sosa
|
||||
:
|
||||
foo
|
||||
)", LineCol{2, 3});
|
||||
)", Location{2, 3});
|
||||
}
|
||||
|
||||
#ifdef RYML_WITH_TAB_TOKENS
|
||||
@@ -581,112 +581,112 @@ TEST(simple_map, flow_tab_tokens__5_everywhere)
|
||||
|
||||
TEST(simple_map, tokens_after_flow_0_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }foo", LineCol{1,32});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }foo", Location{1,32});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_0_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\nfoo", LineCol{2,4});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\nfoo", Location{2,4});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_2_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }- foo", LineCol{1,29});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }- foo", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_2_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n- foo", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n- foo", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_3_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }[foo,bar]", LineCol{1,29});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }[foo,bar]", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_3_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n[foo,bar]", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n[foo,bar]", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_4_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }{foo: bar}", LineCol{1,29});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }{foo: bar}", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_4_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n{foo: bar}", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n{foo: bar}", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_5_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }'foo'", LineCol{1,29});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }'foo'", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_5_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n'foo'", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n'foo'", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_6_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }|\nfoo", LineCol{1,29});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }|\nfoo", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_6_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n|\nfoo", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n|\nfoo", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_7_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }>\nfoo", LineCol{1,29});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }>\nfoo", Location{1,29});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_7_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n>\nfoo", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n>\nfoo", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_8_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }?foo", LineCol{1,33});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }?foo", Location{1,33});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_8_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n?\nfoo", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n?\nfoo", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_9_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }:foo", LineCol{1,33});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }:foo", Location{1,33});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_9_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n:\nfoo", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n:\nfoo", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_10_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }: foo", LineCol{1,29});// fixme
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }: foo", Location{1,29});// fixme
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_10_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n: \nfoo", LineCol{2,1});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n: \nfoo", Location{2,1});
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_11_0)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa } &foo", LineCol{1,34});// fixme
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa } &foo", Location{1,34});// fixme
|
||||
}
|
||||
|
||||
TEST(simple_map, tokens_after_flow_11_1)
|
||||
{
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n&foo", LineCol{2,5});
|
||||
verify_error_is_reported("", "{ first: Sammy, last: Sosa }\n&foo", Location{2,5});
|
||||
}
|
||||
|
||||
|
||||
@@ -1329,7 +1329,7 @@ R"(foo
|
||||
baz
|
||||
: bat
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple map, values on next line 4MUZ, v4", EXPECT_PARSE_ERROR,
|
||||
@@ -1342,7 +1342,7 @@ baz
|
||||
:
|
||||
bat
|
||||
)",
|
||||
LineCol(4, 1)
|
||||
Location(4, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("json compact",
|
||||
|
||||
@@ -225,7 +225,7 @@ TEST(NodeRef, valid_vs_seed_vs_readable)
|
||||
#define _TEST_FAIL(tree, method_expr) \
|
||||
{ \
|
||||
SCOPED_TRACE(#method_expr); \
|
||||
ExpectError::check_assertion(tree, [&]{ \
|
||||
ExpectError::check_assert_basic(tree, [&]{ \
|
||||
auto ret = (method_expr); \
|
||||
C4_DONT_OPTIMIZE(ret); \
|
||||
}); \
|
||||
|
||||
@@ -27,7 +27,8 @@ void mklarge(Parser *p, Callbacks const& cb)
|
||||
ASSERT_TRUE(p->m_evt_handler);
|
||||
Parser::handler_type *evt_handler = p->m_evt_handler;
|
||||
p->~Parser();
|
||||
evt_handler->m_stack.m_callbacks = cb;
|
||||
if(&cb != &evt_handler->m_stack.m_callbacks)
|
||||
evt_handler->m_stack.m_callbacks = cb;
|
||||
new ((void*)p) Parser(evt_handler, p->options());
|
||||
p->reserve_stack(20); // cause an allocation
|
||||
p->reserve_locations(128); // cause an allocation
|
||||
@@ -407,7 +408,7 @@ TEST(Parser, alloc_arena)
|
||||
EXPECT_FALSE(prev.overlaps(next_arena));
|
||||
};
|
||||
evt_handler.reset(&tree, tree.root_id());
|
||||
evt_handler.start_parse("filename", relocate, &data);
|
||||
evt_handler.start_parse("filename", "", relocate, &data);
|
||||
substr bufa = evt_handler.alloc_arena(64);
|
||||
bufa.fill('a');
|
||||
csubstr prev = bufa;
|
||||
@@ -586,14 +587,14 @@ TEST(parse_in_arena, overloads)
|
||||
|
||||
TEST(Parser, error_without_handler)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_basic([]{
|
||||
Parser parser{nullptr};
|
||||
});
|
||||
}
|
||||
|
||||
TEST(parse_in_place, error_without_handler)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_basic([]{
|
||||
EventHandlerTree evth;
|
||||
Parser parser{&evth};
|
||||
parser.m_evt_handler = nullptr;
|
||||
@@ -604,7 +605,7 @@ TEST(parse_in_place, error_without_handler)
|
||||
|
||||
TEST(parse_in_arena, error_without_handler)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_basic([]{
|
||||
EventHandlerTree evth;
|
||||
Parser parser{&evth};
|
||||
parser.m_evt_handler = nullptr;
|
||||
@@ -1272,7 +1273,7 @@ TEST_F(ParseToSeqFlowTest, whitespace__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, val_plain__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1292,7 +1293,7 @@ TEST_F(ParseToSeqFlowTest, val_plain__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, val_squo__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1312,7 +1313,7 @@ TEST_F(ParseToSeqFlowTest, val_squo__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, val_dquo__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1332,7 +1333,7 @@ TEST_F(ParseToSeqFlowTest, val_dquo__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, val_literal__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1352,7 +1353,7 @@ TEST_F(ParseToSeqFlowTest, val_literal_anchor__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, val_folded__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1372,7 +1373,7 @@ TEST_F(ParseToSeqFlowTest, val_folded__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, val_ref__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_ref), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1434,7 +1435,7 @@ TEST_F(ParseToSeqFlowTest, seq_blck__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, map_flow__to__seq_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_flow), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1454,7 +1455,7 @@ TEST_F(ParseToSeqFlowTest, map_flow__to__seq_flow__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, map_blck_plain__to__seq_blck__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_blck_plain), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1474,7 +1475,7 @@ TEST_F(ParseToSeqFlowTest, map_blck_plain__to__seq_blck__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, map_blck_squo__to__seq_blck__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_blck_squo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1494,7 +1495,7 @@ TEST_F(ParseToSeqFlowTest, map_blck_squo__to__seq_blck__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, map_blck_dquo__to__seq_blck__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_blck_dquo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1514,7 +1515,7 @@ TEST_F(ParseToSeqFlowTest, map_blck_dquo__to__seq_blck__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, map_blck_literal__to__seq_blck__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_blck_literal), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1534,7 +1535,7 @@ TEST_F(ParseToSeqFlowTest, map_blck_literal__to__seq_blck__new_child)
|
||||
TEST_F(ParseToSeqFlowTest, map_blck_folded__to__seq_blck__root)
|
||||
{
|
||||
NodeRef dst = dst_seq_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_blck_folded), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_seq_flow);
|
||||
@@ -1590,7 +1591,7 @@ TEST_F(ParseToMapFlowTest, whitespace__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_plain__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1610,7 +1611,7 @@ TEST_F(ParseToMapFlowTest, val_plain__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_plain_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1630,7 +1631,7 @@ TEST_F(ParseToMapFlowTest, val_plain_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_plain_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1650,7 +1651,7 @@ TEST_F(ParseToMapFlowTest, val_plain_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_squo__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1670,7 +1671,7 @@ TEST_F(ParseToMapFlowTest, val_squo__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_squo_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1690,7 +1691,7 @@ TEST_F(ParseToMapFlowTest, val_squo_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_squo_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1710,7 +1711,7 @@ TEST_F(ParseToMapFlowTest, val_squo_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_dquo__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1730,7 +1731,7 @@ TEST_F(ParseToMapFlowTest, val_dquo__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_dquo_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1750,7 +1751,7 @@ TEST_F(ParseToMapFlowTest, val_dquo_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_dquo_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1770,7 +1771,7 @@ TEST_F(ParseToMapFlowTest, val_dquo_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_literal__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1790,7 +1791,7 @@ TEST_F(ParseToMapFlowTest, val_literal__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_literal_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1810,7 +1811,7 @@ TEST_F(ParseToMapFlowTest, val_literal_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_literal_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1830,7 +1831,7 @@ TEST_F(ParseToMapFlowTest, val_literal_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_folded__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1850,7 +1851,7 @@ TEST_F(ParseToMapFlowTest, val_folded__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_folded_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1870,7 +1871,7 @@ TEST_F(ParseToMapFlowTest, val_folded_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_folded_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1890,7 +1891,7 @@ TEST_F(ParseToMapFlowTest, val_folded_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, val_ref__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_ref), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_flow);
|
||||
@@ -1910,7 +1911,7 @@ TEST_F(ParseToMapFlowTest, val_ref_to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, seq_flow__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_flow), dst);
|
||||
});
|
||||
}
|
||||
@@ -1929,7 +1930,7 @@ TEST_F(ParseToMapFlowTest, seq_flow__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, seq_flow_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_flow_anchor), dst);
|
||||
});
|
||||
}
|
||||
@@ -1948,7 +1949,7 @@ TEST_F(ParseToMapFlowTest, seq_flow_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, seq_flow_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_flow_tag), dst);
|
||||
});
|
||||
}
|
||||
@@ -1967,7 +1968,7 @@ TEST_F(ParseToMapFlowTest, seq_flow_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, seq_blck__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_blck), dst);
|
||||
});
|
||||
}
|
||||
@@ -2006,7 +2007,7 @@ TEST_F(ParseToMapFlowTest, map_flow__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapFlowTest, map_flow__to__map_flow__new_child_no_key)
|
||||
{
|
||||
NodeRef dst = dst_map_flow.rootref().append_child();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_flow), dst);
|
||||
});
|
||||
}
|
||||
@@ -2252,7 +2253,7 @@ class ParseToMapBlockTest : public ParseToNodeTest {};
|
||||
TEST_F(ParseToMapBlockTest, val_plain__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2272,7 +2273,7 @@ TEST_F(ParseToMapBlockTest, val_plain__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_plain_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2292,7 +2293,7 @@ TEST_F(ParseToMapBlockTest, val_plain_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_plain_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_plain_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2312,7 +2313,7 @@ TEST_F(ParseToMapBlockTest, val_plain_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_squo__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2332,7 +2333,7 @@ TEST_F(ParseToMapBlockTest, val_squo__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_squo_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2352,7 +2353,7 @@ TEST_F(ParseToMapBlockTest, val_squo_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_squo_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_squo_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2372,7 +2373,7 @@ TEST_F(ParseToMapBlockTest, val_squo_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_dquo__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2392,7 +2393,7 @@ TEST_F(ParseToMapBlockTest, val_dquo__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_dquo_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2412,7 +2413,7 @@ TEST_F(ParseToMapBlockTest, val_dquo_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_dquo_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_dquo_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2432,7 +2433,7 @@ TEST_F(ParseToMapBlockTest, val_dquo_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_literal__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2452,7 +2453,7 @@ TEST_F(ParseToMapBlockTest, val_literal__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_literal_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2472,7 +2473,7 @@ TEST_F(ParseToMapBlockTest, val_literal_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_literal_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_literal_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2492,7 +2493,7 @@ TEST_F(ParseToMapBlockTest, val_literal_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_folded__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2512,7 +2513,7 @@ TEST_F(ParseToMapBlockTest, val_folded__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_folded_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded_anchor), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2532,7 +2533,7 @@ TEST_F(ParseToMapBlockTest, val_folded_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_folded_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_folded_tag), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2552,7 +2553,7 @@ TEST_F(ParseToMapBlockTest, val_folded_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, val_ref__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(val_ref), dst);
|
||||
});
|
||||
_c4dbg_tree("actual", dst_map_blck);
|
||||
@@ -2572,7 +2573,7 @@ TEST_F(ParseToMapBlockTest, val_ref_to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, seq_flow__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_flow), dst);
|
||||
});
|
||||
}
|
||||
@@ -2591,7 +2592,7 @@ TEST_F(ParseToMapBlockTest, seq_flow__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, seq_flow_anchor__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_flow_anchor), dst);
|
||||
});
|
||||
}
|
||||
@@ -2610,7 +2611,7 @@ TEST_F(ParseToMapBlockTest, seq_flow_anchor__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, seq_flow_tag__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_flow_tag), dst);
|
||||
});
|
||||
}
|
||||
@@ -2629,7 +2630,7 @@ TEST_F(ParseToMapBlockTest, seq_flow_tag__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, seq_blck__to__map_flow__root)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(seq_blck), dst);
|
||||
});
|
||||
}
|
||||
@@ -2668,7 +2669,7 @@ TEST_F(ParseToMapBlockTest, map_flow__to__map_flow__new_child)
|
||||
TEST_F(ParseToMapBlockTest, map_flow__to__map_flow__new_child_no_key)
|
||||
{
|
||||
NodeRef dst = dst_map_blck.rootref().append_child();
|
||||
ExpectError::check_error(dst.tree(), [&]{
|
||||
ExpectError::check_error_basic(dst.tree(), [&]{
|
||||
parse_in_arena(to_csubstr(map_flow), dst);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "./test_lib/test_case.hpp"
|
||||
#include "./test_lib/test_group.hpp"
|
||||
#include "./test_lib/test_group.def.hpp"
|
||||
#ifndef RYML_SINGLE_HEADER
|
||||
#include <c4/yml/parse_engine.def.hpp>
|
||||
#endif
|
||||
|
||||
C4_SUPPRESS_WARNING_GCC_CLANG_PUSH
|
||||
C4_SUPPRESS_WARNING_GCC("-Wuseless-cast")
|
||||
@@ -732,7 +735,7 @@ void verify_error_is_reported(csubstr case_name, csubstr yaml, Location loc={})
|
||||
SCOPED_TRACE(case_name);
|
||||
SCOPED_TRACE(yaml);
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&](){
|
||||
ExpectError::check_error_parse(&tree, [&](){
|
||||
parse_in_arena(yaml, &tree);
|
||||
}, loc);
|
||||
}
|
||||
|
||||
@@ -1735,7 +1735,7 @@ TEST(block_folded, test_suite_W4TN)
|
||||
TEST(block_folded, error_on_folded_in_seqflow)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("[\n >\n a\n,]");
|
||||
});
|
||||
}
|
||||
@@ -1744,7 +1744,7 @@ TEST(block_folded, error_on_folded_in_seqflow)
|
||||
TEST(block_folded, error_on_folded_in_mapflow)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("{\n b: >\n a\n,}");
|
||||
});
|
||||
}
|
||||
@@ -1753,13 +1753,13 @@ TEST(block_literal, indentation_indicator_0)
|
||||
{
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena(">0");
|
||||
});
|
||||
}
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena(">10");
|
||||
});
|
||||
}
|
||||
@@ -1801,13 +1801,13 @@ TEST(block_literal, indentation_indicator_1)
|
||||
{
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("--- >0");
|
||||
});
|
||||
}
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("--- >10");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ TEST(block_literal, errors_on_tab_indents)
|
||||
TEST(block_literal, error_on_bad_spec_0)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("- |012abc\n must have errors above\n");
|
||||
});
|
||||
}
|
||||
@@ -1040,7 +1040,7 @@ TEST(block_literal, error_on_bad_spec_0)
|
||||
TEST(block_literal, error_on_bad_spec_1)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("- |0\n a\n");
|
||||
});
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ TEST(block_literal, error_on_bad_spec_1)
|
||||
TEST(block_literal, error_on_literal_in_seqflow)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("[\n |\n a\n,]");
|
||||
});
|
||||
}
|
||||
@@ -1056,7 +1056,7 @@ TEST(block_literal, error_on_literal_in_seqflow)
|
||||
TEST(block_literal, error_on_literal_in_mapflow)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("{\n b: |\n a\n,}");
|
||||
});
|
||||
}
|
||||
@@ -1065,13 +1065,13 @@ TEST(block_literal, indentation_indicator_0)
|
||||
{
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("|0");
|
||||
});
|
||||
}
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("|10");
|
||||
});
|
||||
}
|
||||
@@ -1113,13 +1113,13 @@ TEST(block_literal, indentation_indicator_1)
|
||||
{
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("--- |0");
|
||||
});
|
||||
}
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&t]{
|
||||
ExpectError::check_error_parse(&t, [&t]{
|
||||
t = parse_in_arena("--- |10");
|
||||
});
|
||||
}
|
||||
@@ -1492,13 +1492,13 @@ N(STREAM, L{
|
||||
|
||||
ADD_CASE_TO_GROUP("indentation requirements err, 0", EXPECT_PARSE_ERROR,
|
||||
R"(|0)",
|
||||
LineCol(1, 1)
|
||||
Location(1, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("indentation requirements err, 0.1", EXPECT_PARSE_ERROR,
|
||||
R"(|0
|
||||
)",
|
||||
LineCol(1, 1)
|
||||
Location(1, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("indentation requirements err seq", EXPECT_PARSE_ERROR,
|
||||
@@ -1509,7 +1509,7 @@ there
|
||||
ciao
|
||||
qua
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("indentation requirements err map", EXPECT_PARSE_ERROR,
|
||||
@@ -1520,7 +1520,7 @@ bar: |
|
||||
ciao
|
||||
qua
|
||||
)",
|
||||
LineCol(2, 6)
|
||||
Location(2, 6)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("indentation requirements err level", EXPECT_PARSE_ERROR,
|
||||
|
||||
@@ -10,8 +10,8 @@ C4_SUPPRESS_WARNING_GCC_WITH_PUSH("-Wuseless-cast")
|
||||
csubstr getafter(csubstr yaml, csubstr pattern)
|
||||
{
|
||||
size_t pos = yaml.find(pattern);
|
||||
RYML_ASSERT(pos != npos);
|
||||
RYML_ASSERT(yaml.sub(pos).begins_with(pattern));
|
||||
_RYML_ASSERT_BASIC(pos != npos);
|
||||
_RYML_ASSERT_BASIC(yaml.sub(pos).begins_with(pattern));
|
||||
return yaml.sub(pos + pattern.len);
|
||||
}
|
||||
|
||||
@@ -416,17 +416,17 @@ block:
|
||||
s = "asd"; bsquoted >> s; EXPECT_EQ(s, "");
|
||||
s = "asd"; bliteral >> s; EXPECT_EQ(s, "");
|
||||
s = "asd"; bfolded >> s; EXPECT_EQ(s, "");
|
||||
s = "asd"; ExpectError::check_error(&t, [&]{ fplain >> s; });
|
||||
s = "asd"; ExpectError::check_error(&t, [&]{ bplain >> s; });
|
||||
s = "asd"; ExpectError::check_error_visit(&t, [&]{ fplain >> s; }, fplain.id());
|
||||
s = "asd"; ExpectError::check_error_visit(&t, [&]{ bplain >> s; }, bplain.id());
|
||||
s = "asd"; fenull >> s; EXPECT_EQ(s, "null");
|
||||
s = "asd"; benull >> s; EXPECT_EQ(s, "null");
|
||||
s = "asd"; ftilde >> s; EXPECT_EQ(s, "~");
|
||||
s = "asd"; btilde >> s; EXPECT_EQ(s, "~");
|
||||
// check error also for integral and float types
|
||||
ExpectError::check_error(&t, [&]{ int val = 0; fplain >> val; });
|
||||
ExpectError::check_error(&t, [&]{ int val = 0; bplain >> val; });
|
||||
ExpectError::check_error(&t, [&]{ float val = 0; fplain >> val; });
|
||||
ExpectError::check_error(&t, [&]{ float val = 0; bplain >> val; });
|
||||
ExpectError::check_error_visit(&t, [&]{ int val = 0; fplain >> val; }, fplain.id());
|
||||
ExpectError::check_error_visit(&t, [&]{ int val = 0; bplain >> val; }, bplain.id());
|
||||
ExpectError::check_error_visit(&t, [&]{ float val = 0; fplain >> val; }, fplain.id());
|
||||
ExpectError::check_error_visit(&t, [&]{ float val = 0; bplain >> val; }, bplain.id());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -558,17 +558,17 @@ block:
|
||||
s = "asd"; bsquoted >> key(s); EXPECT_EQ(s, "");
|
||||
s = "asd"; bliteral >> key(s); EXPECT_EQ(s, "");
|
||||
s = "asd"; bfolded >> key(s); EXPECT_EQ(s, "");
|
||||
s = "asd"; ExpectError::check_error(&t, [&]{ fplain >> key(s); });
|
||||
s = "asd"; ExpectError::check_error(&t, [&]{ bplain >> key(s); });
|
||||
s = "asd"; ExpectError::check_error_visit(&t, [&]{ fplain >> key(s); }, fplain.id());
|
||||
s = "asd"; ExpectError::check_error_visit(&t, [&]{ bplain >> key(s); }, bplain.id());
|
||||
s = "asd"; fenull >> key(s); EXPECT_EQ(s, "null");
|
||||
s = "asd"; benull >> key(s); EXPECT_EQ(s, "null");
|
||||
s = "asd"; ftilde >> key(s); EXPECT_EQ(s, "~");
|
||||
s = "asd"; btilde >> key(s); EXPECT_EQ(s, "~");
|
||||
// check error also for integral and float types
|
||||
ExpectError::check_error(&t, [&]{ int k = 0; fplain >> key(k); });
|
||||
ExpectError::check_error(&t, [&]{ int k = 0; bplain >> key(k); });
|
||||
ExpectError::check_error(&t, [&]{ float k = 0; fplain >> key(k); });
|
||||
ExpectError::check_error(&t, [&]{ float k = 0; bplain >> key(k); });
|
||||
ExpectError::check_error_visit(&t, [&]{ int k = 0; fplain >> key(k); }, fplain.id());
|
||||
ExpectError::check_error_visit(&t, [&]{ int k = 0; bplain >> key(k); }, bplain.id());
|
||||
ExpectError::check_error_visit(&t, [&]{ float k = 0; fplain >> key(k); }, fplain.id());
|
||||
ExpectError::check_error_visit(&t, [&]{ float k = 0; bplain >> key(k); }, bplain.id());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -590,9 +590,9 @@ b:
|
||||
test_check_emit_check(yaml, [](Tree const& t){
|
||||
EXPECT_TRUE(t[0].val_is_null());
|
||||
EXPECT_TRUE(t[1].val_is_null());
|
||||
ExpectError::check_error(&t, [&] { std::string s; t["a"] >> s; });
|
||||
ExpectError::check_error(&t, [&] { int s; t["a"] >> s; });
|
||||
ExpectError::check_error(&t, [&] { float s; t["a"] >> s; });
|
||||
ExpectError::check_error_visit(&t, [&] { std::string s; t["a"] >> s; }, t["a"].id());
|
||||
ExpectError::check_error_visit(&t, [&] { int s; t["a"] >> s; }, t["a"].id());
|
||||
ExpectError::check_error_visit(&t, [&] { float s; t["a"] >> s; }, t["a"].id());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -611,9 +611,9 @@ TEST(empty_scalar, issue471_key)
|
||||
test_check_emit_check(yaml, [](Tree const& t){
|
||||
EXPECT_TRUE(t[0].key_is_null());
|
||||
EXPECT_TRUE(t[1].key_is_null());
|
||||
ExpectError::check_error(&t, [&] { std::string s; t[0] >> key(s); });
|
||||
ExpectError::check_error(&t, [&] { int s; t[0] >> key(s); });
|
||||
ExpectError::check_error(&t, [&] { float s; t[0] >> key(s); });
|
||||
ExpectError::check_error_visit(&t, [&] { std::string s; t[0] >> key(s); }, t[0].id());
|
||||
ExpectError::check_error_visit(&t, [&] { int s; t[0] >> key(s); }, t[0].id());
|
||||
ExpectError::check_error_visit(&t, [&] { float s; t[0] >> key(s); }, t[0].id());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,13 +309,13 @@ TEST(plain_scalar, issue153_map)
|
||||
TEST(plain_scalar, test_suite_BS4K)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_parse(&t, [&]{
|
||||
t = parse_in_arena(R"(word1 # comment
|
||||
word2
|
||||
word3
|
||||
)");
|
||||
});
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_parse(&t, [&]{
|
||||
t = parse_in_arena(R"(word1 # comment
|
||||
word2
|
||||
)");
|
||||
@@ -1013,7 +1013,7 @@ R"(- Several lines of text,
|
||||
- and some "quotes" of various 'types'.
|
||||
But this: must cause a parse error.
|
||||
)",
|
||||
LineCol(4, 11)
|
||||
Location(4, 11)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar, do not accept ': ' start line", EXPECT_PARSE_ERROR,
|
||||
@@ -1024,7 +1024,7 @@ R"(
|
||||
But this must cause a parse error -
|
||||
: foo bar
|
||||
)",
|
||||
LineCol(6, 3)
|
||||
Location(6, 3)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar, do not accept ': ' at line end", EXPECT_PARSE_ERROR,
|
||||
@@ -1033,7 +1033,7 @@ R"(- Several lines of text,
|
||||
- and some "quotes" of various 'types'.
|
||||
But this must cause a parse error:
|
||||
)",
|
||||
LineCol(4, 36)
|
||||
Location(4, 36)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar, do not accept ':' at line end", EXPECT_PARSE_ERROR,
|
||||
@@ -1043,7 +1043,7 @@ R"(- Several lines of text,
|
||||
But this must cause a parse error:
|
||||
- well, did it?
|
||||
)",
|
||||
LineCol(4, 36)
|
||||
Location(4, 36)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar, accept ' #' at line start",
|
||||
@@ -1117,7 +1117,7 @@ R"([
|
||||
a plain scalar
|
||||
with several lines
|
||||
)",
|
||||
LineCol(4, 1)
|
||||
Location(4, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar, explicit, early end, map", EXPECT_PARSE_ERROR,
|
||||
@@ -1125,7 +1125,7 @@ R"({foo:
|
||||
a plain scalar
|
||||
with several lines
|
||||
)",
|
||||
LineCol(4, 1)
|
||||
Location(4, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("plain scalar, multiple docs",
|
||||
|
||||
@@ -278,7 +278,7 @@ void verify_error_is_reported(csubstr case_name, csubstr yaml, Location loc={})
|
||||
SCOPED_TRACE(case_name);
|
||||
SCOPED_TRACE(yaml);
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&](){
|
||||
ExpectError::check_error_parse(&tree, [&](){
|
||||
parse_in_arena(yaml, &tree);
|
||||
}, loc);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ void verify_filter_error_is_reported(csubstr case_name, csubstr scalar_, Locatio
|
||||
SCOPED_TRACE(scalar_);
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&](){
|
||||
ExpectError::check_error_parse(&t, [&](){
|
||||
Parser::handler_type evt_handler = {};
|
||||
Parser parser(&evt_handler);
|
||||
evt_handler.reset(&t, t.root_id());
|
||||
@@ -303,7 +303,7 @@ void verify_filter_error_is_reported(csubstr case_name, csubstr scalar_, Locatio
|
||||
}
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&](){
|
||||
ExpectError::check_error_parse(&t, [&](){
|
||||
Parser::handler_type evt_handler = {};
|
||||
Parser parser(&evt_handler);
|
||||
evt_handler.reset(&t, t.root_id());
|
||||
@@ -538,7 +538,7 @@ R"(- ' 1st non-empty
|
||||
2nd non-empty
|
||||
3rd non-empty '
|
||||
)",
|
||||
LineCol(1,1)
|
||||
Location(1,1)
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace yml {
|
||||
TEST(simple_seq, bad_seq1)
|
||||
{
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
parse_in_arena(R"(
|
||||
---
|
||||
[ a, b, c ] ]
|
||||
@@ -18,7 +18,7 @@ TEST(simple_seq, bad_seq1)
|
||||
TEST(simple_seq, bad_seq2)
|
||||
{
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
parse_in_arena(R"(
|
||||
---
|
||||
[ [ a, b, c ]
|
||||
@@ -48,7 +48,7 @@ TEST(simple_seq, many_unmatched_brackets)
|
||||
Location loc = {};
|
||||
loc.line = 1;
|
||||
loc.col = num_brackets + 1u;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_parse(&tree, [&]{
|
||||
parse_in_place(to_substr(src), &tree);
|
||||
}, loc);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ TEST(simple_seq, block_tab_tokens__3_tabs_everywhere)
|
||||
}
|
||||
TEST(simple_seq, block_tab_tokens__4_tabs_indentation_error)
|
||||
{
|
||||
ExpectError::check_error([]{
|
||||
ExpectError::check_error_parse([]{
|
||||
Tree tree = parse_in_arena(R"(
|
||||
- 0 0
|
||||
- 1 1
|
||||
@@ -210,14 +210,14 @@ TEST(simple_seq, unterminated_seqimap)
|
||||
{
|
||||
SCOPED_TRACE("space after");
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_parse(&t, [&]{
|
||||
parse_in_arena("[a: ");
|
||||
});
|
||||
}
|
||||
{
|
||||
SCOPED_TRACE("no space after");
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_parse(&t, [&]{
|
||||
parse_in_arena("[a:");
|
||||
});
|
||||
}
|
||||
@@ -1043,58 +1043,58 @@ ADD_CASE_TO_GROUP("simple seq, invalid character 1", EXPECT_PARSE_ERROR,
|
||||
R"(- 0 # this is a foo
|
||||
}
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq, invalid character 2", EXPECT_PARSE_ERROR,
|
||||
R"(- 0 # this is a foo
|
||||
]
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq, invalid character 3", EXPECT_PARSE_ERROR,
|
||||
R"(- 0 # this is a foo
|
||||
:
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq, invalid character 4", EXPECT_PARSE_ERROR,
|
||||
R"(- 0 # this is a foo
|
||||
abcdef!
|
||||
)",
|
||||
LineCol(2, 1)
|
||||
Location(2, 1)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq flow, missing val, 1", EXPECT_PARSE_ERROR,
|
||||
R"([,]
|
||||
)",
|
||||
LineCol(1, 2)
|
||||
Location(1, 2)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq flow, missing val, 2", EXPECT_PARSE_ERROR,
|
||||
R"([ ,]
|
||||
)",
|
||||
LineCol(1, 3)
|
||||
Location(1, 3)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq flow, missing val, 3", EXPECT_PARSE_ERROR,
|
||||
R"([ , ]
|
||||
)",
|
||||
LineCol(1, 3)
|
||||
Location(1, 3)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq flow, missing val, 4", EXPECT_PARSE_ERROR,
|
||||
R"([ , val]
|
||||
)",
|
||||
LineCol(1, 3)
|
||||
Location(1, 3)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq flow, missing val, 5", EXPECT_PARSE_ERROR,
|
||||
R"([ , , ]
|
||||
)",
|
||||
LineCol(1, 3)
|
||||
Location(1, 3)
|
||||
);
|
||||
|
||||
ADD_CASE_TO_GROUP("simple seq flow, seqimap, at line end",
|
||||
|
||||
@@ -221,15 +221,15 @@ TEST(serialize, integral)
|
||||
i = 1; t[2] >> i; EXPECT_EQ(i, 20);
|
||||
i = 1; t[3] >> i; EXPECT_EQ(i, -30);
|
||||
i = 1; t[4] >> i; EXPECT_EQ(i, 0xaf);
|
||||
ExpectError::check_error(&t, [&]{ t[5] >> i; });
|
||||
ExpectError::check_error(&t, [&]{ t[6] >> i; });
|
||||
ExpectError::check_error_basic(&t, [&]{ t[5] >> i; });
|
||||
ExpectError::check_error_basic(&t, [&]{ t[6] >> i; });
|
||||
i = 1; t[0] >> key(i); EXPECT_EQ(i, 0);
|
||||
i = 1; t[1] >> key(i); EXPECT_EQ(i, 10);
|
||||
i = 1; t[2] >> key(i); EXPECT_EQ(i, 20);
|
||||
i = 1; t[3] >> key(i); EXPECT_EQ(i, -30);
|
||||
i = 1; t[4] >> key(i); EXPECT_EQ(i, 0xaf);
|
||||
ExpectError::check_error(&t, [&]{ t[5] >> key(i); });
|
||||
ExpectError::check_error(&t, [&]{ t[6] >> key(i); });
|
||||
ExpectError::check_error_basic(&t, [&]{ t[5] >> key(i); });
|
||||
ExpectError::check_error_basic(&t, [&]{ t[6] >> key(i); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -291,10 +291,10 @@ set:
|
||||
SCOPED_TRACE(ch.key());
|
||||
float f = 0.f;
|
||||
double d = 0.;
|
||||
ExpectError::check_error(&t, [&]{ ch >> f; });
|
||||
ExpectError::check_error(&t, [&]{ ch >> d; });
|
||||
ExpectError::check_error(&t, [&]{ ch >> key(f); });
|
||||
ExpectError::check_error(&t, [&]{ ch >> key(d); });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> f; });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> d; });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> key(f); });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> key(d); });
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -379,10 +379,10 @@ set:
|
||||
SCOPED_TRACE(ch.key());
|
||||
float f = 0.f;
|
||||
double d = 0.;
|
||||
ExpectError::check_error(&t, [&]{ ch >> f; });
|
||||
ExpectError::check_error(&t, [&]{ ch >> d; });
|
||||
ExpectError::check_error(&t, [&]{ ch >> key(f); });
|
||||
ExpectError::check_error(&t, [&]{ ch >> key(d); });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> f; });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> d; });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> key(f); });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> key(d); });
|
||||
}
|
||||
});
|
||||
C4_SUPPRESS_WARNING_GCC_CLANG_POP
|
||||
@@ -445,10 +445,10 @@ set:
|
||||
SCOPED_TRACE(ch.key());
|
||||
float f = 0.f;
|
||||
double d = 0.;
|
||||
ExpectError::check_error(&t, [&]{ ch >> f; });
|
||||
ExpectError::check_error(&t, [&]{ ch >> d; });
|
||||
ExpectError::check_error(&t, [&]{ ch >> key(f); });
|
||||
ExpectError::check_error(&t, [&]{ ch >> key(d); });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> f; });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> d; });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> key(f); });
|
||||
ExpectError::check_error_basic(&t, [&]{ ch >> key(d); });
|
||||
}
|
||||
});
|
||||
C4_SUPPRESS_WARNING_GCC_CLANG_POP
|
||||
@@ -531,11 +531,11 @@ TEST(deserialize, issue434_0)
|
||||
int value = 0;
|
||||
EXPECT_FALSE(read(node, &value));
|
||||
}
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
int value = 0;
|
||||
cnode >> value;
|
||||
});
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
int value = 0;
|
||||
node >> value;
|
||||
});
|
||||
@@ -547,11 +547,11 @@ TEST(deserialize, issue434_0)
|
||||
double value = 0;
|
||||
EXPECT_FALSE(read(node, &value));
|
||||
}
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
double value = 0;
|
||||
cnode >> value;
|
||||
});
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
double value = 0;
|
||||
node >> value;
|
||||
});
|
||||
@@ -573,11 +573,11 @@ void test_deserialize_trailing_434(csubstr yaml, csubstr val, csubstr first, dou
|
||||
int value = {};
|
||||
EXPECT_FALSE(read(node, &value));
|
||||
}
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
int value = 1;
|
||||
cnode >> value;
|
||||
});
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
int value = 1;
|
||||
node >> value;
|
||||
});
|
||||
|
||||
@@ -464,7 +464,7 @@ TEST(tag_directives, accepts_multiple_spaces)
|
||||
void test_fail_tag_parsing(csubstr yaml)
|
||||
{
|
||||
Tree t;
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_parse(&t, [&]{
|
||||
t = parse_in_arena(yaml);
|
||||
});
|
||||
}
|
||||
@@ -474,7 +474,7 @@ void test_fail_tag_resolve(csubstr yaml)
|
||||
Tree t;
|
||||
t = parse_in_arena(yaml);
|
||||
_c4dbg_tree(t);
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_basic(&t, [&]{
|
||||
t.resolve_tags();
|
||||
});
|
||||
}
|
||||
@@ -566,7 +566,7 @@ TEST(tag_directives, decode_uri_chars)
|
||||
{
|
||||
Tree t;
|
||||
auto checkerr = [&t](csubstr yaml){
|
||||
ExpectError::check_error(&t, [&]{
|
||||
ExpectError::check_error_basic(&t, [&]{
|
||||
t.clear();
|
||||
t = parse_in_arena(yaml);
|
||||
t.resolve_tags();
|
||||
@@ -888,60 +888,60 @@ TEST(tags, errors)
|
||||
|
||||
// cannot get key tag in a node that does not have a key tag
|
||||
EXPECT_FALSE(t.has_key_tag(empty_keyval));
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.key_tag(empty_keyval), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.key_tag(keyval), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.key_tag(keymap), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.key_tag(keyseq), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.key_tag(val), "");
|
||||
});
|
||||
// cannot get val tag in a node that does not have a val tag
|
||||
EXPECT_FALSE(t.has_val_tag(empty_val));
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.val_tag(empty_val), "");
|
||||
});
|
||||
EXPECT_FALSE(t.has_val_tag(empty_keyval));
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.val_tag(empty_keyval), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.val_tag(keyval), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.val_tag(keymap), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.val_tag(keyseq), "");
|
||||
});
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
EXPECT_EQ(t.val_tag(val), "");
|
||||
});
|
||||
// cannot set key tag in a node that does not have a key
|
||||
EXPECT_FALSE(t.has_key(empty_keyval));
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
t.set_key_tag(empty_keyval, "!keytag");
|
||||
});
|
||||
EXPECT_FALSE(t.has_key_tag(val)); // must stay the same
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
t.set_key_tag(val, "!valtag");
|
||||
});
|
||||
EXPECT_FALSE(t.has_key_tag(val)); // must stay the same
|
||||
// cannot set val tag in a node that does not have a val
|
||||
EXPECT_FALSE(t.has_val(empty_val));
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
t.set_val_tag(empty_val, "!valtag");
|
||||
});
|
||||
EXPECT_FALSE(t.has_val_tag(empty_val)); // must stay the same
|
||||
EXPECT_FALSE(t.has_val(empty_keyval));
|
||||
ExpectError::check_assertion(&t, [&](){
|
||||
ExpectError::check_assert_visit(&t, [&](){
|
||||
t.set_val_tag(empty_keyval, "!valtag");
|
||||
});
|
||||
EXPECT_FALSE(t.has_val_tag(empty_keyval)); // must stay the same
|
||||
@@ -1044,7 +1044,7 @@ TEST(tags, EHF6)
|
||||
TEST(tags, fuzzcrash0)
|
||||
{
|
||||
Tree tree;
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
parse_in_arena("%TAG !! " "\n"
|
||||
"})" "\n"
|
||||
"" "\n"
|
||||
|
||||
@@ -964,7 +964,10 @@ static void* alloc(size_t len, void* /*hint*/, void* user_data) {
|
||||
TEST(Tree, issue564_relocate_arena_0)
|
||||
{
|
||||
issue564::AvailableBlocks blocks_by_size;
|
||||
Callbacks cb(&blocks_by_size, issue564::alloc, issue564::free, nullptr);
|
||||
Callbacks cb{};
|
||||
cb.m_user_data = &blocks_by_size;
|
||||
cb.m_allocate = issue564::alloc;
|
||||
cb.m_free = issue564::free;
|
||||
Tree dest(cb);
|
||||
Tree source(cb);
|
||||
parse_in_arena("[]", &dest);
|
||||
@@ -1066,7 +1069,7 @@ void verify_success_(csubstr src, Function &&fn)
|
||||
template<class Function>
|
||||
void verify_assertion_(Tree &tree, Function &&fn)
|
||||
{
|
||||
ExpectError::check_assertion(&tree, [&]{
|
||||
ExpectError::check_assert_basic(&tree, [&]{
|
||||
(void)fn(tree);
|
||||
});
|
||||
}
|
||||
@@ -1074,7 +1077,7 @@ template<class Function>
|
||||
void verify_assertion_(csubstr src, Function &&fn)
|
||||
{
|
||||
Tree tree = parse_in_arena(src);
|
||||
ExpectError::check_assertion(&tree, [&]{
|
||||
ExpectError::check_assert_basic(&tree, [&]{
|
||||
(void)fn(tree);
|
||||
});
|
||||
}
|
||||
@@ -1082,7 +1085,7 @@ void verify_assertion_(csubstr src, Function &&fn)
|
||||
template<class Function>
|
||||
void verify_error_(Tree &tree, Function &&fn)
|
||||
{
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
(void)fn(tree);
|
||||
});
|
||||
}
|
||||
@@ -1090,7 +1093,7 @@ template<class Function>
|
||||
void verify_error_(csubstr src, Function &&fn)
|
||||
{
|
||||
Tree tree = parse_in_arena(src);
|
||||
ExpectError::check_error(&tree, [&]{
|
||||
ExpectError::check_error_basic(&tree, [&]{
|
||||
(void)fn(tree);
|
||||
});
|
||||
}
|
||||
@@ -4541,7 +4544,7 @@ TEST(Tree, add_tag_directives)
|
||||
check_up_to(3);
|
||||
t.add_tag_directive(td[3]);
|
||||
check_up_to(4);
|
||||
ExpectError::check_error(&t, [&]{ // number exceeded
|
||||
ExpectError::check_error_basic(&t, [&]{ // number exceeded
|
||||
t.add_tag_directive(td[4]);
|
||||
});
|
||||
t.clear_tag_directives();
|
||||
|
||||
@@ -210,7 +210,7 @@ struct TestSequenceLevel
|
||||
|
||||
void receive_src(TestSequenceLevel & prev_)
|
||||
{
|
||||
RYML_ASSERT(&prev_ == prev);
|
||||
_RYML_ASSERT_BASIC(&prev_ == prev);
|
||||
if(!prev_.tree_was_emitted)
|
||||
{
|
||||
_nfo_logf("level[{}] not emitted. emit!", prev_.level);
|
||||
@@ -230,7 +230,7 @@ struct TestSequenceLevel
|
||||
|
||||
void receive_src_json(TestSequenceLevel & prev_)
|
||||
{
|
||||
RYML_ASSERT(&prev_ == prev);
|
||||
_RYML_ASSERT_BASIC(&prev_ == prev);
|
||||
if(!prev_.tree_was_emitted_json)
|
||||
{
|
||||
_nfo_logf("level[{}] not emitted. emit!", prev_.level);
|
||||
@@ -407,7 +407,7 @@ struct TestSequenceLevel
|
||||
void compare_trees(TestSequenceLevel & that)
|
||||
{
|
||||
SCOPED_TRACE("compare trees");
|
||||
RYML_ASSERT(&that == prev);
|
||||
_RYML_ASSERT_BASIC(&that == prev);
|
||||
if(!that.tree_was_parsed)
|
||||
{
|
||||
_nfo_logf("level[{}] not parsed. parse!", that.level);
|
||||
@@ -428,7 +428,7 @@ struct TestSequenceLevel
|
||||
void compare_trees_json(TestSequenceLevel & that)
|
||||
{
|
||||
SCOPED_TRACE("compare trees");
|
||||
RYML_ASSERT(&that == prev);
|
||||
_RYML_ASSERT_BASIC(&that == prev);
|
||||
if(!that.tree_was_parsed_json)
|
||||
{
|
||||
_nfo_logf("level[{}] not parsed. parse!", that.level);
|
||||
@@ -449,7 +449,7 @@ struct TestSequenceLevel
|
||||
void compare_emitted_yaml(TestSequenceLevel & that)
|
||||
{
|
||||
SCOPED_TRACE("compare emitted");
|
||||
RYML_ASSERT(&that == prev);
|
||||
_RYML_ASSERT_BASIC(&that == prev);
|
||||
if(!that.tree_was_emitted)
|
||||
{
|
||||
_nfo_logf("level[{}] not emitted. emit!", that.level);
|
||||
@@ -476,7 +476,7 @@ struct TestSequenceLevel
|
||||
void compare_emitted_json(TestSequenceLevel & that)
|
||||
{
|
||||
SCOPED_TRACE("compare emitted");
|
||||
RYML_ASSERT(&that == prev);
|
||||
_RYML_ASSERT_BASIC(&that == prev);
|
||||
if(!that.tree_was_emitted_json)
|
||||
{
|
||||
_nfo_logf("level[{}] not emitted. emit!", that.level);
|
||||
@@ -554,7 +554,7 @@ struct TestSequenceData
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
levels[i].parse_yaml_to_tree();
|
||||
});
|
||||
break; // because we expect error,we cannot go on to the next
|
||||
@@ -573,7 +573,7 @@ struct TestSequenceData
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
levels[i].parse_json_to_tree();
|
||||
});
|
||||
break; // because we expect error,we cannot go on to the next
|
||||
@@ -595,7 +595,7 @@ struct TestSequenceData
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
levels[i].parse_yaml_to_events();
|
||||
});
|
||||
break; // because we expect error, we cannot go on to the next
|
||||
@@ -617,7 +617,7 @@ struct TestSequenceData
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpectError::check_error([&]{
|
||||
ExpectError::check_error_parse([&]{
|
||||
levels[i].parse_yaml_to_events_ints();
|
||||
});
|
||||
break; // because we expect error,we cannot go on to the next
|
||||
@@ -770,7 +770,7 @@ struct TestSequenceData
|
||||
//SKIP_IF(has_container_keys); // DO IT!
|
||||
if(m_expected_error_to_tree_checked)
|
||||
return;
|
||||
ExpectError::check_error(&levels[0].tree_parsed_from_src, [this]{
|
||||
ExpectError::check_error_parse(&levels[0].tree_parsed_from_src, [this]{
|
||||
levels[0].parse_yaml_to_tree();
|
||||
});
|
||||
m_expected_error_to_tree_checked = true;
|
||||
@@ -781,7 +781,7 @@ struct TestSequenceData
|
||||
//SKIP_IF(has_container_keys); // DO IT!
|
||||
if(m_expected_error_to_events_checked)
|
||||
return;
|
||||
ExpectError::check_error([this]{
|
||||
ExpectError::check_error_parse([this]{
|
||||
levels[0].parse_yaml_to_events();
|
||||
});
|
||||
m_expected_error_to_events_checked = true;
|
||||
@@ -792,7 +792,7 @@ struct TestSequenceData
|
||||
//SKIP_IF(has_container_keys); // DO IT!
|
||||
if(m_expected_error_to_events_ints_checked)
|
||||
return;
|
||||
ExpectError::check_error([this]{
|
||||
ExpectError::check_error_parse([this]{
|
||||
levels[0].parse_yaml_to_events_ints();
|
||||
});
|
||||
m_expected_error_to_events_ints_checked = true;
|
||||
@@ -852,7 +852,7 @@ struct SuiteCase
|
||||
case_title = to_csubstr(case_title_);
|
||||
|
||||
case_dir = to_csubstr(case_dir_);
|
||||
RYML_CHECK(case_dir.find('\\') == yml::npos);
|
||||
_RYML_CHECK_BASIC(case_dir.find('\\') == yml::npos);
|
||||
C4_CHECK_MSG(fs::dir_exists(case_dir.str), "dir not found: '%s'", case_dir);
|
||||
|
||||
filename = catrs<std::string>(case_dir, '/', to_csubstr(input_file));
|
||||
@@ -990,70 +990,70 @@ struct which : public ::testing::TestWithParam<size_t> \
|
||||
TEST_P(which, 0_parse_yaml_to_events) \
|
||||
{ \
|
||||
/*ALWAYS COMPARE.~SKIP_IF(g_suite_case->test_case_expects_error);*/ \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.parse_yaml_to_events(1 + GetParam()); \
|
||||
} \
|
||||
\
|
||||
TEST_P(which, 0_parse_yaml_to_tree) \
|
||||
{ \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.parse_yaml_to_tree(1 + GetParam()); \
|
||||
} \
|
||||
TEST_P(which, 0_parse_json_to_tree) \
|
||||
{ \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
SKIP_IF( ! g_suite_case->test_case_is_json); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.parse_json_to_tree(1 + GetParam()); \
|
||||
} \
|
||||
\
|
||||
TEST_P(which, 1_compare_emitted_events_to_ref_events) \
|
||||
{ \
|
||||
/*ALWAYS COMPARE.~SKIP_IF(g_suite_case->test_case_expects_error);*/ \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.compare_emitted_events_str(1 + GetParam(), &g_suite_case->events); \
|
||||
} \
|
||||
\
|
||||
TEST_P(which, 2_emit_tree_parsed_from_src) \
|
||||
{ \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.emit_tree_parsed_from_src(1 + GetParam()); \
|
||||
} \
|
||||
TEST_P(which, 2_emit_tree_parsed_from_src_json) \
|
||||
{ \
|
||||
SKIP_IF( ! g_suite_case->test_case_is_json); \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.emit_tree_parsed_from_src_json(1 + GetParam()); \
|
||||
} \
|
||||
\
|
||||
TEST_P(which, 3_compare_level_trees) \
|
||||
{ \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.compare_level_trees(1 + GetParam()); \
|
||||
} \
|
||||
TEST_P(which, 3_compare_level_trees_json) \
|
||||
{ \
|
||||
SKIP_IF( ! g_suite_case->test_case_is_json); \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.compare_level_trees_json(1 + GetParam()); \
|
||||
} \
|
||||
\
|
||||
TEST_P(which, 4_compare_emitted_yaml) \
|
||||
{ \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.compare_level_emitted(1 + GetParam()); \
|
||||
} \
|
||||
TEST_P(which, 4_compare_emitted_yaml_json) \
|
||||
{ \
|
||||
SKIP_IF( ! g_suite_case->test_case_is_json); \
|
||||
SKIP_IF(g_suite_case->test_case_expects_error); \
|
||||
RYML_CHECK(GetParam() < NLEVELS); \
|
||||
_RYML_CHECK_BASIC(GetParam() < NLEVELS); \
|
||||
g_suite_case->which.compare_level_emitted_json(1 + GetParam()); \
|
||||
} \
|
||||
\
|
||||
|
||||
@@ -106,7 +106,7 @@ struct Scalar
|
||||
OptionalScalar ref = {};
|
||||
OptionalScalar tag = {};
|
||||
NodeType flags = {};
|
||||
inline operator bool() const { if(anchor || tag) { RYML_ASSERT(scalar); } return scalar.was_set; }
|
||||
inline operator bool() const { if(anchor || tag) { _RYML_ASSERT_BASIC(scalar); } return scalar.was_set; }
|
||||
void add_key_props(Tree *tree, id_type node) const
|
||||
{
|
||||
if(ref)
|
||||
|
||||
@@ -181,7 +181,7 @@ cspan<AllowedFailure> g_container_key_cases = container_key_cases;
|
||||
|
||||
AllowedFailure is_failure_expected(csubstr casename)
|
||||
{
|
||||
RYML_CHECK(casename.not_empty());
|
||||
_RYML_CHECK_BASIC(casename.not_empty());
|
||||
for(AllowedFailure const& af : g_allowed_failures)
|
||||
if(af.test_name == casename || casename.begins_with(af.test_name))
|
||||
return af;
|
||||
@@ -190,7 +190,7 @@ AllowedFailure is_failure_expected(csubstr casename)
|
||||
|
||||
AllowedFailure case_has_container_keys(csubstr casename)
|
||||
{
|
||||
RYML_CHECK(casename.not_empty());
|
||||
_RYML_CHECK_BASIC(casename.not_empty());
|
||||
for(AllowedFailure const& af : g_container_key_cases)
|
||||
if(af.test_name == casename || casename.begins_with(af.test_name))
|
||||
return af;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <ryml_all.hpp>
|
||||
#else
|
||||
#include <c4/yml/common.hpp>
|
||||
#include <c4/yml/error.hpp>
|
||||
#include <c4/span.hpp>
|
||||
#endif
|
||||
#include <c4/log/log.hpp>
|
||||
|
||||
Reference in New Issue
Block a user