Skip to content

Commit

Permalink
css2/test: Improve error messages for unhandled things
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlinden committed Jan 12, 2025
1 parent aa33aab commit b734f23
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions css2/tokenizer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,25 @@ constexpr char const *kReplacementCharacter = "\xef\xbf\xbd";
class TokenizerOutput {
public:
~TokenizerOutput() {
a.expect(tokens.empty(), "Not all tokens were handled", loc);
a.expect(errors.empty(), "Not all errors were handled", loc);
if (!tokens.empty()) {
std::stringstream ss;
ss << "Not all tokens were handled. Unhandled:\n";
for (auto const &t : tokens) {
ss << "* " << to_string(t) << '\n';
}

a.expectation_failure(ss.view(), loc);
}

if (!errors.empty()) {
std::stringstream ss;
ss << "Not all errors were handled. Unhandled:\n";
for (auto e : errors) {
ss << "* " << to_string(e) << '\n';
}

a.expectation_failure(ss.view(), loc);
}
}

etest::IActions &a;
Expand Down

0 comments on commit b734f23

Please sign in to comment.