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 860991e commit 630e8b9
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions css2/tokenizer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <cstdint>
#include <limits>
#include <source_location>
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
Expand All @@ -27,8 +28,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 630e8b9

Please sign in to comment.