Fixed MessageChainsOrder test helper function for JSON
This commit is contained in:
@@ -40,7 +40,7 @@ void to_json(nlohmann::json &j, const participant &c)
|
|||||||
j["name"] = dynamic_cast<const method &>(c).method_name();
|
j["name"] = dynamic_cast<const method &>(c).method_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
j["full_name"] = c.full_name(false);
|
j["full_name"] = generators::json::render_name(c.full_name(false));
|
||||||
|
|
||||||
if (c.type_name() == "function" || c.type_name() == "function_template") {
|
if (c.type_name() == "function" || c.type_name() == "function_template") {
|
||||||
const auto &f = dynamic_cast<const function &>(c);
|
const auto &f = dynamic_cast<const function &>(c);
|
||||||
|
|||||||
@@ -719,6 +719,8 @@ template <typename DiagramType>
|
|||||||
bool MessageChainsOrder(
|
bool MessageChainsOrder(
|
||||||
const DiagramType &d, std::vector<std::vector<Message>> message_chains)
|
const DiagramType &d, std::vector<std::vector<Message>> message_chains)
|
||||||
{
|
{
|
||||||
|
// Try to match each chain to each sequence - sequence order depends
|
||||||
|
// on platform and LLVM version
|
||||||
for (const auto &message_chain : message_chains) {
|
for (const auto &message_chain : message_chains) {
|
||||||
if (!MessageOrder(d, message_chain))
|
if (!MessageOrder(d, message_chain))
|
||||||
return false;
|
return false;
|
||||||
@@ -2515,31 +2517,40 @@ template <>
|
|||||||
bool MessageChainsOrder<json_t>(
|
bool MessageChainsOrder<json_t>(
|
||||||
const json_t &d, std::vector<std::vector<Message>> message_chains)
|
const json_t &d, std::vector<std::vector<Message>> message_chains)
|
||||||
{
|
{
|
||||||
uint32_t chain_index{0};
|
const auto sequence_chains_count{
|
||||||
|
d.src["sequences"][0]["message_chains"].size()};
|
||||||
|
|
||||||
for (const auto &messages : message_chains) {
|
for (const auto &messages : message_chains) {
|
||||||
int64_t offset{0};
|
for (uint32_t chain_index = 0; chain_index < sequence_chains_count;
|
||||||
|
chain_index++) {
|
||||||
|
int64_t offset{0};
|
||||||
|
|
||||||
std::vector<int64_t> order;
|
std::vector<int64_t> order;
|
||||||
order.reserve(messages.size());
|
order.reserve(messages.size());
|
||||||
std::transform(messages.begin(), messages.end(),
|
std::transform(messages.begin(), messages.end(),
|
||||||
std::back_inserter(order),
|
std::back_inserter(order),
|
||||||
[&d, &offset, chain_index](const auto &m) {
|
[&d, &offset, chain_index](const auto &m) -> int64_t {
|
||||||
offset = find_message_in_chain(d, m, offset, true, chain_index);
|
try {
|
||||||
return offset;
|
offset = find_message_in_chain(
|
||||||
});
|
d, m, offset, true, chain_index);
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bool are_messages_in_order = std::is_sorted(order.begin(), order.end());
|
bool are_messages_in_order =
|
||||||
|
std::is_sorted(order.begin(), order.end());
|
||||||
|
|
||||||
chain_index++;
|
if (are_messages_in_order)
|
||||||
|
return true;
|
||||||
if (!are_messages_in_order) {
|
|
||||||
FAIL(fmt::format(
|
|
||||||
"Messages are not in order: \n[{}]", fmt::join(order, ",\n")));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
FAIL(fmt::format("Messages are not in order"));
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
Reference in New Issue
Block a user