Compare commits
2 commits
1ac4f0905c
...
906e49cb29
Author | SHA1 | Date | |
---|---|---|---|
906e49cb29 | |||
2dab1ffd23 |
3 changed files with 10 additions and 10 deletions
|
@ -88,7 +88,7 @@ struct Client {
|
|||
jid.resource = std::move(r.payload.jid->resource);
|
||||
SPDLOG_INFO("Allocated resource: {}", jid.resource);
|
||||
},
|
||||
IqErrThrowVisitor<::iq::Bind>{"Error response on IQ: Set::Bind"}),
|
||||
IqErrVisitor<::iq::Bind>{"Error response on IQ: Set::Bind"}),
|
||||
std::move(set_bind_response));
|
||||
co_return;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ struct Client {
|
|||
roster = std::move(r.payload);
|
||||
SPDLOG_INFO("New roster: {}", ToString(roster));
|
||||
},
|
||||
IqErrThrowVisitor<::iq::Roster>{"Error response on IQ: Get::Roster"}),
|
||||
IqErrVisitor<::iq::Roster>{"Error response on IQ: Get::Roster"}),
|
||||
std::move(get_roster_response));
|
||||
co_return;
|
||||
}
|
||||
|
|
|
@ -124,8 +124,8 @@ template <typename Payload>
|
|||
using Iq = std::variant<iq::Get<Payload>, iq::Set<Payload>, iq::Result<Payload>, IqError>;
|
||||
|
||||
template <typename Payload>
|
||||
struct IqErrThrowVisitor {
|
||||
constexpr IqErrThrowVisitor(std::string_view baseErrorMsg) : baseErrorMsg(baseErrorMsg) {
|
||||
struct IqErrVisitor {
|
||||
constexpr IqErrVisitor(std::string_view baseErrorMsg) : baseErrorMsg(baseErrorMsg) {
|
||||
}
|
||||
|
||||
void operator()(const iq::Get<Payload>&) {
|
||||
|
|
12
tests/iq.cpp
12
tests/iq.cpp
|
@ -72,7 +72,7 @@ TEST(IQ, ParseForbiddenError) {
|
|||
ASSERT_TRUE(std::holds_alternative<iq::error::impl::Forbidden>(errorRes.payload));
|
||||
}
|
||||
|
||||
TEST(IQ, IqErrThrowVisitorThrow) {
|
||||
TEST(IQ, IqErrVisitorThrow) {
|
||||
std::istringstream xml_stream(kForbiddenErrorData);
|
||||
|
||||
xmlpp::DomParser parser;
|
||||
|
@ -86,7 +86,7 @@ TEST(IQ, IqErrThrowVisitorThrow) {
|
|||
static constexpr auto visitorErrMsg = "Test Error";
|
||||
static constexpr auto throwErrMsg = "Stanza IQ Error: Forbidden";
|
||||
try {
|
||||
std::visit(utempl::Overloaded([](iq::Result<SomeStruct> r) {}, IqErrThrowVisitor<SomeStruct>{visitorErrMsg}), std::move(iqRes));
|
||||
std::visit(utempl::Overloaded([](iq::Result<SomeStruct> r) {}, IqErrVisitor<SomeStruct>{visitorErrMsg}), std::move(iqRes));
|
||||
} catch(const iq::error::impl::IqBaseError& err) {
|
||||
ASSERT_STREQ(throwErrMsg, err.what());
|
||||
return;
|
||||
|
@ -99,7 +99,7 @@ TEST(IQ, IqErrThrowVisitorThrow) {
|
|||
ASSERT_TRUE(false) << "Expected throwing an exception due to an error in output";
|
||||
}
|
||||
|
||||
TEST(IQ, IqErrThrowVisitorThrowGet) {
|
||||
TEST(IQ, IqErrVisitorThrowGet) {
|
||||
std::istringstream xml_stream(kExpectedData);
|
||||
|
||||
xmlpp::DomParser parser;
|
||||
|
@ -113,7 +113,7 @@ TEST(IQ, IqErrThrowVisitorThrowGet) {
|
|||
static constexpr auto visitorErrMsg = "Test Error";
|
||||
static constexpr auto throwErrMsg = "Test Error: 'Get' is an invalid type for IQ result. Expected 'Result' or 'Error'";
|
||||
try {
|
||||
std::visit(utempl::Overloaded([](iq::Result<SomeStruct> r) {}, IqErrThrowVisitor<SomeStruct>{"Test Error"}), std::move(iqRes));
|
||||
std::visit(utempl::Overloaded([](iq::Result<SomeStruct> r) {}, IqErrVisitor<SomeStruct>{"Test Error"}), std::move(iqRes));
|
||||
} catch(const iq::error::impl::IqBaseError& err) {
|
||||
ASSERT_TRUE(false) << "\tERROR: Invalid throw type throw";
|
||||
} catch(const std::runtime_error& err) {
|
||||
|
@ -126,7 +126,7 @@ TEST(IQ, IqErrThrowVisitorThrowGet) {
|
|||
ASSERT_TRUE(false) << "\tERROR: Expected throwing an exception due to an error in output";
|
||||
}
|
||||
|
||||
TEST(IQ, IqErrThrowVisitorThrowSet) {
|
||||
TEST(IQ, IqErrVisitorThrowSet) {
|
||||
std::istringstream xml_stream(kExpectedSetData);
|
||||
|
||||
xmlpp::DomParser parser;
|
||||
|
@ -140,7 +140,7 @@ TEST(IQ, IqErrThrowVisitorThrowSet) {
|
|||
static constexpr auto visitorErrMsg = "Test Error";
|
||||
static constexpr auto throwErrMsg = "Test Error: 'Set' is an invalid type for IQ result. Expected 'Result' or 'Error'";
|
||||
try {
|
||||
std::visit(utempl::Overloaded([](iq::Result<SomeStruct> r) {}, IqErrThrowVisitor<SomeStruct>{"Test Error"}), std::move(iqRes));
|
||||
std::visit(utempl::Overloaded([](iq::Result<SomeStruct> r) {}, IqErrVisitor<SomeStruct>{"Test Error"}), std::move(iqRes));
|
||||
} catch(const iq::error::impl::IqBaseError& err) {
|
||||
ASSERT_TRUE(false) << "\tERROR: Invalid throw type throw";
|
||||
} catch(const std::runtime_error& err) {
|
||||
|
|
Loading…
Reference in a new issue