From e08f69fcf6388cca48e98fcbafef931478f1f661 Mon Sep 17 00:00:00 2001 From: Joao Paulo Magalhaes Date: Sat, 22 Mar 2025 20:57:30 +0000 Subject: [PATCH] refactor error API: update tests --- .../c4/yml/extra/event_handler_testsuite.hpp | 86 +- src_extra/c4/yml/extra/string.hpp | 42 +- test/CMakeLists.txt | 2 + test/test_anchor.cpp | 6 +- test/test_basic.cpp | 1 + test/test_bom.cpp | 8 +- test/test_callbacks.cpp | 2096 ++++++++++++++--- test/test_doc.cpp | 16 +- test/test_emit.cpp | 64 +- test/test_explicit_key.cpp | 10 +- test/test_extra_ints.cpp | 4 + test/test_filter.cpp | 1 + test/test_fuzz/test_fuzz_common.hpp | 63 +- test/test_github_issues.cpp | 14 +- test/test_indentation.cpp | 4 +- test/test_json.cpp | 34 +- test/test_lib/callbacks_tester.hpp | 10 +- test/test_lib/test_case.cpp | 303 ++- test/test_lib/test_case.hpp | 47 +- test/test_lib/test_case_node.hpp | 6 +- test/test_lib/test_engine.cpp | 8 +- test/test_lib/test_engine.hpp | 18 +- test/test_lib/test_group.cpp | 6 +- test/test_lib/test_group.hpp | 4 +- test/test_location.cpp | 2 +- test/test_map.cpp | 66 +- test/test_noderef.cpp | 2 +- test/test_parser.cpp | 119 +- test/test_scalar_dquoted.cpp | 5 +- test/test_scalar_folded.cpp | 12 +- test/test_scalar_literal.cpp | 24 +- test/test_scalar_null.cpp | 40 +- test/test_scalar_plain.cpp | 16 +- test/test_scalar_squoted.cpp | 8 +- test/test_seq.cpp | 30 +- test/test_serialize.cpp | 44 +- test/test_tag_property.cpp | 38 +- test/test_tree.cpp | 15 +- test/testsuite.cpp | 48 +- test/testsuite/testsuite_events.cpp | 2 +- test/testsuite/testsuite_parts.cpp | 4 +- test/testsuite/testsuite_parts.hpp | 1 + 42 files changed, 2550 insertions(+), 779 deletions(-) diff --git a/src_extra/c4/yml/extra/event_handler_testsuite.hpp b/src_extra/c4/yml/extra/event_handler_testsuite.hpp index 9c9af2bb..2a49216b 100644 --- a/src_extra/c4/yml/extra/event_handler_testsuite.hpp +++ b/src_extra/c4/yml/extra/event_handler_testsuite.hpp @@ -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__() @@ -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()); diff --git a/src_extra/c4/yml/extra/string.hpp b/src_extra/c4/yml/extra/string.hpp index 384cba18..f66dccd4 100644 --- a/src_extra/c4/yml/extra/string.hpp +++ b/src_extra/c4/yml/extra/string.hpp @@ -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]; } }; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9e6406af..650f71d9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) diff --git a/test/test_anchor.cpp b/test/test_anchor.cpp index b6087028..30e61d4b 100644 --- a/test/test_anchor.cpp +++ b/test/test_anchor.cpp @@ -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", diff --git a/test/test_basic.cpp b/test/test_basic.cpp index e8faa71c..d413e070 100644 --- a/test/test_basic.cpp +++ b/test/test_basic.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #endif #include "./test_lib/test_case.hpp" diff --git a/test/test_bom.cpp b/test/test_bom.cpp index fd432c43..b52d227f 100644 --- a/test/test_bom.cpp +++ b/test/test_bom.cpp @@ -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); }); diff --git a/test/test_callbacks.cpp b/test/test_callbacks.cpp index 9bce233b..d1ed0d60 100644 --- a/test/test_callbacks.cpp +++ b/test/test_callbacks.cpp @@ -1,12 +1,15 @@ #include "./test_lib/test_case.hpp" #ifndef RYML_SINGLE_HEADER #include "c4/yml/common.hpp" +#include "c4/yml/error.def.hpp" #include "c4/dump.hpp" #endif #include #include +C4_SUPPRESS_WARNING_MSVC_WITH_PUSH(4996) // fopen: This function or variable may be unsafe + namespace c4 { namespace yml { @@ -16,25 +19,167 @@ static_assert(size_t(c4::yml::npos) == ((size_t)-1), "invalid value"); // some d static_assert(size_t(c4::yml::NONE) == ((size_t)-1), "invalid value"); // some debuggers show the wrong value... std::string stored_msg; -Location stored_location; +std::string stored_msg_full; +Location stored_cpploc; +Location stored_ymlloc; void * stored_mem; size_t stored_length; +Tree const* stored_tree; +id_type stored_id; -C4_IF_EXCEPTIONS_( - , - std::jmp_buf s_jmp_env_expect_error = {}; - ) +C4_IF_EXCEPTIONS_( , +std::jmp_buf s_jmp_env_expect_error = {}; +) -C4_NORETURN void test_error_impl(const char* msg, size_t length, Location loc, void * /*user_data*/) +#ifdef C4_WIN +const char * const null_name = "NUL:"; +#else // assume unix or posix +const char * const null_name = "/dev/null"; +#endif + + +namespace { // anon +C4_NO_INLINE void dump2file(csubstr s, FILE *f) { - stored_msg = std::string(msg, length); - stored_location = loc; - C4_IF_EXCEPTIONS( - throw std::runtime_error(stored_msg); - , - std::longjmp(s_jmp_env_expect_error, 1); - ); - C4_UNREACHABLE_AFTER_ERR(); + // using fwrite() is more portable than using fprintf("%.*s") which + // is not available in some embedded platforms + if(s.len) + fwrite(s.str, 1, s.len, f); // NOLINT +} +} // namespace anon + +void location_print(Location const& loc, FILE *f=nullptr) +{ + if(!f) + f = stderr; + location_format([f](csubstr s){ dump2file(s, f); }, loc); +} + +void err_basic_print(csubstr msg, ErrorDataBasic const& errdata, FILE *f=nullptr) +{ + if(!f) + f = stderr; + err_basic_format([f](csubstr s){ dump2file(s, f); }, msg, errdata); + fputc('\n', f); // NOLINT + fflush(f); // NOLINT +} + +void err_parse_print(csubstr msg, ErrorDataParse const& errdata, FILE *f=nullptr) +{ + if(!f) + f = stderr; + err_parse_format([f](csubstr s){ dump2file(s, f); }, msg, errdata); + fputc('\n', f); // NOLINT + fflush(f); // NOLINT +} + +void err_visit_print(csubstr msg, ErrorDataVisit const& errdata, FILE *f=nullptr) +{ + if(!f) + f = stderr; + err_visit_format([f](csubstr s){ dump2file(s, f); }, msg, errdata); + fputc('\n', f); // NOLINT + fflush(f); // NOLINT +} + +static void test_loc_print(Location const& cpploc) +{ + FILE *file = fopen(null_name, "wb"); // NOLINT + location_print(cpploc, file); + fprintf(file, "\n"); // NOLINT + fflush(file); // NOLINT + if(file) + fclose(file); // NOLINT +} + +static void test_error_basic_print(csubstr msg, ErrorDataBasic const& errdata) +{ + FILE *file = fopen(null_name, "wb"); // NOLINT + err_basic_print(msg, errdata, file); + if(file) + fclose(file); // NOLINT +} + +static void test_error_parse_print(csubstr msg, ErrorDataParse const& errdata) +{ + FILE *file = fopen(null_name, "wb"); // NOLINT + err_parse_print(msg, errdata, file); + if(file) + fclose(file); // NOLINT +} + +static void test_error_visit_print(csubstr msg, ErrorDataVisit const& errdata) +{ + FILE *file = fopen(null_name, "wb"); // NOLINT + err_visit_print(msg, errdata, file); + if(file) + fclose(file); // NOLINT +} + +C4_NORETURN void test_error_basic_impl(csubstr msg, ErrorDataBasic const& errdata, void * /*user_data*/) +{ + std::string pmsg; + test_error_basic_print(msg, errdata); + err_basic_format([&](csubstr s){ + pmsg.append(s.str, s.len); + }, msg, errdata); + stored_msg_full = pmsg; + stored_msg.assign(msg.str, msg.len); + stored_cpploc = errdata.location; + #ifndef C4_EXCEPTIONS + std::longjmp(s_jmp_env_expect_error, 1); + #else + #ifdef _RYML_WITH_EXCEPTIONS + throw ExceptionBasic(msg, errdata); + #else + throw std::runtime_error(stored_msg); + #endif + #endif +} + +C4_NORETURN void test_error_parse_impl(csubstr msg, ErrorDataParse const& errdata, void * /*user_data*/) +{ + std::string pmsg; + test_error_parse_print(msg, errdata); + err_parse_format([&](csubstr s){ + pmsg.append(s.str, s.len); + }, msg, errdata); + stored_msg_full = pmsg; + stored_msg.assign(msg.str, msg.len); + stored_cpploc = errdata.cpploc; + stored_ymlloc = errdata.ymlloc; + #ifndef C4_EXCEPTIONS + std::longjmp(s_jmp_env_expect_error, 1); + #else + #ifdef _RYML_WITH_EXCEPTIONS + throw ExceptionParse(msg, errdata); + #else + throw std::runtime_error(stored_msg); + #endif + #endif +} + +C4_NORETURN void test_error_visit_impl(csubstr msg, ErrorDataVisit const& errdata, void * /*user_data*/) +{ + std::string pmsg; + test_error_visit_print(msg, errdata); + err_visit_format([&](csubstr s){ + pmsg.append(s.str, s.len); + }, msg, errdata); + stored_msg_full = pmsg; + stored_msg.assign(msg.str, msg.len); + stored_cpploc = errdata.cpploc; + stored_tree = errdata.tree; + stored_id = errdata.node; + #ifndef C4_EXCEPTIONS + std::longjmp(s_jmp_env_expect_error, 1); + #else + #ifdef _RYML_WITH_EXCEPTIONS + throw ExceptionVisit(msg, errdata); + #else + throw std::runtime_error(stored_msg); + #endif + #endif } void* test_allocate_impl(size_t length, void * /*hint*/, void * /*user_data*/) @@ -43,10 +188,7 @@ void* test_allocate_impl(size_t length, void * /*hint*/, void * /*user_data*/) stored_length = length; stored_mem = mem; if(mem == nullptr) - { - const char msg[] = "could not allocate memory"; - test_error_impl(msg, sizeof(msg)-1, {}, nullptr); - } + test_error_basic_impl("could not allocate memory", RYML_LOC_HERE(), nullptr); return mem; } @@ -62,157 +204,227 @@ void test_free_impl(void *mem, size_t length, void * /*user_data*/) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +Callbacks mk_test_callbacks() +{ + return Callbacks{} + .set_user_data(nullptr) + .set_allocate(&test_allocate_impl) + .set_free(&test_free_impl) + .set_error_basic(&test_error_basic_impl) + .set_error_parse(&test_error_parse_impl) + .set_error_visit(&test_error_visit_impl); +} + +void check_callbacks_test(Callbacks const& cb) +{ + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_EQ(cb.m_allocate, &test_allocate_impl); + EXPECT_EQ(cb.m_free, &test_free_impl); + EXPECT_EQ(cb.m_error_basic, &test_error_basic_impl); + EXPECT_EQ(cb.m_error_parse, &test_error_parse_impl); + EXPECT_EQ(cb.m_error_visit, &test_error_visit_impl); +} + +void check_callbacks_default(Callbacks const& cb) +{ + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_NE(cb.m_allocate, &test_allocate_impl); + EXPECT_NE(cb.m_free, &test_free_impl); + EXPECT_NE(cb.m_error_basic, &test_error_basic_impl); + EXPECT_NE(cb.m_error_parse, &test_error_parse_impl); + EXPECT_NE(cb.m_error_visit, &test_error_visit_impl); +#ifndef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_NE(cb.m_allocate, nullptr); + EXPECT_NE(cb.m_free, nullptr); + EXPECT_NE(cb.m_error_basic, nullptr); + EXPECT_NE(cb.m_error_parse, nullptr); + EXPECT_NE(cb.m_error_visit, nullptr); +#else + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_EQ(cb.m_allocate, nullptr); + EXPECT_EQ(cb.m_free, nullptr); + EXPECT_EQ(cb.m_error_basic, nullptr); + EXPECT_EQ(cb.m_error_parse, nullptr); + EXPECT_EQ(cb.m_error_visit, nullptr); +#endif +} TEST(Callbacks, ctor) { - { - Callbacks cb; - EXPECT_NE(cb.m_allocate, &test_allocate_impl); - EXPECT_NE(cb.m_free, &test_free_impl); - EXPECT_NE(cb.m_error, &test_error_impl); - #ifndef RYML_NO_DEFAULT_CALLBACKS - EXPECT_EQ(cb.m_user_data, nullptr); - EXPECT_NE(cb.m_allocate, nullptr); - EXPECT_NE(cb.m_free, nullptr); - EXPECT_NE(cb.m_error, nullptr); - #else - EXPECT_EQ(cb.m_user_data, nullptr); - EXPECT_EQ(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, nullptr); - EXPECT_EQ(cb.m_error, nullptr); - #endif - } - { - Callbacks cb((void*)0xff, nullptr, nullptr, nullptr); - EXPECT_NE(cb.m_allocate, &test_allocate_impl); - EXPECT_NE(cb.m_free, &test_free_impl); - EXPECT_NE(cb.m_error, &test_error_impl); - #ifndef RYML_NO_DEFAULT_CALLBACKS - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_NE(cb.m_allocate, nullptr); - EXPECT_NE(cb.m_free, nullptr); - EXPECT_NE(cb.m_error, nullptr); - #else - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_EQ(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, nullptr); - EXPECT_EQ(cb.m_error, nullptr); - #endif - } - { - Callbacks cb((void*)0xff, &test_allocate_impl, nullptr, nullptr); - #ifndef RYML_NO_DEFAULT_CALLBACKS - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_EQ(cb.m_allocate, &test_allocate_impl); - EXPECT_NE(cb.m_free, nullptr); - EXPECT_NE(cb.m_error, nullptr); - #else - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_EQ(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, nullptr); - EXPECT_EQ(cb.m_error, nullptr); - #endif - } - { - Callbacks cb((void*)0xff, nullptr, &test_free_impl, nullptr); - #ifndef RYML_NO_DEFAULT_CALLBACKS - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_NE(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, &test_free_impl); - EXPECT_NE(cb.m_error, nullptr); - #else - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_EQ(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, &test_free_impl); - EXPECT_EQ(cb.m_error, nullptr); - #endif - } - { - Callbacks cb((void*)0xff, nullptr, nullptr, &test_error_impl); - #ifndef RYML_NO_DEFAULT_CALLBACKS - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_NE(cb.m_allocate, nullptr); - EXPECT_NE(cb.m_free, nullptr); - EXPECT_EQ(cb.m_error, &test_error_impl); - #else - EXPECT_EQ(cb.m_user_data, (void*)0xff); - EXPECT_EQ(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, nullptr); - EXPECT_EQ(cb.m_error, test_error_impl); - #endif - } + Callbacks cb; + EXPECT_NE(cb.m_allocate, &test_allocate_impl); + EXPECT_NE(cb.m_free, &test_free_impl); + EXPECT_NE(cb.m_error_basic, &test_error_basic_impl); + EXPECT_NE(cb.m_error_parse, &test_error_parse_impl); + EXPECT_NE(cb.m_error_visit, &test_error_visit_impl); +#ifndef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_NE(cb.m_allocate, nullptr); + EXPECT_NE(cb.m_free, nullptr); + EXPECT_NE(cb.m_error_basic, nullptr); + EXPECT_NE(cb.m_error_parse, nullptr); + EXPECT_NE(cb.m_error_visit, nullptr); +#else + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_EQ(cb.m_allocate, nullptr); + EXPECT_EQ(cb.m_free, nullptr); + EXPECT_EQ(cb.m_error_basic, nullptr); + EXPECT_EQ(cb.m_error_parse, nullptr); + EXPECT_EQ(cb.m_error_visit, nullptr); +#endif + int data = 1; + C4_SUPPRESS_WARNING_GCC_WITH_PUSH("-Wdeprecated-declarations"); + C4_SUPPRESS_WARNING_CLANG_WITH_PUSH("-Wdeprecated"); + Callbacks cb2((void*)&data, + &test_allocate_impl, + &test_free_impl, + &test_error_basic_impl); + C4_SUPPRESS_WARNING_GCC_CLANG_POP +#ifndef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb2.m_user_data, &data); + EXPECT_EQ(cb2.m_allocate, &test_allocate_impl); + EXPECT_EQ(cb2.m_free, &test_free_impl); + EXPECT_EQ(cb2.m_error_basic, &test_error_basic_impl); + EXPECT_NE(cb.m_error_parse, nullptr); + EXPECT_NE(cb.m_error_visit, nullptr); +#else + EXPECT_EQ(cb2.m_user_data, nullptr); + EXPECT_EQ(cb.m_user_data, nullptr); + EXPECT_EQ(cb.m_allocate, nullptr); + EXPECT_EQ(cb.m_free, nullptr); + EXPECT_EQ(cb.m_error_basic, nullptr); + EXPECT_EQ(cb.m_error_parse, nullptr); + EXPECT_EQ(cb.m_error_visit, nullptr); +#endif } +TEST(Callbacks, set_user_data) +{ + Callbacks cb; + EXPECT_EQ(cb.m_user_data, nullptr); + cb.set_user_data((void*)0xff); + EXPECT_EQ(cb.m_user_data, (void*)0xff); + cb.set_user_data(nullptr); + EXPECT_EQ(cb.m_user_data, nullptr); +} + +TEST(Callbacks, set_allocate) +{ + Callbacks cb; + cb.set_allocate(test_allocate_impl); + EXPECT_EQ(cb.m_allocate, test_allocate_impl); + cb.set_allocate(test_allocate_impl); + cb.set_allocate(nullptr); +#ifdef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_allocate, nullptr); +#else + EXPECT_NE(cb.m_allocate, nullptr); +#endif +} + +TEST(Callbacks, set_free) +{ + Callbacks cb; + cb.set_free(test_free_impl); + EXPECT_EQ(cb.m_free, test_free_impl); + cb.set_free(test_free_impl); + cb.set_free(nullptr); +#ifdef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_free, nullptr); +#else + EXPECT_NE(cb.m_free, nullptr); +#endif +} + +TEST(Callbacks, set_error_basic) +{ + Callbacks cb; + cb.set_error_basic(test_error_basic_impl); + EXPECT_EQ(cb.m_error_basic, test_error_basic_impl); + cb.set_error_basic(test_error_basic_impl); + cb.set_error_basic(nullptr); +#ifdef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_error_basic, nullptr); +#else + EXPECT_NE(cb.m_error_basic, nullptr); +#endif +} + +TEST(Callbacks, set_error_parse) +{ + Callbacks cb; + cb.set_error_parse(test_error_parse_impl); + EXPECT_EQ(cb.m_error_parse, test_error_parse_impl); + cb.set_error_parse(test_error_parse_impl); + cb.set_error_parse(nullptr); +#ifdef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_error_parse, nullptr); +#else + EXPECT_NE(cb.m_error_parse, nullptr); +#endif +} + +TEST(Callbacks, set_error_visit) +{ + Callbacks cb; + cb.set_error_visit(test_error_visit_impl); + EXPECT_EQ(cb.m_error_visit, test_error_visit_impl); + cb.set_error_visit(test_error_visit_impl); + cb.set_error_visit(nullptr); +#ifdef RYML_NO_DEFAULT_CALLBACKS + EXPECT_EQ(cb.m_error_visit, nullptr); +#else + EXPECT_NE(cb.m_error_visit, nullptr); +#endif +} + + TEST(Callbacks, get) { Callbacks cb = get_callbacks(); - EXPECT_NE(cb.m_allocate, &test_allocate_impl); - EXPECT_NE(cb.m_free, &test_free_impl); - EXPECT_NE(cb.m_error, &test_error_impl); - #ifndef RYML_NO_DEFAULT_CALLBACKS - EXPECT_EQ(cb.m_user_data, nullptr); - EXPECT_NE(cb.m_allocate, nullptr); - EXPECT_NE(cb.m_free, nullptr); - EXPECT_NE(cb.m_error, nullptr); - #else - EXPECT_EQ(cb.m_user_data, nullptr); - EXPECT_EQ(cb.m_allocate, nullptr); - EXPECT_EQ(cb.m_free, nullptr); - EXPECT_EQ(cb.m_error, nullptr); - #endif + check_callbacks_default(cb); } TEST(Callbacks, set) { + Callbacks cb = mk_test_callbacks(); Callbacks before = get_callbacks(); - Callbacks cb((void*)0xff, &test_allocate_impl, &test_free_impl, &test_error_impl); - + check_callbacks_default(before); set_callbacks(cb); - Callbacks after = get_callbacks(); - EXPECT_EQ(cb.m_user_data, after.m_user_data); - EXPECT_EQ(cb.m_allocate, after.m_allocate); - EXPECT_EQ(cb.m_free, after.m_free); - EXPECT_EQ(cb.m_error, after.m_error); - + Callbacks curr = get_callbacks(); + check_callbacks_test(curr); set_callbacks(before); - after = get_callbacks(); - EXPECT_EQ(before.m_user_data, after.m_user_data); - EXPECT_EQ(before.m_allocate, after.m_allocate); - EXPECT_EQ(before.m_free, after.m_free); - EXPECT_EQ(before.m_error, after.m_error); - - set_callbacks(cb); - after = get_callbacks(); - EXPECT_EQ(cb.m_user_data, after.m_user_data); - EXPECT_EQ(cb.m_allocate, after.m_allocate); - EXPECT_EQ(cb.m_free, after.m_free); - EXPECT_EQ(cb.m_error, after.m_error); + curr = get_callbacks(); + check_callbacks_default(curr); } TEST(Callbacks, reset) { Callbacks before = get_callbacks(); - Callbacks cb((void*)0xff, &test_allocate_impl, &test_free_impl, &test_error_impl); - + { + SCOPED_TRACE("default"); + check_callbacks_default(before); + } + Callbacks cb = mk_test_callbacks(); set_callbacks(cb); - Callbacks after = get_callbacks(); - EXPECT_EQ(cb.m_user_data, after.m_user_data); - EXPECT_EQ(cb.m_allocate, after.m_allocate); - EXPECT_EQ(cb.m_free, after.m_free); - EXPECT_EQ(cb.m_error, after.m_error); - + { + SCOPED_TRACE("test"); + check_callbacks_test(cb); + } reset_callbacks(); - EXPECT_EQ(before.m_user_data, after.m_user_data); - EXPECT_EQ(before.m_allocate, after.m_allocate); - EXPECT_EQ(before.m_free, after.m_free); - EXPECT_EQ(before.m_error, after.m_error); + { + SCOPED_TRACE("before"); + check_callbacks_default(before); + check_callbacks_default(get_callbacks()); + } } TEST(Callbacks, eq) { Callbacks before = get_callbacks(); Callbacks bf2 = get_callbacks(); - Callbacks cb((void*)0xff, &test_allocate_impl, &test_free_impl, &test_error_impl); + Callbacks cb = mk_test_callbacks(); EXPECT_EQ(bf2, before); EXPECT_TRUE(bf2 == before); @@ -224,8 +436,7 @@ TEST(Callbacks, ne) { Callbacks before = get_callbacks(); Callbacks bf2 = get_callbacks(); - Callbacks cb((void*)0xff, &test_allocate_impl, &test_free_impl, &test_error_impl); - + Callbacks cb = mk_test_callbacks().set_user_data((void*)0xff); EXPECT_NE(cb, before); EXPECT_TRUE(cb != before); EXPECT_TRUE(!(bf2 != before)); @@ -234,46 +445,80 @@ TEST(Callbacks, ne) TEST(Callbacks, cmp_user_data) { - #ifndef C4_UBSAN Callbacks before = get_callbacks(); - before.m_user_data = (void*)1u; - Callbacks cp = before; - EXPECT_EQ(cp, before); - cp.m_user_data = (void*)(((char*)before.m_user_data) + 100u); // ubsan: runtime error: applying non-zero offset 100 to null pointer - EXPECT_NE(cp, before); - #endif + Callbacks cb = get_callbacks(); + EXPECT_EQ(cb, before); + EXPECT_TRUE(cb == before); + cb.set_user_data((void*)0xff); + EXPECT_NE(cb, before); + EXPECT_TRUE(cb != before); + EXPECT_FALSE(!(cb != before)); } TEST(Callbacks, cmp_allocate) { Callbacks before = get_callbacks(); - Callbacks cp = before; - EXPECT_NE(cp.m_allocate, nullptr); - EXPECT_EQ(cp, before); - cp.m_allocate = nullptr; - EXPECT_NE(cp, before); + Callbacks cb = get_callbacks(); + EXPECT_EQ(cb, before); + EXPECT_TRUE(cb == before); + EXPECT_FALSE(!(cb == before)); + cb.set_allocate(test_allocate_impl); + EXPECT_NE(cb, before); + EXPECT_TRUE(cb != before); + EXPECT_FALSE(!(cb != before)); } TEST(Callbacks, cmp_free) { Callbacks before = get_callbacks(); - Callbacks cp = before; - EXPECT_NE(cp.m_free, nullptr); - EXPECT_EQ(cp, before); - cp.m_free = nullptr; - EXPECT_NE(cp, before); + Callbacks cb = get_callbacks(); + EXPECT_EQ(cb, before); + EXPECT_TRUE(cb == before); + EXPECT_FALSE(!(cb == before)); + cb.set_free(test_free_impl); + EXPECT_NE(cb, before); + EXPECT_TRUE(cb != before); + EXPECT_FALSE(!(cb != before)); } -TEST(Callbacks, cmp_error) +TEST(Callbacks, cmp_error_basic) { Callbacks before = get_callbacks(); - Callbacks cp = before; - EXPECT_NE(cp.m_error, nullptr); - EXPECT_EQ(cp, before); - cp.m_error = nullptr; - EXPECT_NE(cp, before); + Callbacks cb = get_callbacks(); + EXPECT_EQ(cb, before); + EXPECT_TRUE(cb == before); + EXPECT_FALSE(!(cb == before)); + cb.set_error_basic(test_error_basic_impl); + EXPECT_NE(cb, before); + EXPECT_TRUE(cb != before); + EXPECT_FALSE(!(cb != before)); } +TEST(Callbacks, cmp_error_parse) +{ + Callbacks before = get_callbacks(); + Callbacks cb = get_callbacks(); + EXPECT_EQ(cb, before); + EXPECT_TRUE(cb == before); + EXPECT_FALSE(!(cb == before)); + cb.set_error_parse(test_error_parse_impl); + EXPECT_NE(cb, before); + EXPECT_TRUE(cb != before); + EXPECT_FALSE(!(cb != before)); +} + +TEST(Callbacks, cmp_error_visit) +{ + Callbacks before = get_callbacks(); + Callbacks cb = get_callbacks(); + EXPECT_EQ(cb, before); + EXPECT_TRUE(cb == before); + EXPECT_FALSE(!(cb == before)); + cb.set_error_visit(test_error_visit_impl); + EXPECT_NE(cb, before); + EXPECT_TRUE(cb != before); + EXPECT_FALSE(!(cb != before)); +} //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -282,9 +527,8 @@ TEST(Callbacks, cmp_error) TEST(allocate_and_free, basic) { EXPECT_NE(get_callbacks().m_allocate, &test_allocate_impl); - EXPECT_NE(get_callbacks().m_error, &test_error_impl); - Callbacks cb(nullptr, &test_allocate_impl, &test_free_impl, nullptr); - set_callbacks(cb); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); void *mem = get_callbacks().m_allocate(32, /*hint*/0, get_callbacks().m_user_data); EXPECT_EQ(stored_mem, mem); EXPECT_EQ(stored_length, 32u); @@ -293,108 +537,836 @@ TEST(allocate_and_free, basic) get_callbacks().m_free(mem, 32u, get_callbacks().m_user_data); EXPECT_EQ(stored_mem, mem); EXPECT_EQ(stored_length, 32u); + reset_callbacks(); +} + +void testloc(Location const& actual, Location const& expected) +{ + test_loc_print(actual); // ensure coverage + EXPECT_EQ(actual.name, expected.name); + EXPECT_EQ(actual.offset, expected.offset); + EXPECT_EQ(actual.line, expected.line); + EXPECT_EQ(actual.col, expected.col); +} +void test_full_msg(Location const& loc, csubstr msg, csubstr *payload) +{ + SCOPED_TRACE(std::string(msg.str, msg.len)); + csubstr rem = msg; + ASSERT_TRUE(rem.begins_with(loc.name)); + rem = rem.sub(loc.name.len); + ASSERT_TRUE(rem.begins_with(':')); + rem = rem.sub(1); + size_t pos = rem.find(':'); + ASSERT_NE(pos, csubstr::npos); + csubstr str = rem.first(pos); + EXPECT_EQ(str.len, pos); + size_t line_num = csubstr::npos; + ASSERT_TRUE(from_chars(str, &line_num)); + EXPECT_EQ(loc.line, line_num); + rem = rem.sub(pos); + ASSERT_TRUE(rem.begins_with(':')); + rem = rem.sub(1); + if(loc.col != npos) + { + ASSERT_TRUE(rem.begins_with(" col=")); + rem = rem.sub(5); + if(loc.offset == npos) + { + pos = rem.find(':'); + ASSERT_NE(pos, csubstr::npos); + str = rem.first(pos); + EXPECT_EQ(str.len, pos); + rem = rem.sub(pos); + ASSERT_TRUE(rem.begins_with(':')); + rem = rem.sub(1); + } + else + { + pos = rem.find(" ("); + ASSERT_NE(pos, csubstr::npos); + str = rem.first(pos); + EXPECT_EQ(str.len, pos); + rem = rem.sub(pos); + } + size_t col_num = csubstr::npos; + ASSERT_TRUE(from_chars(str, &col_num)) << str; + EXPECT_EQ(loc.col, col_num); + } + ASSERT_TRUE(rem.begins_with(" ")); + rem = rem.sub(1); + if(loc.offset != npos) + { + ASSERT_TRUE(rem.begins_with("(")); + rem = rem.sub(1); + pos = rem.find("B)"); + ASSERT_NE(pos, csubstr::npos); + str = rem.first(pos); + EXPECT_EQ(str.len, pos); + size_t offset = csubstr::npos; + ASSERT_TRUE(from_chars(str, &offset)); + EXPECT_EQ(loc.offset, offset); + rem = rem.sub(pos); + ASSERT_TRUE(rem.begins_with("B): ")) << rem; + rem = rem.sub(4); + } + ASSERT_TRUE(rem.begins_with("ERROR: ")) << rem; + rem = rem.sub(csubstr("ERROR: ").len); + ASSERT_TRUE(rem.begins_with('[')) << rem; + rem = rem.sub(1); + ASSERT_TRUE(rem.begins_with("basic") || rem.begins_with("parse") || rem.begins_with("visit")) << rem; + rem = rem.sub(5); + ASSERT_TRUE(rem.begins_with("] ")) << rem; + rem = rem.sub(2); + *payload = rem; +} +void test_full_msg_args(Location const& loc, csubstr msg, std::string const& expected) +{ + csubstr payload; + test_full_msg(loc, msg, &payload); + ASSERT_TRUE(payload.is_sub(msg)); + EXPECT_TRUE(to_csubstr(payload).begins_with(to_csubstr(expected))) << "payload=~~~" << std::string(payload.str, payload.len) << "~~~ vs expected=~~~" << expected << "~~~"; + EXPECT_TRUE(to_csubstr(stored_msg).begins_with(to_csubstr(expected))) << "payload=~~~" << std::string(payload.str, payload.len) << "~~~ vs expected=~~~" << expected << "~~~"; +} + + +//----------------------------------------------------------------------------- + +#ifdef _RYML_WITH_EXCEPTIONS +#define RYML_IF_EXC(...) __VA_ARGS__ +#else +#define RYML_IF_EXC(...) +#endif + +template +void test_error_basic(Location const& cpploc, const char* errmsg, Args const& ...args) +{ + auto reset_stored = []{ + stored_msg_full = {}; + stored_msg = {}; + stored_cpploc = {}; + }; + SCOPED_TRACE("test_error_basic"); + reset_stored(); + { + SCOPED_TRACE("custom handler"); + std::string expected = c4::formatrs(errmsg, args...); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_basic(cpploc, errmsg, args...); + } + RYML_IF_EXC(catch(ExceptionBasic const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, cpploc); + test_full_msg_args(cpploc, to_csubstr(stored_msg_full), expected); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + } + reset_stored(); + { + SCOPED_TRACE("custom handler, no format"); + std::string expected = errmsg; + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_basic(cpploc, errmsg); + } + RYML_IF_EXC(catch(ExceptionBasic const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, cpploc); + test_full_msg_args(cpploc, to_csubstr(stored_msg_full), expected); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + } + // + #ifdef _RYML_WITH_EXCEPTIONS + reset_stored(); + { + SCOPED_TRACE("default handler exceptions"); + std::string expected = c4::formatrs(errmsg, args...); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_basic(cpploc, errmsg, args...); + } + catch(ExceptionBasic const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_basic.location, cpploc); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected); + } + reset_stored(); + { + SCOPED_TRACE("default handler exceptions"); + std::string expected = errmsg; + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_basic(cpploc, errmsg); + } + catch(ExceptionBasic const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_basic.location, cpploc); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected); + } + #endif } TEST(error, basic) { - EXPECT_NE(get_callbacks().m_error, &test_error_impl); - Callbacks cb(nullptr, nullptr, nullptr, &test_error_impl); - set_callbacks(cb); - // message - EXPECT_EQ(get_callbacks().m_error, &test_error_impl); - C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) { - c4::yml::error("some message 123"); // calls test_error_impl, which sets stored_msg and stored_location + SCOPED_TRACE("case 1: no col, no offset"); + test_error_basic(Location("file.yml", 0, 123u, 0), "some message int={} s={}", 1213, "abc"); } - C4_IF_EXCEPTIONS_(catch(std::exception const&), else) { - ; + SCOPED_TRACE("case 2: no col, offset"); + test_error_basic(Location("file.yml", 433u, 123u, 0u), "some message int={} s={}", 1213, "abc"); } - EXPECT_EQ(stored_msg, "some message 123"); - EXPECT_EQ(stored_location.name, ""); - EXPECT_EQ(stored_location.offset, 0u); - EXPECT_EQ(stored_location.line, 0u); - EXPECT_EQ(stored_location.col, 0u); - // location - C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) { - c4::yml::error("some message 456", Location("file.yml", 433u, 123u, 4u)); + SCOPED_TRACE("case 3: col, no offset"); + test_error_basic(Location("file.yml", 0, 123u, 456u), "some message int={} s={}", 1213, "abc"); } - C4_IF_EXCEPTIONS_(catch(std::exception const&), else) { - ; + SCOPED_TRACE("case 4: col, offset"); + test_error_basic(Location("file.yml", 433u, 123u, 456u), "some message int={} s={}", 1213, "abc"); + } +} + +#ifdef _RYML_WITH_EXCEPTIONS +template +void testmsg(Args const& ...args) +{ + std::string msg(RYML_ERRMSG_SIZE + 10, '='); + T exc(to_csubstr(msg), args...); + ASSERT_EQ(sizeof(exc.msg), RYML_ERRMSG_SIZE); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 1], '\0'); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 2], ']'); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 3], '.'); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 4], '.'); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 5], '.'); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 6], '['); + EXPECT_EQ(exc.msg[RYML_ERRMSG_SIZE - 7], '='); + EXPECT_EQ(to_csubstr(exc.msg).first_not_of('='), RYML_ERRMSG_SIZE - 6); +} +TEST(error, basic_message_is_truncated) +{ + testmsg(ErrorDataBasic(Location{})); +} +TEST(error, parse_message_is_truncated) +{ + testmsg(ErrorDataParse(Location{}, Location{})); +} +TEST(error, visit_message_is_truncated) +{ + Tree tree; + id_type node = {}; + testmsg(ErrorDataVisit(Location{}, &tree, node)); +} +#endif + +TEST(error, loc_print_accepts_null_file) +{ + test_loc_print(Location{}); + test_loc_print(RYML_LOC_HERE()); + location_print(Location{}); + location_print(Location{}, nullptr); + location_print(RYML_LOC_HERE()); + fprintf(stderr, "\n"); // NOLINT + location_print(RYML_LOC_HERE(), nullptr); + fprintf(stderr, "\n"); // NOLINT +} + +TEST(error, basic_print_accepts_null_file) +{ + csubstr msg = "(disregard this message)"; + err_basic_print(msg, Location{}); + err_basic_print(msg, Location{}, nullptr); + err_basic_print(msg, RYML_LOC_HERE()); + err_basic_print(msg, RYML_LOC_HERE(), nullptr); +} + +TEST(error, parse_print_accepts_null_file) +{ + csubstr msg = "(disregard this message)"; + err_parse_print(msg, {Location{}, Location{}}); + err_parse_print(msg, {Location{}, Location{}}, nullptr); + err_parse_print(msg, {RYML_LOC_HERE(), Location{}}); + err_parse_print(msg, {RYML_LOC_HERE(), Location{}}, nullptr); + err_parse_print(msg, {Location{}, RYML_LOC_HERE()}); + err_parse_print(msg, {Location{}, RYML_LOC_HERE()}, nullptr); + err_parse_print(msg, {RYML_LOC_HERE(), RYML_LOC_HERE()}); + err_parse_print(msg, {RYML_LOC_HERE(), RYML_LOC_HERE()}, nullptr); +} + +TEST(error, visit_print_accepts_null_file) +{ + csubstr msg = "(disregard this message)"; + Tree tree; + id_type node = {}; + err_visit_print(msg, {Location{}, &tree, node}); + err_visit_print(msg, {Location{}, &tree, node}, nullptr); + err_visit_print(msg, {RYML_LOC_HERE(), &tree, node}); + err_visit_print(msg, {RYML_LOC_HERE(), &tree, node}, nullptr); +} + + +//----------------------------------------------------------------------------- + +template +void test_error_parse(Location const& cpploc, Location const& ymlloc, const char* errmsg, Args const& ...args) +{ + SCOPED_TRACE("test_error_parse"); + const std::string expected = errmsg; + const std::string expected_fmt = c4::formatrs(errmsg, args...); + auto reset_stored = []{ + stored_msg_full = {}; + stored_msg = {}; + stored_cpploc = {}; + stored_ymlloc = {}; + }; + reset_stored(); + { + SCOPED_TRACE("custom handler"); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg, args...); + } + RYML_IF_EXC(catch(ExceptionParse const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_ymlloc, ymlloc); + testloc(stored_cpploc, cpploc); + test_full_msg_args(ymlloc, to_csubstr(stored_msg_full), expected_fmt); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected_fmt)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + } + reset_stored(); + { + SCOPED_TRACE("custom handler, no format"); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg); + } + RYML_IF_EXC(catch(ExceptionParse const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_ymlloc, ymlloc); + testloc(stored_cpploc, cpploc); + test_full_msg_args(ymlloc, to_csubstr(stored_msg_full), expected); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + } + reset_stored(); + { + SCOPED_TRACE("custom handler, parse falls back to basic"); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + Callbacks cb2 = mk_test_callbacks(); + cb2.m_error_parse = nullptr; + set_callbacks(cb2); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg); + } + RYML_IF_EXC(catch(ExceptionParse const& exc){ + exc_ok = false; + } + catch(ExceptionBasic const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, ymlloc); + EXPECT_EQ(to_csubstr(stored_msg), expected); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + } + reset_stored(); + { + SCOPED_TRACE("custom handler, parse falls back to basic"); + Callbacks cb2 = mk_test_callbacks(); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + cb2.m_error_parse = nullptr; + set_callbacks(cb2); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg, args...); + } + RYML_IF_EXC(catch(ExceptionParse const& exc){ + exc_ok = false; + } + catch(ExceptionBasic const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, ymlloc); + EXPECT_EQ(to_csubstr(stored_msg), expected_fmt); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected_fmt)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + } + // + #ifdef _RYML_WITH_EXCEPTIONS + reset_stored(); + { + SCOPED_TRACE("default handler exceptions"); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg, args...); + } + catch(ExceptionParse const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_parse.ymlloc, ymlloc); + testloc(exc.errdata_parse.cpploc, cpploc); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected_fmt); + } + reset_stored(); + { + SCOPED_TRACE("default handler exceptions, no format"); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg); + } + catch(ExceptionParse const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_parse.ymlloc, ymlloc); + testloc(exc.errdata_parse.cpploc, cpploc); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected); + } + reset_stored(); + { + SCOPED_TRACE("parse err can be caught as basic"); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_parse({cpploc, ymlloc}, errmsg, args...); + } + catch(ExceptionBasic const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_basic.location, ymlloc); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected_fmt); + } + #endif +} + +TEST(error, parse) +{ + { + SCOPED_TRACE("case 1: no col, no offset"); + test_error_parse(Location("file.cpp", 0, 123u, 0), + Location("file.yml", 0, 123u, 0), + "some message int={} s={}", 1213, "abc"); + } + { + SCOPED_TRACE("case 2: no col, offset"); + test_error_parse(Location("file.cpp", 433u, 123u, 0u), + Location("file.yml", 433u, 123u, 0u), + "some message int={} s={}", 1213, "abc"); + } + { + SCOPED_TRACE("case 2: col, no offset"); + test_error_parse(Location("file.cpp", 0, 123u, 456u), + Location("file.yml", 0, 123u, 456u), + "some message int={} s={}", 1213, "abc"); + } + { + SCOPED_TRACE("case 4: no col, offset"); + test_error_parse(Location("file.cpp", 433u, 123u, 456u), + Location("file.yml", 433u, 123u, 456u), + "some message int={} s={}", 1213, "abc"); + } +} + + +//----------------------------------------------------------------------------- + +template +void test_error_visit(Location const& cpploc, Tree const* t, id_type id, const char* errmsg, Args const& ...args) +{ + const std::string expected = errmsg; + const std::string expected_fmt = c4::formatrs(errmsg, args...); + auto reset_stored = []{ + stored_msg_full = {}; + stored_msg = {}; + stored_cpploc = {}; + stored_id = NONE; + stored_tree = nullptr; + }; + SCOPED_TRACE("test_error_visit"); + reset_stored(); + { + SCOPED_TRACE("custom handler"); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + set_callbacks(mk_test_callbacks()); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_visit({cpploc, t, id}, errmsg, args...); + } + RYML_IF_EXC(catch(ExceptionVisit const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, cpploc); + test_full_msg_args(cpploc, to_csubstr(stored_msg_full), expected_fmt); + EXPECT_EQ(stored_tree, t); + EXPECT_EQ(stored_id, id); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected_fmt)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + } + // + reset_stored(); + { + SCOPED_TRACE("custom handler, no fmt"); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + set_callbacks(mk_test_callbacks()); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_visit({cpploc, t, id}, errmsg); + } + RYML_IF_EXC(catch(ExceptionVisit const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, cpploc); + test_full_msg_args(cpploc, to_csubstr(stored_msg_full), expected); + EXPECT_EQ(stored_tree, t); + EXPECT_EQ(stored_id, id); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + } + // + reset_stored(); + { + SCOPED_TRACE("custom handler, null visit falls back to basic, args"); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + Callbacks cb = mk_test_callbacks(); + cb.m_error_visit = nullptr; + set_callbacks(cb); + EXPECT_EQ(get_callbacks().m_error_visit, nullptr); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_visit({cpploc, t, id}, errmsg, args...); + } + RYML_IF_EXC(catch(ExceptionVisit const& exc){ + exc_ok = false; + } + catch(ExceptionBasic const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, cpploc); + test_full_msg_args(cpploc, to_csubstr(stored_msg_full), expected_fmt); + EXPECT_EQ(stored_tree, nullptr); + EXPECT_EQ(stored_id, NONE); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected_fmt)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + } + // + reset_stored(); + { + SCOPED_TRACE("custom handler, null visit falls back to basic, args"); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + Callbacks cb = mk_test_callbacks(); + cb.m_error_visit = nullptr; + set_callbacks(cb); + EXPECT_EQ(get_callbacks().m_error_visit, nullptr); + std::string exc_msg;(void)exc_msg; + RYML_IF_EXC(bool exc_ok = false); + C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) + { + c4::yml::err_visit({cpploc, t, id}, errmsg); + } + RYML_IF_EXC(catch(ExceptionVisit const& exc){ + exc_ok = false; + } + catch(ExceptionBasic const& exc){ + exc_msg = exc.what(); + exc_ok = true; + }) + C4_IF_EXCEPTIONS_(catch(std::exception const& exc) { exc_msg = exc.what(); }, else {;}) + testloc(stored_cpploc, cpploc); + EXPECT_EQ(stored_msg, expected); + EXPECT_EQ(stored_tree, nullptr); + EXPECT_EQ(stored_id, NONE); + RYML_IF_EXC(EXPECT_TRUE(exc_ok)); + RYML_IF_EXC(EXPECT_EQ(exc_msg, expected)); + reset_callbacks(); + EXPECT_NE(get_callbacks().m_error_visit, &test_error_visit_impl); + } + // + #ifdef _RYML_WITH_EXCEPTIONS + reset_stored(); + { + SCOPED_TRACE("default handler exceptions"); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_visit({cpploc, t, id}, errmsg, args...); + } + catch(ExceptionVisit const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_visit.cpploc, cpploc); + EXPECT_EQ(exc.errdata_visit.tree, t); + EXPECT_EQ(exc.errdata_visit.node, id); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected_fmt); + } + reset_stored(); + { + SCOPED_TRACE("default handler exceptions, no fmt"); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_visit({cpploc, t, id}, errmsg); + } + catch(ExceptionVisit const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_visit.cpploc, cpploc); + EXPECT_EQ(exc.errdata_visit.tree, t); + EXPECT_EQ(exc.errdata_visit.node, id); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected); + } + reset_stored(); + { + SCOPED_TRACE("visit err can be caught as basic"); + bool exc_ok = false; + std::string exc_msg; + try + { + c4::yml::err_visit({cpploc, t, id}, errmsg, args...); + } + catch(ExceptionBasic const& exc) + { + exc_ok = true; + exc_msg = exc.what(); + testloc(exc.errdata_basic.location, cpploc); + } + catch(std::exception const& exc) + { + exc_msg = exc.what(); + } + EXPECT_TRUE(exc_ok); + EXPECT_EQ(exc_msg, expected_fmt); + } + #endif +} + +TEST(error, visit) +{ + const Tree tree = parse_in_arena("foo: bar"); + const id_type id = tree["foo"].id(); + { + SCOPED_TRACE("case 1: no col, no offset"); + test_error_visit(Location("file.cpp", 0, 123u, 0), + &tree, id, + "some message int={} s={}", 1213, "abc"); + } + { + SCOPED_TRACE("case 2: no col, offset"); + test_error_visit(Location("file.cpp", 433u, 123u, 0u), + &tree, id, + "some message int={} s={}", 1213, "abc"); + } + { + SCOPED_TRACE("case 2: col, no offset"); + test_error_visit(Location("file.cpp", 0, 123u, 456u), + &tree, id, + "some message int={} s={}", 1213, "abc"); + } + { + SCOPED_TRACE("case 4: no col, offset"); + test_error_visit(Location("file.cpp", 433u, 123u, 456u), + &tree, id, + "some message int={} s={}", 1213, "abc"); } - EXPECT_EQ(stored_msg, "some message 456"); - EXPECT_EQ(stored_location.name, "file.yml"); - EXPECT_EQ(stored_location.offset, 433u); - EXPECT_EQ(stored_location.line, 123u); - EXPECT_EQ(stored_location.col, 4u); - reset_callbacks(); - EXPECT_NE(get_callbacks().m_error, &test_error_impl); } TEST(RYML_CHECK, basic) { - EXPECT_NE(get_callbacks().m_error, &test_error_impl); - Callbacks cb(nullptr, nullptr, nullptr, &test_error_impl); - set_callbacks(cb); - ASSERT_EQ(get_callbacks(), cb); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); + ASSERT_EQ(get_callbacks(), mk_test_callbacks()); const size_t the_line = (size_t)(__LINE__ + 3); // careful C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) { - RYML_CHECK(false); // keep both statements in the same line + _RYML_CHECK_BASIC(false); // keep both statements in the same line } C4_IF_EXCEPTIONS_(catch(std::exception const&), else) { ; } - EXPECT_EQ(stored_msg, "check failed: false"); - EXPECT_EQ(stored_location.name, __FILE__); - EXPECT_EQ(stored_location.offset, 0u); - EXPECT_EQ(stored_location.line, the_line); - EXPECT_EQ(stored_location.col, 0u); + EXPECT_EQ(stored_msg, "check failed"); + EXPECT_EQ(stored_cpploc.name, __FILE__); + EXPECT_EQ(stored_cpploc.offset, npos); + EXPECT_EQ(stored_cpploc.line, the_line); + EXPECT_EQ(stored_cpploc.col, npos); reset_callbacks(); - EXPECT_NE(get_callbacks().m_error, &test_error_impl); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); } TEST(RYML_ASSERT, basic) { - EXPECT_NE(get_callbacks().m_error, &test_error_impl); - Callbacks cb(nullptr, nullptr, nullptr, &test_error_impl); - set_callbacks(cb); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); + set_callbacks(mk_test_callbacks()); stored_msg = ""; - stored_location = {}; + stored_cpploc = {}; const size_t the_line = (size_t)(__LINE__ + 3); // careful C4_IF_EXCEPTIONS_(try, if(setjmp(s_jmp_env_expect_error) == 0)) { - RYML_ASSERT(false); + _RYML_ASSERT_BASIC(false); } C4_IF_EXCEPTIONS_(catch(std::exception const&), else) { ; } #if RYML_USE_ASSERT - EXPECT_EQ(stored_msg, "check failed: false"); - EXPECT_EQ(stored_location.name, __FILE__); - EXPECT_EQ(stored_location.offset, 0u); - EXPECT_EQ(stored_location.line, the_line); - EXPECT_EQ(stored_location.col, 0u); + EXPECT_EQ(stored_msg, "check failed"); + EXPECT_EQ(stored_cpploc.name, __FILE__); + EXPECT_EQ(stored_cpploc.offset, npos); + EXPECT_EQ(stored_cpploc.line, the_line); + EXPECT_EQ(stored_cpploc.col, npos); #else (void)the_line; EXPECT_EQ(stored_msg, ""); - EXPECT_EQ(stored_location.name, nullptr); - EXPECT_EQ(stored_location.offset, 0u); - EXPECT_EQ(stored_location.line, 0u); - EXPECT_EQ(stored_location.col, 0u); + EXPECT_EQ(stored_cpploc.name, nullptr); + EXPECT_EQ(stored_cpploc.offset, npos); + EXPECT_EQ(stored_cpploc.line, npos); + EXPECT_EQ(stored_cpploc.col, npos); #endif reset_callbacks(); - EXPECT_NE(get_callbacks().m_error, &test_error_impl); + EXPECT_NE(get_callbacks().m_error_parse, &test_error_parse_impl); } //----------------------------------------------------------------------------- +struct CustomLengthArg { size_t len; }; +size_t to_chars(substr buf, CustomLengthArg const& arg) +{ + size_t len = (arg.len < buf.len) ? arg.len : buf.len; + for(size_t i = 0; i < len; ++i) + buf.str[i] = (char)('0' + (i % 9)); + return arg.len; +} + struct Dumper { char errmsg[RYML_ERRMSG_SIZE] = {0}; @@ -404,66 +1376,664 @@ struct Dumper writer.append(s); } }; -TEST(_parse_dump, small_args) + +TEST(_to_chars_limited, arg_not_requiring_argbuf) { - const std::string str(/*count*/RYML_LOGBUF_SIZE-1, 's'); - const csubstr fmt = "smaller={}"; - const std::string expected = formatrs(fmt, str); + char argbuf_[RYML_LOGBUF_SIZE]; + substr argbuf(argbuf_); + ASSERT_EQ(argbuf.len + 1, RYML_LOGBUF_SIZE); { - Dumper dumper; - char writebuf[RYML_LOGBUF_SIZE]; - c4::DumpResults results = c4::format_dump_resume(dumper, writebuf, fmt, str); - EXPECT_EQ(results.bufsize, str.size()); - EXPECT_EQ(dumper.writer.curr(), to_csubstr(expected)); + SCOPED_TRACE("smaller size"); + std::string arg(argbuf.len - 1, '-'); + const std::string expected = catrs(arg); + csubstr actual = detail::_to_chars_limited(argbuf, to_csubstr(arg)); + EXPECT_EQ(expected.size(), arg.size()); + EXPECT_EQ(actual, expected); } { - Dumper dumper; - detail::_dump(dumper, fmt, str); - EXPECT_EQ(dumper.writer.curr(), to_csubstr(expected)); + SCOPED_TRACE("same size"); + std::string arg(argbuf.len, '-'); + const std::string expected = catrs(arg); + csubstr actual = detail::_to_chars_limited(argbuf, to_csubstr(arg)); + EXPECT_EQ(expected.size(), arg.size()); + EXPECT_EQ(actual, expected); + } + { + SCOPED_TRACE("larger size"); + std::string arg(argbuf.len + 1, '-'); + std::string expected = catrs(arg); + csubstr actual = detail::_to_chars_limited(argbuf, to_csubstr(arg)); + EXPECT_EQ(expected.size(), arg.size()); + EXPECT_EQ(actual, expected); } } -TEST(_parse_dump, large_args) +TEST(_to_chars_limited, arg_requiring_argbuf) { - const std::string str(/*count*/RYML_LOGBUF_SIZE+1, 'l'); - const csubstr fmt = "larger={}"; + char argbuf_[RYML_LOGBUF_SIZE]; + substr argbuf(argbuf_); + ASSERT_EQ(argbuf.len + 1, RYML_LOGBUF_SIZE); { - Dumper dumper; - char writebuf[RYML_LOGBUF_SIZE]; - c4::DumpResults results = c4::format_dump_resume(dumper, writebuf, fmt, str); - const csubstr expected = "larger="; - EXPECT_EQ(results.bufsize, str.size()); - EXPECT_EQ(dumper.writer.curr(), expected); + SCOPED_TRACE("smaller size"); + CustomLengthArg arg{argbuf.len - 1}; + const std::string expected = catrs(arg); + csubstr actual = detail::_to_chars_limited(argbuf, arg); + EXPECT_EQ(expected.size(), arg.len); + EXPECT_EQ(actual, expected); } { - Dumper dumper; - detail::_dump(dumper, fmt, str); - const std::string expected = formatrs(fmt, str); - EXPECT_EQ(dumper.writer.curr(), to_csubstr(expected)); + SCOPED_TRACE("same size"); + CustomLengthArg arg{argbuf.len}; + const std::string expected = catrs(arg); + csubstr actual = detail::_to_chars_limited(argbuf, arg); + EXPECT_EQ(expected.size(), arg.len); + EXPECT_EQ(actual, expected); + } + { + SCOPED_TRACE("larger size"); + CustomLengthArg arg{argbuf.len + 1}; + std::string expected = catrs(arg); + csubstr actual = detail::_to_chars_limited(argbuf, arg); + EXPECT_EQ(expected.size(), arg.len); + EXPECT_NE(actual, expected); + EXPECT_GT(arg.len, argbuf.len); + EXPECT_GT(expected.size(), argbuf.len); + EXPECT_EQ(actual.len, argbuf.len); + EXPECT_TRUE(actual.ends_with("...")) << actual; + csubstr expected_with_ellipsis = detail::_maybe_add_ellipsis(to_substr(expected).first(argbuf.len), arg.len); + EXPECT_TRUE(expected_with_ellipsis.ends_with("...")) << expected; + EXPECT_EQ(actual, expected_with_ellipsis); } } -TEST(_parse_dump, unprintable_args) +TEST(_mk_err_msg, smaller_size) { - const std::string str(/*count*/RYML_LOGBUF_SIZE_MAX+1, 'u'); - const csubstr fmt = "unprintable={}"; - const csubstr expected = "unprintable="; + size_t item_size = RYML_ERRMSG_SIZE / 10; + std::string arg(item_size, '-'); + char buf_[RYML_ERRMSG_SIZE]; + substr buf(buf_); + std::string expected = c4::formatrs("{}", to_csubstr(arg)); + EXPECT_EQ(expected.size(), item_size); + csubstr actual = detail::_mk_err_msg(buf, "{}", to_csubstr(arg)); + EXPECT_LT(actual.len, buf.len); + EXPECT_EQ(actual, expected); +} + +TEST(_mk_err_msg, larger_size_not_requiring_argbuf) +{ + size_t item_size = RYML_ERRMSG_SIZE * 2; + std::string arg_(item_size, '-'); + csubstr arg = to_csubstr(arg_); + EXPECT_EQ(arg.size(), item_size); + EXPECT_EQ(arg.len, item_size); + char buf_[RYML_ERRMSG_SIZE] = {0}; + substr buf(buf_); + std::string expected = c4::formatrs("{}", arg); + EXPECT_EQ(expected.size(), arg.len); + csubstr actual = detail::_mk_err_msg(buf, "{}", arg); + EXPECT_EQ(actual.len, buf.len); + EXPECT_NE(actual, expected); + EXPECT_TRUE(actual.ends_with("...")); +} + +TEST(_mk_err_msg, larger_size_requiring_argbuf) +{ + size_t item_size = RYML_ERRMSG_SIZE * 2; + CustomLengthArg arg{item_size}; + EXPECT_EQ(arg.len, item_size); + char buf_[RYML_ERRMSG_SIZE]; + substr buf(buf_); + std::string expected = c4::formatrs("{}", arg); + EXPECT_EQ(expected.size(), arg.len); + csubstr actual = detail::_mk_err_msg(buf, "{}", arg); + EXPECT_EQ(actual.len, RYML_LOGBUF_SIZE-1); + EXPECT_NE(actual, expected); + EXPECT_TRUE(actual.ends_with("...")); +} + +TEST(_mk_err_msg, trailing_fmt) +{ + char buf_[RYML_ERRMSG_SIZE]; + substr buf(buf_); + std::string expected = c4::formatrs("{} trailing after fmt", 2); + csubstr actual = detail::_mk_err_msg(buf, "{} trailing after fmt", 2); + EXPECT_EQ(actual, expected); +} + +TEST(_mk_err_msg, no_args) +{ + char buf_[RYML_ERRMSG_SIZE]; + substr buf(buf_); + std::string expected = c4::formatrs("look, no args!"); + csubstr actual = detail::_mk_err_msg(buf, "look, no args!"); + EXPECT_EQ(actual, expected); +} + + +TEST(_get_text_region, basic) +{ + #define check_same(a, b) \ + { \ + csubstr a_ = (a); \ + csubstr b_ = (b); \ + if(a_.str != b_.str || a_.len != b_.len) \ + { \ + std::cout << __FILE__ << ":" << __LINE__ << ": " \ + << "[" << a_.len << "]~~~"; \ + std::cout.write(a_.str, (std::streamsize)a_.len); \ + std::cout << "~~~=" #a "\n"; \ + std::cout << __FILE__ << ":" << __LINE__ << ": " \ + << "[" << b_.len << "]~~~"; \ + std::cout.write(b_.str, (std::streamsize)b_.len); \ + std::cout << "~~~=" #b "\n"; \ + } \ + EXPECT_EQ(a_.str, b_.str); \ + EXPECT_EQ(a_.len, b_.len); \ + } + using detail::_get_text_region; { - Dumper dumper; - char writebuf[RYML_LOGBUF_SIZE]; - c4::DumpResults results = c4::format_dump_resume(dumper, writebuf, fmt, str); - EXPECT_EQ(results.bufsize, str.size()); - EXPECT_EQ(dumper.writer.curr(), expected); + csubstr txt = ""; + check_same(txt, _get_text_region(txt, 0, 0, 0)); + check_same(txt, _get_text_region(txt, 0, 2, 2)); + check_same(txt, _get_text_region(txt, 1, 2, 2)); + check_same(txt, _get_text_region(txt, 2, 2, 2)); } { - Dumper dumper; - detail::_dump(dumper, fmt, str); - size_t unprintable_size = (size_t)(RYML_LOGBUF_SIZE_MAX+1); - const std::string zeros(/*count*/unprintable_size, '\0'); - EXPECT_EQ(to_csubstr(zeros).len, unprintable_size); - EXPECT_EQ(dumper.writer.pos, expected.size()); - EXPECT_EQ(dumper.writer.curr(), expected); + csubstr txt = "a\nb\nc\n"; + // + check_same(txt.first(1), _get_text_region(txt, 0, 0, 0)); + check_same(txt.first(1), _get_text_region(txt, 1, 0, 0)); + check_same(txt.range(2, 3), _get_text_region(txt, 2, 0, 0)); + check_same(txt.range(2, 3), _get_text_region(txt, 3, 0, 0)); + check_same(txt.range(4, 5), _get_text_region(txt, 4, 0, 0)); + check_same(txt.range(4, 5), _get_text_region(txt, 5, 0, 0)); + check_same(txt.range(6, 6), _get_text_region(txt, 6, 0, 0)); + // 1 line before + check_same(txt.first(1), _get_text_region(txt, 0, 1, 0)); + check_same(txt.first(1), _get_text_region(txt, 1, 1, 0)); + check_same(txt.range(0, 3), _get_text_region(txt, 2, 1, 0)); + check_same(txt.range(0, 3), _get_text_region(txt, 3, 1, 0)); + check_same(txt.range(2, 5), _get_text_region(txt, 4, 1, 0)); + check_same(txt.range(2, 5), _get_text_region(txt, 5, 1, 0)); + check_same(txt.range(4, 6), _get_text_region(txt, 6, 1, 0)); + // 2 lines before + check_same(txt.first(1), _get_text_region(txt, 0, 2, 0)); + check_same(txt.first(1), _get_text_region(txt, 1, 2, 0)); + check_same(txt.range(0, 3), _get_text_region(txt, 2, 2, 0)); + check_same(txt.range(0, 3), _get_text_region(txt, 3, 2, 0)); + check_same(txt.range(0, 5), _get_text_region(txt, 4, 2, 0)); + check_same(txt.range(0, 5), _get_text_region(txt, 5, 2, 0)); + check_same(txt.range(2, 6), _get_text_region(txt, 6, 2, 0)); + // 1 line after + check_same(txt.first(3), _get_text_region(txt, 0, 0, 1)); + check_same(txt.first(3), _get_text_region(txt, 1, 0, 1)); + check_same(txt.range(2, 5), _get_text_region(txt, 2, 0, 1)); + check_same(txt.range(2, 5), _get_text_region(txt, 3, 0, 1)); + check_same(txt.range(4, 6), _get_text_region(txt, 4, 0, 1)); + check_same(txt.range(4, 6), _get_text_region(txt, 5, 0, 1)); + check_same(txt.range(6, 6), _get_text_region(txt, 6, 0, 1)); + // 2 lines after + check_same(txt.first(5), _get_text_region(txt, 0, 0, 2)); + check_same(txt.first(5), _get_text_region(txt, 1, 0, 2)); + check_same(txt.range(2, 6), _get_text_region(txt, 2, 0, 2)); + check_same(txt.range(2, 6), _get_text_region(txt, 3, 0, 2)); + check_same(txt.range(4, 6), _get_text_region(txt, 4, 0, 2)); + check_same(txt.range(4, 6), _get_text_region(txt, 5, 0, 2)); + check_same(txt.range(6, 6), _get_text_region(txt, 6, 0, 2)); } + #undef check_same +} + + +struct msgs { std::string nocall, withcall; }; +msgs mkmsg_(csubstr txt, const char* file, size_t line, size_t col, size_t offset, size_t firstcol=0, size_t lastcol=0, size_t num_lines_before=0, size_t num_lines_after = 0, size_t maxlen=80u) +{ + Location loc; + loc.name = to_csubstr(file); + loc.line = line; + loc.col = col; + loc.offset = offset; + msgs ret; + auto dumpfn1 = [&ret](csubstr s) { ret.nocall.append(s.str, s.len); }; + location_format_with_context(dumpfn1, loc, txt, csubstr{}, firstcol, lastcol, num_lines_before, num_lines_after, maxlen); + #if defined(RYML_DBG) || 1 + std::cout << "----\n"; + std::cout << ret.nocall; + #endif + auto dumpfn2 = [&ret](csubstr s) { ret.withcall.append(s.str, s.len); }; + location_format_with_context(dumpfn2, loc, txt, "error", firstcol, lastcol, num_lines_before, num_lines_after, maxlen); + #if defined(RYML_DBG) || 1 + std::cout << "....\n"; + std::cout << ret.withcall; + #endif + return ret; +} + +TEST(format_region, basic) +{ +#define mkmsg(args, nocall_, withcall_) \ + do { \ + SCOPED_TRACE(#args); \ + msgs actual = mkmsg_ args; \ + msgs expected{nocall_, withcall_}; \ + EXPECT_EQ(actual.nocall, expected.nocall); \ + EXPECT_EQ(actual.withcall, expected.withcall); \ + } while(0) + + csubstr txt = "aaa\nbbb\nccc\nddd\neee\n"; + // src file line col offset + mkmsg((txt, nullptr, npos, npos, npos), "", ""); + mkmsg((txt, nullptr, npos, npos, 0), "(0B): aaa\n", "(0B): error:\nerror:\nerror: aaa\n"); // FIXME + mkmsg((txt, nullptr, npos, npos, 1), "(1B): aaa\n", "(1B): error:\nerror:\nerror: aaa\n"); // FIXME + mkmsg((txt, nullptr, npos, npos, 2), "(2B): aaa\n", "(2B): error:\nerror:\nerror: aaa\n"); // FIXME + mkmsg((txt, nullptr, npos, npos, 3), "(3B): aaa\n", "(3B): error:\nerror:\nerror: aaa\n"); // FIXME + mkmsg((txt, nullptr, npos, 0 , npos), "col=0: \n", "col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, npos, 0 , 0), "col=0 (0B): aaa\n |\n (here)\n", "col=0 (0B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 1), "col=1 (1B): aaa\n |\n (here)\n", "col=1 (1B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 2), "col=2 (2B): aaa\n |\n (here)\n", "col=2 (2B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 3), "col=3 (3B): aaa\n |\n (here)\n", "col=3 (3B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos), "", ""); + mkmsg((txt, nullptr, npos, npos, 4+0), "(4B): bbb\n", "(4B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+1), "(5B): bbb\n", "(5B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+2), "(6B): bbb\n", "(6B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+3), "(7B): bbb\n", "(7B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, 0 , npos), "col=0: \n", "col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, npos, 0 , 4+0), "col=0 (4B): bbb\n |\n (here)\n", "col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 4+1), "col=1 (5B): bbb\n |\n (here)\n", "col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 4+2), "col=2 (6B): bbb\n |\n (here)\n", "col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 4+3), "col=3 (7B): bbb\n |\n (here)\n", "col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos, 1), "", ""); + mkmsg((txt, nullptr, npos, npos, 4+0 , 1), "(4B): bbb\n(4B): see region:\naaa\nbbb\n", "(4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+1 , 1), "(5B): bbb\n(5B): see region:\naaa\nbbb\n", "(5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+2 , 1), "(6B): bbb\n(6B): see region:\naaa\nbbb\n", "(6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+3 , 1), "(7B): bbb\n(7B): see region:\naaa\nbbb\n", "(7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, 0 , npos, 1), "col=0: \ncol=0: see region:\n", "col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, npos, 0 , 4+0 , 1), "col=0 (4B): bbb\n |\n (here)\ncol=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 4+1 , 1), "col=1 (5B): bbb\n |\n (here)\ncol=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 4+2 , 1), "col=2 (6B): bbb\n |\n (here)\ncol=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 4+3 , 1), "col=3 (7B): bbb\n |\n (here)\ncol=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos, 2), "", ""); + mkmsg((txt, nullptr, npos, npos, 4+0 , 2), "(4B): bbb\n(4B): see region:\naaa\nbbb\n", "(4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+1 , 2), "(5B): bbb\n(5B): see region:\naaa\nbbb\n", "(5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+2 , 2), "(6B): bbb\n(6B): see region:\naaa\nbbb\n", "(6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, npos, 4+3 , 2), "(7B): bbb\n(7B): see region:\naaa\nbbb\n", "(7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, npos, 0 , npos, 2), "col=0: \ncol=0: see region:\n", "col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, npos, 0 , 4+0 , 2), "col=0 (4B): bbb\n |\n (here)\ncol=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 4+1 , 2), "col=1 (5B): bbb\n |\n (here)\ncol=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 4+2 , 2), "col=2 (6B): bbb\n |\n (here)\ncol=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 4+3 , 2), "col=3 (7B): bbb\n |\n (here)\ncol=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos), "", ""); + mkmsg((txt, nullptr, npos, npos, 8+0), "(8B): ccc\n", "(8B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+1), "(9B): ccc\n", "(9B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+2), "(10B): ccc\n", "(10B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+3), "(11B): ccc\n", "(11B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, 0 , npos), "col=0: \n", "col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, npos, 0 , 8+0), "col=0 (8B): ccc\n |\n (here)\n", "col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 8+1), "col=1 (9B): ccc\n |\n (here)\n", "col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 8+2), "col=2 (10B): ccc\n |\n (here)\n", "col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 8+3), "col=3 (11B): ccc\n |\n (here)\n", "col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos, 1), "", ""); + mkmsg((txt, nullptr, npos, npos, 8+0 , 1), "(8B): ccc\n(8B): see region:\nbbb\nccc\n", "(8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+1 , 1), "(9B): ccc\n(9B): see region:\nbbb\nccc\n", "(9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+2 , 1), "(10B): ccc\n(10B): see region:\nbbb\nccc\n", "(10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+3 , 1), "(11B): ccc\n(11B): see region:\nbbb\nccc\n", "(11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, 0 , npos, 1), "col=0: \ncol=0: see region:\n", "col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, npos, 0 , 8+0 , 1), "col=0 (8B): ccc\n |\n (here)\ncol=0 (8B): see region:\nbbb\nccc\n|\n(here)\n", "col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 8+1 , 1), "col=1 (9B): ccc\n |\n (here)\ncol=1 (9B): see region:\nbbb\nccc\n |\n (here)\n", "col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 8+2 , 1), "col=2 (10B): ccc\n |\n (here)\ncol=2 (10B): see region:\nbbb\nccc\n |\n (here)\n", "col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 8+3 , 1), "col=3 (11B): ccc\n |\n (here)\ncol=3 (11B): see region:\nbbb\nccc\n |\n (here)\n", "col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos, 2), "", ""); + mkmsg((txt, nullptr, npos, npos, 8+0 , 2), "(8B): ccc\n(8B): see region:\naaa\nbbb\nccc\n", "(8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+1 , 2), "(9B): ccc\n(9B): see region:\naaa\nbbb\nccc\n", "(9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+2 , 2), "(10B): ccc\n(10B): see region:\naaa\nbbb\nccc\n", "(10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+3 , 2), "(11B): ccc\n(11B): see region:\naaa\nbbb\nccc\n", "(11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, 0 , npos, 2), "col=0: \ncol=0: see region:\n", "col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, npos, 0 , 8+0 , 2), "col=0 (8B): ccc\n |\n (here)\ncol=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 8+1 , 2), "col=1 (9B): ccc\n |\n (here)\ncol=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 8+2 , 2), "col=2 (10B): ccc\n |\n (here)\ncol=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 8+3 , 2), "col=3 (11B): ccc\n |\n (here)\ncol=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, npos, npos, 3), "", ""); + mkmsg((txt, nullptr, npos, npos, 8+0 , 3), "(8B): ccc\n(8B): see region:\naaa\nbbb\nccc\n", "(8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+1 , 3), "(9B): ccc\n(9B): see region:\naaa\nbbb\nccc\n", "(9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+2 , 3), "(10B): ccc\n(10B): see region:\naaa\nbbb\nccc\n", "(10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, npos, 8+3 , 3), "(11B): ccc\n(11B): see region:\naaa\nbbb\nccc\n", "(11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, npos, 0 , npos, 3), "col=0: \ncol=0: see region:\n", "col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, npos, 0 , 8+0 , 3), "col=0 (8B): ccc\n |\n (here)\ncol=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 1 , 8+1 , 3), "col=1 (9B): ccc\n |\n (here)\ncol=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 2 , 8+2 , 3), "col=2 (10B): ccc\n |\n (here)\ncol=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, npos, 3 , 8+3 , 3), "col=3 (11B): ccc\n |\n (here)\ncol=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + // + // src file line col offset + mkmsg((txt, nullptr, 10, npos, npos), "line=10: \n", "line=10: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, 11, npos, 0), "line=11: (0B): aaa\n", "line=11: (0B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, nullptr, 12, npos, 1), "line=12: (1B): aaa\n", "line=12: (1B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, nullptr, 13, npos, 2), "line=13: (2B): aaa\n", "line=13: (2B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, nullptr, 14, npos, 3), "line=14: (3B): aaa\n", "line=14: (3B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, nullptr, 10, 0 , npos), "line=10 col=0: \n", "line=10 col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, 11, 0 , 0), "line=11 col=0 (0B): aaa\n |\n (here)\n", "line=11 col=0 (0B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 1), "line=12 col=1 (1B): aaa\n |\n (here)\n", "line=12 col=1 (1B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 2), "line=13 col=2 (2B): aaa\n |\n (here)\n", "line=13 col=2 (2B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 3), "line=14 col=3 (3B): aaa\n |\n (here)\n", "line=14 col=3 (3B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos), "line=10: \n", "line=10: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, 11, npos, 4+0), "line=11: (4B): bbb\n", "line=11: (4B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, 12, npos, 4+1), "line=12: (5B): bbb\n", "line=12: (5B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, 13, npos, 4+2), "line=13: (6B): bbb\n", "line=13: (6B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, 14, npos, 4+3), "line=14: (7B): bbb\n", "line=14: (7B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, nullptr, 10, 0 , 4+0), "line=10 col=0 (4B): bbb\n |\n (here)\n", "line=10 col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 0 , 4+1), "line=12 col=0 (5B): bbb\n |\n (here)\n", "line=12 col=0 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 4+1), "line=12 col=1 (5B): bbb\n |\n (here)\n", "line=12 col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 4+2), "line=13 col=2 (6B): bbb\n |\n (here)\n", "line=13 col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 4+3), "line=14 col=3 (7B): bbb\n |\n (here)\n", "line=14 col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos, 1), "line=10: \nline=10: see region:\n", "line=10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, npos, 4+0 , 1), "line=11: (4B): bbb\nline=11: (4B): see region:\naaa\nbbb\n", "line=11: (4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 12, npos, 4+1 , 1), "line=12: (5B): bbb\nline=12: (5B): see region:\naaa\nbbb\n", "line=12: (5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 13, npos, 4+2 , 1), "line=13: (6B): bbb\nline=13: (6B): see region:\naaa\nbbb\n", "line=13: (6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 14, npos, 4+3 , 1), "line=14: (7B): bbb\nline=14: (7B): see region:\naaa\nbbb\n", "line=14: (7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 10, 0 , npos, 1), "line=10 col=0: \nline=10 col=0: see region:\n", "line=10 col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, 0 , 4+0 , 1), "line=11 col=0 (4B): bbb\n |\n (here)\nline=11 col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "line=11 col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 4+1 , 1), "line=12 col=1 (5B): bbb\n |\n (here)\nline=12 col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "line=12 col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 4+2 , 1), "line=13 col=2 (6B): bbb\n |\n (here)\nline=13 col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "line=13 col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 4+3 , 1), "line=14 col=3 (7B): bbb\n |\n (here)\nline=14 col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "line=14 col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos, 2), "line=10: \nline=10: see region:\n", "line=10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, npos, 4+0 , 2), "line=11: (4B): bbb\nline=11: (4B): see region:\naaa\nbbb\n", "line=11: (4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 12, npos, 4+1 , 2), "line=12: (5B): bbb\nline=12: (5B): see region:\naaa\nbbb\n", "line=12: (5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 13, npos, 4+2 , 2), "line=13: (6B): bbb\nline=13: (6B): see region:\naaa\nbbb\n", "line=13: (6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 14, npos, 4+3 , 2), "line=14: (7B): bbb\nline=14: (7B): see region:\naaa\nbbb\n", "line=14: (7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, nullptr, 10, 0 , npos, 2), "line=10 col=0: \nline=10 col=0: see region:\n", "line=10 col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, 0 , 4+0 , 2), "line=11 col=0 (4B): bbb\n |\n (here)\nline=11 col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "line=11 col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 4+1 , 2), "line=12 col=1 (5B): bbb\n |\n (here)\nline=12 col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "line=12 col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 4+2 , 2), "line=13 col=2 (6B): bbb\n |\n (here)\nline=13 col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "line=13 col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 4+3 , 2), "line=14 col=3 (7B): bbb\n |\n (here)\nline=14 col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "line=14 col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos), "line=10: \n", "line=10: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, 11, npos, 8+0), "line=11: (8B): ccc\n", "line=11: (8B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, 12, npos, 8+1), "line=12: (9B): ccc\n", "line=12: (9B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, 13, npos, 8+2), "line=13: (10B): ccc\n", "line=13: (10B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, 14, npos, 8+3), "line=14: (11B): ccc\n", "line=14: (11B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, nullptr, 10, 0 , npos), "line=10 col=0: \n", "line=10 col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, nullptr, 11, 0 , 8+0), "line=11 col=0 (8B): ccc\n |\n (here)\n", "line=11 col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 8+1), "line=12 col=1 (9B): ccc\n |\n (here)\n", "line=12 col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 8+2), "line=13 col=2 (10B): ccc\n |\n (here)\n", "line=13 col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 8+3), "line=14 col=3 (11B): ccc\n |\n (here)\n", "line=14 col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos, 1), "line=10: \nline=10: see region:\n", "line=10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, npos, 8+0 , 1), "line=11: (8B): ccc\nline=11: (8B): see region:\nbbb\nccc\n", "line=11: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 12, npos, 8+1 , 1), "line=12: (9B): ccc\nline=12: (9B): see region:\nbbb\nccc\n", "line=12: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 13, npos, 8+2 , 1), "line=13: (10B): ccc\nline=13: (10B): see region:\nbbb\nccc\n", "line=13: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 14, npos, 8+3 , 1), "line=14: (11B): ccc\nline=14: (11B): see region:\nbbb\nccc\n", "line=14: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 10, 0 , npos, 1), "line=10 col=0: \nline=10 col=0: see region:\n", "line=10 col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, 0 , 8+0 , 1), "line=11 col=0 (8B): ccc\n |\n (here)\nline=11 col=0 (8B): see region:\nbbb\nccc\n|\n(here)\n", "line=11 col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 8+1 , 1), "line=12 col=1 (9B): ccc\n |\n (here)\nline=12 col=1 (9B): see region:\nbbb\nccc\n |\n (here)\n", "line=12 col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 8+2 , 1), "line=13 col=2 (10B): ccc\n |\n (here)\nline=13 col=2 (10B): see region:\nbbb\nccc\n |\n (here)\n", "line=13 col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 8+3 , 1), "line=14 col=3 (11B): ccc\n |\n (here)\nline=14 col=3 (11B): see region:\nbbb\nccc\n |\n (here)\n", "line=14 col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos, 2), "line=10: \nline=10: see region:\n", "line=10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, npos, 8+0 , 2), "line=11: (8B): ccc\nline=11: (8B): see region:\naaa\nbbb\nccc\n", "line=11: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 12, npos, 8+1 , 2), "line=12: (9B): ccc\nline=12: (9B): see region:\naaa\nbbb\nccc\n", "line=12: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 13, npos, 8+2 , 2), "line=13: (10B): ccc\nline=13: (10B): see region:\naaa\nbbb\nccc\n", "line=13: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 14, npos, 8+3 , 2), "line=14: (11B): ccc\nline=14: (11B): see region:\naaa\nbbb\nccc\n", "line=14: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 10, 0 , npos, 2), "line=10 col=0: \nline=10 col=0: see region:\n", "line=10 col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, 0 , 8+0 , 2), "line=11 col=0 (8B): ccc\n |\n (here)\nline=11 col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "line=11 col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 8+1 , 2), "line=12 col=1 (9B): ccc\n |\n (here)\nline=12 col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "line=12 col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 8+2 , 2), "line=13 col=2 (10B): ccc\n |\n (here)\nline=13 col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "line=13 col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 8+3 , 2), "line=14 col=3 (11B): ccc\n |\n (here)\nline=14 col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "line=14 col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 10, npos, npos, 3), "line=10: \nline=10: see region:\n", "line=10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, npos, 8+0 , 3), "line=11: (8B): ccc\nline=11: (8B): see region:\naaa\nbbb\nccc\n", "line=11: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 12, npos, 8+1 , 3), "line=12: (9B): ccc\nline=12: (9B): see region:\naaa\nbbb\nccc\n", "line=12: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 13, npos, 8+2 , 3), "line=13: (10B): ccc\nline=13: (10B): see region:\naaa\nbbb\nccc\n", "line=13: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 14, npos, 8+3 , 3), "line=14: (11B): ccc\nline=14: (11B): see region:\naaa\nbbb\nccc\n", "line=14: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, nullptr, 10, 0 , npos, 3), "line=10 col=0: \nline=10 col=0: see region:\n", "line=10 col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, nullptr, 11, 0 , 8+0 , 3), "line=11 col=0 (8B): ccc\n |\n (here)\nline=11 col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "line=11 col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 12, 1 , 8+1 , 3), "line=12 col=1 (9B): ccc\n |\n (here)\nline=12 col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "line=12 col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 13, 2 , 8+2 , 3), "line=13 col=2 (10B): ccc\n |\n (here)\nline=13 col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "line=13 col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, nullptr, 14, 3 , 8+3 , 3), "line=14 col=3 (11B): ccc\n |\n (here)\nline=14 col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "line=14 col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + // + // src file line col offset + mkmsg((txt, "file.yml", npos, npos, npos), "file.yml: \n", "file.yml: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", npos, npos, 0), "file.yml: (0B): aaa\n", "file.yml: (0B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", npos, npos, 1), "file.yml: (1B): aaa\n", "file.yml: (1B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", npos, npos, 2), "file.yml: (2B): aaa\n", "file.yml: (2B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", npos, npos, 3), "file.yml: (3B): aaa\n", "file.yml: (3B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", npos, 0 , npos), "file.yml: col=0: \n", "file.yml: col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", npos, 0 , 0), "file.yml: col=0 (0B): aaa\n |\n (here)\n", "file.yml: col=0 (0B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 1), "file.yml: col=1 (1B): aaa\n |\n (here)\n", "file.yml: col=1 (1B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 2), "file.yml: col=2 (2B): aaa\n |\n (here)\n", "file.yml: col=2 (2B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 3), "file.yml: col=3 (3B): aaa\n |\n (here)\n", "file.yml: col=3 (3B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos), "file.yml: \n", "file.yml: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", npos, npos, 4+0), "file.yml: (4B): bbb\n", "file.yml: (4B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+1), "file.yml: (5B): bbb\n", "file.yml: (5B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+2), "file.yml: (6B): bbb\n", "file.yml: (6B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+3), "file.yml: (7B): bbb\n", "file.yml: (7B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, 0 , 4+0), "file.yml: col=0 (4B): bbb\n |\n (here)\n", "file.yml: col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 0 , 4+1), "file.yml: col=0 (5B): bbb\n |\n (here)\n", "file.yml: col=0 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 4+1), "file.yml: col=1 (5B): bbb\n |\n (here)\n", "file.yml: col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 4+2), "file.yml: col=2 (6B): bbb\n |\n (here)\n", "file.yml: col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 4+3), "file.yml: col=3 (7B): bbb\n |\n (here)\n", "file.yml: col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos, 1), "file.yml: \nfile.yml: see region:\n", "file.yml: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, npos, 4+0 , 1), "file.yml: (4B): bbb\nfile.yml: (4B): see region:\naaa\nbbb\n", "file.yml: (4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+1 , 1), "file.yml: (5B): bbb\nfile.yml: (5B): see region:\naaa\nbbb\n", "file.yml: (5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+2 , 1), "file.yml: (6B): bbb\nfile.yml: (6B): see region:\naaa\nbbb\n", "file.yml: (6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+3 , 1), "file.yml: (7B): bbb\nfile.yml: (7B): see region:\naaa\nbbb\n", "file.yml: (7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, 0 , npos, 1), "file.yml: col=0: \nfile.yml: col=0: see region:\n", "file.yml: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, 0 , 4+0 , 1), "file.yml: col=0 (4B): bbb\n |\n (here)\nfile.yml: col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "file.yml: col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 4+1 , 1), "file.yml: col=1 (5B): bbb\n |\n (here)\nfile.yml: col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml: col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 4+2 , 1), "file.yml: col=2 (6B): bbb\n |\n (here)\nfile.yml: col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml: col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 4+3 , 1), "file.yml: col=3 (7B): bbb\n |\n (here)\nfile.yml: col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml: col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos, 2), "file.yml: \nfile.yml: see region:\n", "file.yml: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, npos, 4+0 , 2), "file.yml: (4B): bbb\nfile.yml: (4B): see region:\naaa\nbbb\n", "file.yml: (4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+1 , 2), "file.yml: (5B): bbb\nfile.yml: (5B): see region:\naaa\nbbb\n", "file.yml: (5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+2 , 2), "file.yml: (6B): bbb\nfile.yml: (6B): see region:\naaa\nbbb\n", "file.yml: (6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, npos, 4+3 , 2), "file.yml: (7B): bbb\nfile.yml: (7B): see region:\naaa\nbbb\n", "file.yml: (7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", npos, 0 , npos, 2), "file.yml: col=0: \nfile.yml: col=0: see region:\n", "file.yml: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, 0 , 4+0 , 2), "file.yml: col=0 (4B): bbb\n |\n (here)\nfile.yml: col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "file.yml: col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 4+1 , 2), "file.yml: col=1 (5B): bbb\n |\n (here)\nfile.yml: col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml: col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 4+2 , 2), "file.yml: col=2 (6B): bbb\n |\n (here)\nfile.yml: col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml: col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 4+3 , 2), "file.yml: col=3 (7B): bbb\n |\n (here)\nfile.yml: col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml: col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos), "file.yml: \n", "file.yml: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", npos, npos, 8+0), "file.yml: (8B): ccc\n", "file.yml: (8B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+1), "file.yml: (9B): ccc\n", "file.yml: (9B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+2), "file.yml: (10B): ccc\n", "file.yml: (10B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+3), "file.yml: (11B): ccc\n", "file.yml: (11B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, 0 , npos), "file.yml: col=0: \n", "file.yml: col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", npos, 0 , 8+0), "file.yml: col=0 (8B): ccc\n |\n (here)\n", "file.yml: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 8+1), "file.yml: col=1 (9B): ccc\n |\n (here)\n", "file.yml: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 8+2), "file.yml: col=2 (10B): ccc\n |\n (here)\n", "file.yml: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 8+3), "file.yml: col=3 (11B): ccc\n |\n (here)\n", "file.yml: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos, 1), "file.yml: \nfile.yml: see region:\n", "file.yml: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, npos, 8+0 , 1), "file.yml: (8B): ccc\nfile.yml: (8B): see region:\nbbb\nccc\n", "file.yml: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+1 , 1), "file.yml: (9B): ccc\nfile.yml: (9B): see region:\nbbb\nccc\n", "file.yml: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+2 , 1), "file.yml: (10B): ccc\nfile.yml: (10B): see region:\nbbb\nccc\n", "file.yml: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+3 , 1), "file.yml: (11B): ccc\nfile.yml: (11B): see region:\nbbb\nccc\n", "file.yml: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, 0 , npos, 1), "file.yml: col=0: \nfile.yml: col=0: see region:\n", "file.yml: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, 0 , 8+0 , 1), "file.yml: col=0 (8B): ccc\n |\n (here)\nfile.yml: col=0 (8B): see region:\nbbb\nccc\n|\n(here)\n", "file.yml: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 8+1 , 1), "file.yml: col=1 (9B): ccc\n |\n (here)\nfile.yml: col=1 (9B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 8+2 , 1), "file.yml: col=2 (10B): ccc\n |\n (here)\nfile.yml: col=2 (10B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 8+3 , 1), "file.yml: col=3 (11B): ccc\n |\n (here)\nfile.yml: col=3 (11B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos, 2), "file.yml: \nfile.yml: see region:\n", "file.yml: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, npos, 8+0 , 2), "file.yml: (8B): ccc\nfile.yml: (8B): see region:\naaa\nbbb\nccc\n", "file.yml: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+1 , 2), "file.yml: (9B): ccc\nfile.yml: (9B): see region:\naaa\nbbb\nccc\n", "file.yml: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+2 , 2), "file.yml: (10B): ccc\nfile.yml: (10B): see region:\naaa\nbbb\nccc\n", "file.yml: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+3 , 2), "file.yml: (11B): ccc\nfile.yml: (11B): see region:\naaa\nbbb\nccc\n", "file.yml: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, 0 , npos, 2), "file.yml: col=0: \nfile.yml: col=0: see region:\n", "file.yml: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, 0 , 8+0 , 2), "file.yml: col=0 (8B): ccc\n |\n (here)\nfile.yml: col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "file.yml: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 8+1 , 2), "file.yml: col=1 (9B): ccc\n |\n (here)\nfile.yml: col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 8+2 , 2), "file.yml: col=2 (10B): ccc\n |\n (here)\nfile.yml: col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 8+3 , 2), "file.yml: col=3 (11B): ccc\n |\n (here)\nfile.yml: col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, npos, npos, 3), "file.yml: \nfile.yml: see region:\n", "file.yml: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, npos, 8+0 , 3), "file.yml: (8B): ccc\nfile.yml: (8B): see region:\naaa\nbbb\nccc\n", "file.yml: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+1 , 3), "file.yml: (9B): ccc\nfile.yml: (9B): see region:\naaa\nbbb\nccc\n", "file.yml: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+2 , 3), "file.yml: (10B): ccc\nfile.yml: (10B): see region:\naaa\nbbb\nccc\n", "file.yml: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, npos, 8+3 , 3), "file.yml: (11B): ccc\nfile.yml: (11B): see region:\naaa\nbbb\nccc\n", "file.yml: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", npos, 0 , npos, 3), "file.yml: col=0: \nfile.yml: col=0: see region:\n", "file.yml: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", npos, 0 , 8+0 , 3), "file.yml: col=0 (8B): ccc\n |\n (here)\nfile.yml: col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "file.yml: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 1 , 8+1 , 3), "file.yml: col=1 (9B): ccc\n |\n (here)\nfile.yml: col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 2 , 8+2 , 3), "file.yml: col=2 (10B): ccc\n |\n (here)\nfile.yml: col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", npos, 3 , 8+3 , 3), "file.yml: col=3 (11B): ccc\n |\n (here)\nfile.yml: col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + // + // src file line col offset + mkmsg((txt, "file.yml", 10, npos, npos), "file.yml:10: \n", "file.yml:10: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", 11, npos, 0), "file.yml:11: (0B): aaa\n", "file.yml:11: (0B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", 12, npos, 1), "file.yml:12: (1B): aaa\n", "file.yml:12: (1B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", 13, npos, 2), "file.yml:13: (2B): aaa\n", "file.yml:13: (2B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", 14, npos, 3), "file.yml:14: (3B): aaa\n", "file.yml:14: (3B): error:\nerror:\nerror: aaa\n"); + mkmsg((txt, "file.yml", 10, 0 , npos), "file.yml:10: col=0: \n", "file.yml:10: col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", 11, 0 , 0), "file.yml:11: col=0 (0B): aaa\n |\n (here)\n", "file.yml:11: col=0 (0B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 1), "file.yml:12: col=1 (1B): aaa\n |\n (here)\n", "file.yml:12: col=1 (1B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 2), "file.yml:13: col=2 (2B): aaa\n |\n (here)\n", "file.yml:13: col=2 (2B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 3), "file.yml:14: col=3 (3B): aaa\n |\n (here)\n", "file.yml:14: col=3 (3B): error:\nerror:\nerror: aaa\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 0, 0, 0, 0, 2), "file.yml:11: col=0 (0B): aaa\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:11: col=0 (0B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 1, 0, 0, 0, 2), "file.yml:12: col=1 (1B): aaa\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:12: col=1 (1B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 2, 0, 0, 0, 2), "file.yml:13: col=2 (2B): aaa\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:13: col=2 (2B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 3, 0, 0, 0, 2), "file.yml:14: col=3 (3B): aaa\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:14: col=3 (3B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 0, 0, 0, 1, 3), "file.yml:11: col=0 (0B): aaa\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:11: col=0 (0B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 1, 0, 0, 1, 3), "file.yml:12: col=1 (1B): aaa\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:12: col=1 (1B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 2, 0, 0, 1, 3), "file.yml:13: col=2 (2B): aaa\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:13: col=2 (2B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 3, 0, 0, 1, 3), "file.yml:14: col=3 (3B): aaa\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:14: col=3 (3B): error:\nerror:\nerror: aaa\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 0, 0, 0, 0, 3), "file.yml:11: col=0 (0B): aaa\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:11: col=0 (0B): error:\nerror:\nerror: aaa\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 1, 0, 0, 0, 3), "file.yml:12: col=1 (1B): aaa\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:12: col=1 (1B): error:\nerror:\nerror: aaa\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 2, 0, 0, 0, 3), "file.yml:13: col=2 (2B): aaa\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:13: col=2 (2B): error:\nerror:\nerror: aaa\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 3, 0, 0, 0, 3), "file.yml:14: col=3 (3B): aaa\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:14: col=3 (3B): error:\nerror:\nerror: aaa\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos), "file.yml:10: \n", "file.yml:10: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", 11, npos, 4+0), "file.yml:11: (4B): bbb\n", "file.yml:11: (4B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", 12, npos, 4+1), "file.yml:12: (5B): bbb\n", "file.yml:12: (5B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", 13, npos, 4+2), "file.yml:13: (6B): bbb\n", "file.yml:13: (6B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", 14, npos, 4+3), "file.yml:14: (7B): bbb\n", "file.yml:14: (7B): error:\nerror:\nerror: bbb\n"); + mkmsg((txt, "file.yml", 10, 0 , 4+0), "file.yml:10: col=0 (4B): bbb\n |\n (here)\n", "file.yml:10: col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 0 , 4+1), "file.yml:12: col=0 (5B): bbb\n |\n (here)\n", "file.yml:12: col=0 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1), "file.yml:12: col=1 (5B): bbb\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2), "file.yml:13: col=2 (6B): bbb\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3), "file.yml:14: col=3 (7B): bbb\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, 0 , 4+0, 0, 0, 0, 2), "file.yml:10: col=0 (4B): bbb\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:10: col=0 (4B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 0 , 4+1, 0, 0, 0, 2), "file.yml:12: col=0 (5B): bbb\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:12: col=0 (5B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1, 0, 0, 0, 2), "file.yml:12: col=1 (5B): bbb\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2, 0, 0, 0, 2), "file.yml:13: col=2 (6B): bbb\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3, 0, 0, 0, 2), "file.yml:14: col=3 (7B): bbb\n ~~ (cols 0-2/3)\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 0-2/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, 0 , 4+0, 0, 0, 1, 3), "file.yml:10: col=0 (4B): bbb\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:10: col=0 (4B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 0 , 4+1, 0, 0, 1, 3), "file.yml:12: col=0 (5B): bbb\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:12: col=0 (5B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1, 0, 0, 1, 3), "file.yml:12: col=1 (5B): bbb\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2, 0, 0, 1, 3), "file.yml:13: col=2 (6B): bbb\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3, 0, 0, 1, 3), "file.yml:14: col=3 (7B): bbb\n ~~ (cols 1-3/3)\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: ~~ (cols 1-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, 0 , 4+0, 0, 0, 0, 3), "file.yml:10: col=0 (4B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:10: col=0 (4B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 0 , 4+1, 0, 0, 0, 3), "file.yml:12: col=0 (5B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:12: col=0 (5B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1, 0, 0, 0, 3), "file.yml:12: col=1 (5B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2, 0, 0, 0, 3), "file.yml:13: col=2 (6B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3, 0, 0, 0, 3), "file.yml:14: col=3 (7B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos, 1), "file.yml:10: \nfile.yml:10: see region:\n", "file.yml:10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, npos, 4+0 , 1), "file.yml:11: (4B): bbb\nfile.yml:11: (4B): see region:\naaa\nbbb\n", "file.yml:11: (4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 12, npos, 4+1 , 1), "file.yml:12: (5B): bbb\nfile.yml:12: (5B): see region:\naaa\nbbb\n", "file.yml:12: (5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 13, npos, 4+2 , 1), "file.yml:13: (6B): bbb\nfile.yml:13: (6B): see region:\naaa\nbbb\n", "file.yml:13: (6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 14, npos, 4+3 , 1), "file.yml:14: (7B): bbb\nfile.yml:14: (7B): see region:\naaa\nbbb\n", "file.yml:14: (7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 10, 0 , npos, 1), "file.yml:10: col=0: \nfile.yml:10: col=0: see region:\n", "file.yml:10: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, 0 , 4+0 , 1), "file.yml:11: col=0 (4B): bbb\n |\n (here)\nfile.yml:11: col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "file.yml:11: col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1 , 1), "file.yml:12: col=1 (5B): bbb\n |\n (here)\nfile.yml:12: col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2 , 1), "file.yml:13: col=2 (6B): bbb\n |\n (here)\nfile.yml:13: col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3 , 1), "file.yml:14: col=3 (7B): bbb\n |\n (here)\nfile.yml:14: col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 4+0 , 1, 0, 0, 3), "file.yml:11: col=0 (4B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:11: col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "file.yml:11: col=0 (4B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1 , 1, 0, 0, 3), "file.yml:12: col=1 (5B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:12: col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2 , 1, 0, 0, 3), "file.yml:13: col=2 (6B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:13: col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3 , 1, 0, 0, 3), "file.yml:14: col=3 (7B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:14: col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos, 2), "file.yml:10: \nfile.yml:10: see region:\n", "file.yml:10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, npos, 4+0 , 2), "file.yml:11: (4B): bbb\nfile.yml:11: (4B): see region:\naaa\nbbb\n", "file.yml:11: (4B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 12, npos, 4+1 , 2), "file.yml:12: (5B): bbb\nfile.yml:12: (5B): see region:\naaa\nbbb\n", "file.yml:12: (5B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 13, npos, 4+2 , 2), "file.yml:13: (6B): bbb\nfile.yml:13: (6B): see region:\naaa\nbbb\n", "file.yml:13: (6B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 14, npos, 4+3 , 2), "file.yml:14: (7B): bbb\nfile.yml:14: (7B): see region:\naaa\nbbb\n", "file.yml:14: (7B): error:\nerror:\nerror: bbb\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\n"); + mkmsg((txt, "file.yml", 10, 0 , npos, 2), "file.yml:10: col=0: \nfile.yml:10: col=0: see region:\n", "file.yml:10: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, 0 , 4+0 , 2), "file.yml:11: col=0 (4B): bbb\n |\n (here)\nfile.yml:11: col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "file.yml:11: col=0 (4B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1 , 2), "file.yml:12: col=1 (5B): bbb\n |\n (here)\nfile.yml:12: col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2 , 2), "file.yml:13: col=2 (6B): bbb\n |\n (here)\nfile.yml:13: col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3 , 2), "file.yml:14: col=3 (7B): bbb\n |\n (here)\nfile.yml:14: col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 4+0 , 2, 0, 0, 3), "file.yml:11: col=0 (4B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:11: col=0 (4B): see region:\naaa\nbbb\n|\n(here)\n", "file.yml:11: col=0 (4B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 4+1 , 2, 0, 0, 3), "file.yml:12: col=1 (5B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:12: col=1 (5B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:12: col=1 (5B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 4+2 , 2, 0, 0, 3), "file.yml:13: col=2 (6B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:13: col=2 (6B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:13: col=2 (6B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 4+3 , 2, 0, 0, 3), "file.yml:14: col=3 (7B): bbb\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:14: col=3 (7B): see region:\naaa\nbbb\n |\n (here)\n", "file.yml:14: col=3 (7B): error:\nerror:\nerror: bbb\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos), "file.yml:10: \n", "file.yml:10: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", 11, npos, 8+0), "file.yml:11: (8B): ccc\n", "file.yml:11: (8B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", 12, npos, 8+1), "file.yml:12: (9B): ccc\n", "file.yml:12: (9B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", 13, npos, 8+2), "file.yml:13: (10B): ccc\n", "file.yml:13: (10B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", 14, npos, 8+3), "file.yml:14: (11B): ccc\n", "file.yml:14: (11B): error:\nerror:\nerror: ccc\n"); + mkmsg((txt, "file.yml", 10, 0 , npos), "file.yml:10: col=0: \n", "file.yml:10: col=0: error:\nerror:\nerror: \n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0), "file.yml:11: col=0 (8B): ccc\n |\n (here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1), "file.yml:12: col=1 (9B): ccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2), "file.yml:13: col=2 (10B): ccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3), "file.yml:14: col=3 (11B): ccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos, 1), "file.yml:10: \nfile.yml:10: see region:\n", "file.yml:10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, npos, 8+0 , 1), "file.yml:11: (8B): ccc\nfile.yml:11: (8B): see region:\nbbb\nccc\n", "file.yml:11: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 12, npos, 8+1 , 1), "file.yml:12: (9B): ccc\nfile.yml:12: (9B): see region:\nbbb\nccc\n", "file.yml:12: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 13, npos, 8+2 , 1), "file.yml:13: (10B): ccc\nfile.yml:13: (10B): see region:\nbbb\nccc\n", "file.yml:13: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 14, npos, 8+3 , 1), "file.yml:14: (11B): ccc\nfile.yml:14: (11B): see region:\nbbb\nccc\n", "file.yml:14: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 10, 0 , npos, 1), "file.yml:10: col=0: \nfile.yml:10: col=0: see region:\n", "file.yml:10: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0 , 1), "file.yml:11: col=0 (8B): ccc\n |\n (here)\nfile.yml:11: col=0 (8B): see region:\nbbb\nccc\n|\n(here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1 , 1), "file.yml:12: col=1 (9B): ccc\n |\n (here)\nfile.yml:12: col=1 (9B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2 , 1), "file.yml:13: col=2 (10B): ccc\n |\n (here)\nfile.yml:13: col=2 (10B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3 , 1), "file.yml:14: col=3 (11B): ccc\n |\n (here)\nfile.yml:14: col=3 (11B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0 , 1, 0, 0, 3), "file.yml:11: col=0 (8B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:11: col=0 (8B): see region:\nbbb\nccc\n|\n(here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1 , 1, 0, 0, 3), "file.yml:12: col=1 (9B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:12: col=1 (9B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2 , 1, 0, 0, 3), "file.yml:13: col=2 (10B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:13: col=2 (10B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3 , 1, 0, 0, 3), "file.yml:14: col=3 (11B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:14: col=3 (11B): see region:\nbbb\nccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos, 2), "file.yml:10: \nfile.yml:10: see region:\n", "file.yml:10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, npos, 8+0 , 2), "file.yml:11: (8B): ccc\nfile.yml:11: (8B): see region:\naaa\nbbb\nccc\n", "file.yml:11: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 12, npos, 8+1 , 2), "file.yml:12: (9B): ccc\nfile.yml:12: (9B): see region:\naaa\nbbb\nccc\n", "file.yml:12: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 13, npos, 8+2 , 2), "file.yml:13: (10B): ccc\nfile.yml:13: (10B): see region:\naaa\nbbb\nccc\n", "file.yml:13: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 14, npos, 8+3 , 2), "file.yml:14: (11B): ccc\nfile.yml:14: (11B): see region:\naaa\nbbb\nccc\n", "file.yml:14: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 10, 0 , npos, 2), "file.yml:10: col=0: \nfile.yml:10: col=0: see region:\n", "file.yml:10: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0 , 2), "file.yml:11: col=0 (8B): ccc\n |\n (here)\nfile.yml:11: col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1 , 2), "file.yml:12: col=1 (9B): ccc\n |\n (here)\nfile.yml:12: col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2 , 2), "file.yml:13: col=2 (10B): ccc\n |\n (here)\nfile.yml:13: col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3 , 2), "file.yml:14: col=3 (11B): ccc\n |\n (here)\nfile.yml:14: col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0 , 2, 0, 0, 3), "file.yml:11: col=0 (8B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:11: col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1 , 2, 0, 0, 3), "file.yml:12: col=1 (9B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:12: col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2 , 2, 0, 0, 3), "file.yml:13: col=2 (10B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:13: col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3 , 2, 0, 0, 3), "file.yml:14: col=3 (11B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:14: col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 10, npos, npos, 3), "file.yml:10: \nfile.yml:10: see region:\n", "file.yml:10: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, npos, 8+0 , 3), "file.yml:11: (8B): ccc\nfile.yml:11: (8B): see region:\naaa\nbbb\nccc\n", "file.yml:11: (8B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 12, npos, 8+1 , 3), "file.yml:12: (9B): ccc\nfile.yml:12: (9B): see region:\naaa\nbbb\nccc\n", "file.yml:12: (9B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 13, npos, 8+2 , 3), "file.yml:13: (10B): ccc\nfile.yml:13: (10B): see region:\naaa\nbbb\nccc\n", "file.yml:13: (10B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 14, npos, 8+3 , 3), "file.yml:14: (11B): ccc\nfile.yml:14: (11B): see region:\naaa\nbbb\nccc\n", "file.yml:14: (11B): error:\nerror:\nerror: ccc\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\n"); + mkmsg((txt, "file.yml", 10, 0 , npos, 3), "file.yml:10: col=0: \nfile.yml:10: col=0: see region:\n", "file.yml:10: col=0: error:\nerror:\nerror: \nerror:\nerror: see region:\nerror:\n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0 , 3), "file.yml:11: col=0 (8B): ccc\n |\n (here)\nfile.yml:11: col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1 , 3), "file.yml:12: col=1 (9B): ccc\n |\n (here)\nfile.yml:12: col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2 , 3), "file.yml:13: col=2 (10B): ccc\n |\n (here)\nfile.yml:13: col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3 , 3), "file.yml:14: col=3 (11B): ccc\n |\n (here)\nfile.yml:14: col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 11, 0 , 8+0 , 3, 0, 0, 3), "file.yml:11: col=0 (8B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:11: col=0 (8B): see region:\naaa\nbbb\nccc\n|\n(here)\n", "file.yml:11: col=0 (8B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 12, 1 , 8+1 , 3, 0, 0, 3), "file.yml:12: col=1 (9B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:12: col=1 (9B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:12: col=1 (9B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 13, 2 , 8+2 , 3, 0, 0, 3), "file.yml:13: col=2 (10B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:13: col=2 (10B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:13: col=2 (10B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 14, 3 , 8+3 , 3, 0, 0, 3), "file.yml:14: col=3 (11B): ccc\n ~~~ (cols 0-3/3)\n |\n (here)\nfile.yml:14: col=3 (11B): see region:\naaa\nbbb\nccc\n |\n (here)\n", "file.yml:14: col=3 (11B): error:\nerror:\nerror: ccc\nerror: ~~~ (cols 0-3/3)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: aaa\nerror: bbb\nerror: ccc\nerror: |\nerror: (here)\n"); + + txt = R"( +0123456789112345678921234567893123456789412345678951234567896123456789 +0a234567891a234567892a234567893a234567894a234567895a234567896a23456789 +)"; + // line offset + // | col | linesbefore + // | | | | linesafter + // | | | | | hlfirstcol + // | | | | | | hllastcol + // | | | | | | | maxlen + // | | | | | | | | + mkmsg((txt, "file.yml", 2, 3, 73, 0, 0, 0, 0, 20), "file.yml:2: col=3 (73B): 0a234567891a23456789[...] (showing columns 0-20/70)\n |\n (here)\n", "file.yml:2: col=3 (73B): error:\nerror:\nerror: 0a234567891a23456789[...] (showing columns 0-20/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 2, 23, 93, 0, 0, 0, 0, 30), "file.yml:2: col=23 (93B): 0a234567891a234567892a23456789[...] (showing columns 0-30/70)\n |\n (here)\n", "file.yml:2: col=23 (93B): error:\nerror:\nerror: 0a234567891a234567892a23456789[...] (showing columns 0-30/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 2, 23, 93, 0, 0, 0, 0, 20), "file.yml:2: col=23 (93B): [...]4567891a234567892a23[...] (showing columns 4-24/70)\n |\n (here)\n", "file.yml:2: col=23 (93B): error:\nerror:\nerror: [...]4567891a234567892a23[...] (showing columns 4-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 2, 23, 93, 0, 0, 0, 0, 15), "file.yml:2: col=23 (93B): [...]91a234567892a23[...] (showing columns 9-24/70)\n |\n (here)\n", "file.yml:2: col=23 (93B): error:\nerror:\nerror: [...]91a234567892a23[...] (showing columns 9-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 2, 23, 93, 0, 0, 0, 0, 10), "file.yml:2: col=23 (93B): [...]4567892a23[...] (showing columns 14-24/70)\n |\n (here)\n", "file.yml:2: col=23 (93B): error:\nerror:\nerror: [...]4567892a23[...] (showing columns 14-24/70)\nerror: |\nerror: (here)\n"); + + txt = R"( +..........++++++++++0123456789 +..........0123456789 +0123456789 +0a234567891a234567892a234567893a234567894a234567895a234567896a23456789 +)"; + // line offset + // | col | linesbefore + // | | | | linesafter + // | | | | | hlfirstcol + // | | | | | | hllastcol + // | | | | | | | maxlen + // | | | | | | | | + mkmsg((txt, "file.yml", 4, 3, 67, 3, 0, 0, 0, 20), "file.yml:4: col=3 (67B): 0a234567891a23456789[...] (showing columns 0-20/70)\n |\n (here)\nfile.yml:4: col=3 (67B): see region:\n..........++++++++++[...] (showing columns 0-20/30)\n..........0123456789\n0123456789\n0a234567891a23456789[...] (showing columns 0-20/70)\n |\n (here)\n", "file.yml:4: col=3 (67B): error:\nerror:\nerror: 0a234567891a23456789[...] (showing columns 0-20/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: ..........++++++++++[...] (showing columns 0-20/30)\nerror: ..........0123456789\nerror: 0123456789\nerror: 0a234567891a23456789[...] (showing columns 0-20/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 30), "file.yml:4: col=23 (87B): 0a234567891a234567892a23456789[...] (showing columns 0-30/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n..........++++++++++0123456789\n..........0123456789\n0123456789\n0a234567891a234567892a23456789[...] (showing columns 0-30/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: 0a234567891a234567892a23456789[...] (showing columns 0-30/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: ..........++++++++++0123456789\nerror: ..........0123456789\nerror: 0123456789\nerror: 0a234567891a234567892a23456789[...] (showing columns 0-30/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 20), "file.yml:4: col=23 (87B): [...]4567891a234567892a23[...] (showing columns 4-24/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n[...]......++++++++++0123[...] (showing columns 4-24/30)\n[...]......0123456789 (showing columns 4-20/20)\n[...]456789 (showing columns 4-10/10)\n[...]4567891a234567892a23[...] (showing columns 4-24/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: [...]4567891a234567892a23[...] (showing columns 4-24/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: [...]......++++++++++0123[...] (showing columns 4-24/30)\nerror: [...]......0123456789 (showing columns 4-20/20)\nerror: [...]456789 (showing columns 4-10/10)\nerror: [...]4567891a234567892a23[...] (showing columns 4-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 17), "file.yml:4: col=23 (87B): [...]7891a234567892a23[...] (showing columns 7-24/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n[...]...++++++++++0123[...] (showing columns 7-24/30)\n[...]...0123456789 (showing columns 7-20/20)\n[...]789 (showing columns 7-10/10)\n[...]7891a234567892a23[...] (showing columns 7-24/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: [...]7891a234567892a23[...] (showing columns 7-24/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: [...]...++++++++++0123[...] (showing columns 7-24/30)\nerror: [...]...0123456789 (showing columns 7-20/20)\nerror: [...]789 (showing columns 7-10/10)\nerror: [...]7891a234567892a23[...] (showing columns 7-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 16), "file.yml:4: col=23 (87B): [...]891a234567892a23[...] (showing columns 8-24/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n[...]..++++++++++0123[...] (showing columns 8-24/30)\n[...]..0123456789 (showing columns 8-20/20)\n[...]89 (showing columns 8-10/10)\n[...]891a234567892a23[...] (showing columns 8-24/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: [...]891a234567892a23[...] (showing columns 8-24/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: [...]..++++++++++0123[...] (showing columns 8-24/30)\nerror: [...]..0123456789 (showing columns 8-20/20)\nerror: [...]89 (showing columns 8-10/10)\nerror: [...]891a234567892a23[...] (showing columns 8-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 15), "file.yml:4: col=23 (87B): [...]91a234567892a23[...] (showing columns 9-24/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n[...].++++++++++0123[...] (showing columns 9-24/30)\n[...].0123456789 (showing columns 9-20/20)\n[...]9 (showing columns 9-10/10)\n[...]91a234567892a23[...] (showing columns 9-24/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: [...]91a234567892a23[...] (showing columns 9-24/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: [...].++++++++++0123[...] (showing columns 9-24/30)\nerror: [...].0123456789 (showing columns 9-20/20)\nerror: [...]9 (showing columns 9-10/10)\nerror: [...]91a234567892a23[...] (showing columns 9-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 10), "file.yml:4: col=23 (87B): [...]4567892a23[...] (showing columns 14-24/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n[...]++++++0123[...] (showing columns 14-24/30)\n[...]456789 (showing columns 14-20/20)\n[...] (not showing, columns=10)\n[...]4567892a23[...] (showing columns 14-24/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: [...]4567892a23[...] (showing columns 14-24/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: [...]++++++0123[...] (showing columns 14-24/30)\nerror: [...]456789 (showing columns 14-20/20)\nerror: [...] (not showing, columns=10)\nerror: [...]4567892a23[...] (showing columns 14-24/70)\nerror: |\nerror: (here)\n"); + mkmsg((txt, "file.yml", 4, 23, 87, 3, 0, 0, 0, 5), "file.yml:4: col=23 (87B): [...]92a23[...] (showing columns 19-24/70)\n |\n (here)\nfile.yml:4: col=23 (87B): see region:\n[...]+0123[...] (showing columns 19-24/30)\n[...]9 (showing columns 19-20/20)\n[...] (not showing, columns=10)\n[...]92a23[...] (showing columns 19-24/70)\n |\n (here)\n", "file.yml:4: col=23 (87B): error:\nerror:\nerror: [...]92a23[...] (showing columns 19-24/70)\nerror: |\nerror: (here)\nerror:\nerror: see region:\nerror:\nerror: [...]+0123[...] (showing columns 19-24/30)\nerror: [...]9 (showing columns 19-20/20)\nerror: [...] (not showing, columns=10)\nerror: [...]92a23[...] (showing columns 19-24/70)\nerror: |\nerror: (here)\n"); } // FIXME this is here merely to avoid a linker error @@ -474,3 +2044,5 @@ Case const* get_case(csubstr) } // namespace yml } // namespace c4 + +C4_SUPPRESS_WARNING_MSVC_POP diff --git a/test/test_doc.cpp b/test/test_doc.cpp index d9358a2d..383bfe3e 100644 --- a/test/test_doc.cpp +++ b/test/test_doc.cpp @@ -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) ); diff --git a/test/test_emit.cpp b/test/test_emit.cpp index 80690d09..c774a2f1 100644 --- a/test/test_emit.cpp +++ b/test/test_emit.cpp @@ -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(t, id, opts); }); - ExpectError::check_error(&t, [&]{ return emitrs_json(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(t, id, opts); }); + ExpectError::check_error_basic(&t, [&]{ return emitrs_json(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(t, opts); }); - ExpectError::check_error(&t, [&]{ return emitrs_json(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(t, opts); }); + ExpectError::check_error_basic(&t, [&]{ return emitrs_json(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(n, opts); }); - ExpectError::check_error(n.tree(), [&]{ return emitrs_json(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(n, opts); }); + ExpectError::check_error_basic(n.tree(), [&]{ return emitrs_json(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); diff --git a/test/test_explicit_key.cpp b/test/test_explicit_key.cpp index dfd902e2..c4237bed 100644 --- a/test/test_explicit_key.cpp +++ b/test/test_explicit_key.cpp @@ -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", diff --git a/test/test_extra_ints.cpp b/test/test_extra_ints.cpp index 8968a0f4..55873f80 100644 --- a/test/test_extra_ints.cpp +++ b/test/test_extra_ints.cpp @@ -2,6 +2,10 @@ #include "test_lib/test_events_ints_helpers.hpp" #include +#ifndef _C4_YML_PARSE_ENGINE_DEF_HPP_ +#include +#endif + // NOLINTBEGIN(hicpp-signed-bitwise) namespace c4 { diff --git a/test/test_filter.cpp b/test/test_filter.cpp index 401a9255..789f5e4c 100644 --- a/test/test_filter.cpp +++ b/test/test_filter.cpp @@ -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" diff --git a/test/test_fuzz/test_fuzz_common.hpp b/test/test_fuzz/test_fuzz_common.hpp index 650253ab..93d5cbf7 100644 --- a/test/test_fuzz/test_fuzz_common.hpp +++ b/test/test_fuzz/test_fuzz_common.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(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; diff --git a/test/test_github_issues.cpp b/test/test_github_issues.cpp index 2f1a270a..39e4a024 100644 --- a/test/test_github_issues.cpp +++ b/test/test_github_issues.cpp @@ -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"); diff --git a/test/test_indentation.cpp b/test/test_indentation.cpp index a63aa303..c67d2591 100644 --- a/test/test_indentation.cpp +++ b/test/test_indentation.cpp @@ -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", diff --git a/test/test_json.cpp b/test/test_json.cpp index 682a50b7..a5fc79b5 100644 --- a/test/test_json.cpp +++ b/test/test_json.cpp @@ -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"); }); } diff --git a/test/test_lib/callbacks_tester.hpp b/test/test_lib/callbacks_tester.hpp index 473fc82d..68bfb849 100644 --- a/test/test_lib/callbacks_tester.hpp +++ b/test/test_lib/callbacks_tester.hpp @@ -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; diff --git a/test/test_lib/test_case.cpp b/test/test_lib/test_case.cpp index 8af34af9..2de2b140 100644 --- a/test/test_lib/test_case.cpp +++ b/test/test_lib/test_case.cpp @@ -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 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 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 fn, Location expected_location) +void ExpectError::check_error_basic(Tree const* tree, fntestref fn) { - check_error(const_cast(tree), fn, expected_location); + check_error_basic(const_cast(tree), fn); } -void ExpectError::check_error(Tree *tree, std::function 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), fn, expected_location); +} + +void ExpectError::check_error_visit(Tree const* tree, fntestref fn, id_type expected_id) +{ + check_error_visit(const_cast(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(e.error_location), static_cast(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(e.errdata.ymlloc), static_cast(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 fn, Location exp EXPECT_TRUE(context.m_got_an_error); } -void ExpectError::check_assertion(Tree *tree, std::function 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 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(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(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(ret); - RYML_ASSERT(pos >= tl); + _RYML_ASSERT_BASIC(pos >= tl); ret = snprintf(buf + static_cast(pos - tl), tl, "/%zu", pos); - RYML_ASSERT(ret >= 0); + _RYML_ASSERT_BASIC(ret >= 0); pos -= static_cast(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); diff --git a/test/test_lib/test_case.hpp b/test/test_lib/test_case.hpp index 730b5658..c5f4b98d 100644 --- a/test/test_lib/test_case.hpp +++ b/test/test_lib/test_case.hpp @@ -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 fn, Location expected={}) { check_error((const Tree*)nullptr, fn, expected); } - static void check_error(Tree *tree, std::function fn, Location expected={}); - static void check_error(Tree const *tree, std::function fn, Location expected={}); - static void check_assertion( std::function fn, Location expected={}) { check_assertion(nullptr, fn, expected); } - static void check_assertion(Tree *tree, std::function fn, Location expected={}); - static void check_success( std::function fn) { check_success(nullptr, fn); }; - static void check_success(Tree *tree, std::function fn); + using fntestref = std::function 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 Case(csubstr file, int line, const char *name_, const char *src_, Args&& ...args) : filelinebuf(catrs(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::forward(args)...), flags(), expected_location() {} - //! create a test case with explicit flags: name, source flags, and expected CaseNode structure - template Case(csubstr file, int line, const char *name_, int f_, const char *src_, Args&& ...args) : filelinebuf(catrs(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::forward(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(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(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(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(file, ':', line)), fileline(to_csubstr(filelinebuf)), name(to_csubstr(name_)), src(to_csubstr(src_)), root(std::move(node)), flags((TestCaseFlags_e)f_), expected_location() {} }; //----------------------------------------------------------------------------- diff --git a/test/test_lib/test_case_node.hpp b/test/test_lib/test_case_node.hpp index 747907f3..dee6e7f3 100644 --- a/test/test_lib/test_case_node.hpp +++ b/test/test_lib/test_case_node.hpp @@ -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 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 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 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(); } diff --git a/test/test_lib/test_engine.cpp b/test/test_lib/test_engine.cpp index f326c6a1..cd842308 100644 --- a/test/test_lib/test_engine.cpp +++ b/test/test_lib/test_engine.cpp @@ -43,7 +43,7 @@ std::vector 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 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 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()); diff --git a/test/test_lib/test_engine.hpp b/test/test_lib/test_engine.hpp index 77fe6cfe..deeb2ecb 100644 --- a/test/test_lib/test_engine.hpp +++ b/test/test_lib/test_engine.hpp @@ -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 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 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 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 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 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 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 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 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 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 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 event_producer; diff --git a/test/test_lib/test_group.cpp b/test/test_lib/test_group.cpp index eca6dfbc..0ab527b2 100644 --- a/test/test_lib/test_group.cpp +++ b/test/test_lib/test_group.cpp @@ -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); diff --git a/test/test_lib/test_group.hpp b/test/test_lib/test_group.hpp index c8ff18bd..a4389465 100644 --- a/test/test_lib/test_group.hpp +++ b/test/test_lib/test_group.hpp @@ -195,8 +195,8 @@ struct CaseAdderGcc4_8 const int line; template - 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(parameters)...); } }; diff --git a/test/test_location.cpp b/test/test_location.cpp index f4f58805..8c859eaa 100644 --- a/test/test_location.cpp +++ b/test/test_location.cpp @@ -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"); diff --git a/test/test_map.cpp b/test/test_map.cpp index 08f56e4d..bc1f68c1 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -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", diff --git a/test/test_noderef.cpp b/test/test_noderef.cpp index f73552b1..31587cf4 100644 --- a/test/test_noderef.cpp +++ b/test/test_noderef.cpp @@ -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); \ }); \ diff --git a/test/test_parser.cpp b/test/test_parser.cpp index 5016956d..d90aab8a 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -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); }); } diff --git a/test/test_scalar_dquoted.cpp b/test/test_scalar_dquoted.cpp index d4e755df..d9e6e535 100644 --- a/test/test_scalar_dquoted.cpp +++ b/test/test_scalar_dquoted.cpp @@ -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 +#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); } diff --git a/test/test_scalar_folded.cpp b/test/test_scalar_folded.cpp index 2d935186..7c2d94ec 100644 --- a/test/test_scalar_folded.cpp +++ b/test/test_scalar_folded.cpp @@ -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"); }); } diff --git a/test/test_scalar_literal.cpp b/test/test_scalar_literal.cpp index ff9fe63f..2a71664d 100644 --- a/test/test_scalar_literal.cpp +++ b/test/test_scalar_literal.cpp @@ -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, diff --git a/test/test_scalar_null.cpp b/test/test_scalar_null.cpp index 5d2c6414..55567cd7 100644 --- a/test/test_scalar_null.cpp +++ b/test/test_scalar_null.cpp @@ -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()); }); } } diff --git a/test/test_scalar_plain.cpp b/test/test_scalar_plain.cpp index 2880652a..fcc615b3 100644 --- a/test/test_scalar_plain.cpp +++ b/test/test_scalar_plain.cpp @@ -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", diff --git a/test/test_scalar_squoted.cpp b/test/test_scalar_squoted.cpp index 93b71f8f..8251b4fd 100644 --- a/test/test_scalar_squoted.cpp +++ b/test/test_scalar_squoted.cpp @@ -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) ); */ diff --git a/test/test_seq.cpp b/test/test_seq.cpp index 3f1e6441..99f2261f 100644 --- a/test/test_seq.cpp +++ b/test/test_seq.cpp @@ -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", diff --git a/test/test_serialize.cpp b/test/test_serialize.cpp index 867fe9c7..78d56b55 100644 --- a/test/test_serialize.cpp +++ b/test/test_serialize.cpp @@ -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; }); diff --git a/test/test_tag_property.cpp b/test/test_tag_property.cpp index 5621262c..46b5c25c 100644 --- a/test/test_tag_property.cpp +++ b/test/test_tag_property.cpp @@ -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" diff --git a/test/test_tree.cpp b/test/test_tree.cpp index a4880633..1bcb6e64 100644 --- a/test/test_tree.cpp +++ b/test/test_tree.cpp @@ -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 void verify_assertion_(Tree &tree, Function &&fn) { - ExpectError::check_assertion(&tree, [&]{ + ExpectError::check_assert_basic(&tree, [&]{ (void)fn(tree); }); } @@ -1074,7 +1077,7 @@ template 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 void verify_error_(Tree &tree, Function &&fn) { - ExpectError::check_error(&tree, [&]{ + ExpectError::check_error_basic(&tree, [&]{ (void)fn(tree); }); } @@ -1090,7 +1093,7 @@ template 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(); diff --git a/test/testsuite.cpp b/test/testsuite.cpp index 333e08d9..244cb69a 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -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(case_dir, '/', to_csubstr(input_file)); @@ -990,70 +990,70 @@ struct which : public ::testing::TestWithParam \ 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()); \ } \ \ diff --git a/test/testsuite/testsuite_events.cpp b/test/testsuite/testsuite_events.cpp index 4f7c3d7c..3aacf93c 100644 --- a/test/testsuite/testsuite_events.cpp +++ b/test/testsuite/testsuite_events.cpp @@ -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) diff --git a/test/testsuite/testsuite_parts.cpp b/test/testsuite/testsuite_parts.cpp index 522f53c2..99087df3 100644 --- a/test/testsuite/testsuite_parts.cpp +++ b/test/testsuite/testsuite_parts.cpp @@ -181,7 +181,7 @@ cspan 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; diff --git a/test/testsuite/testsuite_parts.hpp b/test/testsuite/testsuite_parts.hpp index d45337bb..300d370f 100644 --- a/test/testsuite/testsuite_parts.hpp +++ b/test/testsuite/testsuite_parts.hpp @@ -5,6 +5,7 @@ #include #else #include +#include #include #endif #include