Skip to content

Commit 724c465

Browse files
committed
Accomodate platform differences in exception messages
1 parent c9b283f commit 724c465

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/PegtlExecutableTests.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,19 @@ TEST(PegtlExecutableCase, InvalidStringEscapeSequence)
153153
}
154154
catch (const peg::parse_error& e)
155155
{
156+
ASSERT_NE(nullptr, e.what());
157+
156158
using namespace std::literals;
157159

158-
ASSERT_NE(nullptr, e.what());
159-
EXPECT_TRUE(
160-
"InvalidStringEscapeSequence:1:31: parse error matching struct graphql::peg::string_escape_sequence_content"sv
161-
== e.what())
162-
<< e.what();
160+
const std::string_view error { e.what() };
161+
constexpr auto c_start = "InvalidStringEscapeSequence:1:31: parse error matching "sv;
162+
constexpr auto c_end = " graphql::peg::string_escape_sequence_content"sv;
163+
164+
ASSERT_TRUE(error.size() > c_start.size()) << "error message is too short";
165+
ASSERT_TRUE(error.size() > c_end.size()) << "error message is too short";
166+
EXPECT_TRUE(error.substr(0, c_start.size()) == c_start) << e.what();
167+
EXPECT_TRUE(error.substr(error.size() - c_end.size()) == c_end) << e.what();
168+
163169
caughtException = true;
164170
}
165171

0 commit comments

Comments
 (0)