Skip to content

Commit

Permalink
do not use std::string in the event handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed May 26, 2024
1 parent 0e9c853 commit da08c32
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 177 deletions.
4 changes: 2 additions & 2 deletions test/test_lib/test_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ void test_new_parser_events_from_yaml(ReferenceYaml const& yaml, std::string con
ParseEngine<EventHandlerYamlStd> parser(&handler);
std::string copy = yaml.parsed;
parser.parse_in_place_ev("(testyaml)", to_substr(copy));
csubstr result = sink.get();
_c4dbgpf("~~~\n{}~~~\n", sink.get());
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), expected_events);
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_lib/test_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ C4_NO_INLINE void test_new_parser_str_from_events(std::string const& expected_ev
handler.reset();
EventProducerFn<EventHandlerYamlStd> event_producer;
event_producer(handler);
csubstr result = sink.get();
csubstr result = sink;
_c4dbgpf("~~~\n{}~~~\n", result);
EXPECT_EQ(std::string(result.str, result.len), expected_events);
}
Expand Down
6 changes: 3 additions & 3 deletions test/test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ struct TestSequenceLevel
if(prev)
receive_src(*prev);
_nfo_logf("level[{}]: parsing source:\n{}", level, src_evts);
evt_str_sink.reset();
evt_str_sink.clear();
evt_handler_str_sink.reset();
evt_handler_str_sink.m_stack.m_callbacks = get_callbacks();
parser_str_sink.parse_in_place_ev(filename, to_substr(src_evts));
EXPECT_FALSE(evt_str_sink.get().empty());
EXPECT_NE(evt_str_sink.size(), 0);
events_were_generated = true;
}

Expand Down Expand Up @@ -655,7 +655,7 @@ struct TestSequenceData
for(size_t i = 0; i < num; ++i)
{
levels[i].parse_yaml_to_events();
csubstr result = levels[i].evt_str_sink.get();
csubstr result = levels[i].evt_str_sink;
events->compare_emitted_events_to_reference_events(std::string(result.str, result.len),
/*ignore_container_style*/false,
/*ignore_scalar_style*/(num>0));
Expand Down
Loading

0 comments on commit da08c32

Please sign in to comment.