@@ -54,6 +54,14 @@ class Test_Lex : public ::testing::Test {
54
54
String8_View input, Diagnostic_Assertion,
55
55
String8_View expected_identifier_name,
56
56
Source_Location = Source_Location::current());
57
+ void check_single_token_with_errors (
58
+ String8_View input, Diagnostic_Assertion, Diagnostic_Assertion,
59
+ String8_View expected_identifier_name,
60
+ Source_Location = Source_Location::current());
61
+ void check_single_token_with_errors (
62
+ String8_View input, Span<const Diagnostic_Assertion>,
63
+ String8_View expected_identifier_name,
64
+ Source_Location = Source_Location::current());
57
65
void check_tokens (String8_View input,
58
66
std::initializer_list<Token_Type> expected_token_types,
59
67
Source_Location = Source_Location::current());
@@ -1586,35 +1594,24 @@ TEST_F(Test_Lex, lex_identifier_with_out_of_range_escaped_character) {
1586
1594
TEST_F (Test_Lex, lex_identifier_with_out_of_range_utf_8_sequence) {
1587
1595
// f4 90 80 80 is U+110000
1588
1596
this ->check_single_token_with_errors (
1589
- " too\xf4\x90\x80\x80\x62 ig" _s8v, " too\xf4\x90\x80\x80\x62 ig" _s8v,
1590
- [](Padded_String_View input, const auto & errors) {
1591
- EXPECT_THAT (
1592
- errors,
1593
- ElementsAreArray ({
1594
- DIAG_TYPE_OFFSETS (input, Diag_Invalid_Utf_8_Sequence, //
1595
- sequence, std::strlen (" too" ),
1596
- " \xf4\x90\x80\x80 " _s8v),
1597
- }));
1598
- });
1597
+ " too\xf4\x90\x80\x80\x62 ig" _s8v,
1598
+ DIAGNOSTIC_ASSERTION_SPAN (Diag_Invalid_Utf_8_Sequence, //
1599
+ sequence, std::strlen (" too" ),
1600
+ " \xf4\x90\x80\x80 " _s8v),
1601
+ " too\xf4\x90\x80\x80\x62 ig" _s8v);
1599
1602
}
1600
1603
1601
1604
TEST_F (Test_Lex, lex_identifier_with_malformed_utf_8_sequence) {
1602
1605
this ->check_single_token_with_errors (
1603
1606
" illegal\xc0\xc1\xc2\xc3\xc4 utf8\xfe\xff " _s8v,
1604
- " illegal\xc0\xc1\xc2\xc3\xc4 utf8\xfe\xff " _s8v,
1605
- [](Padded_String_View input, const auto & errors) {
1606
- EXPECT_THAT (
1607
- errors,
1608
- ElementsAreArray ({
1609
- DIAG_TYPE_OFFSETS (input, Diag_Invalid_Utf_8_Sequence, //
1610
- sequence, std::strlen (" illegal" ),
1611
- " \xc0\xc1\xc2\xc3\xc4 " _s8v),
1612
- DIAG_TYPE_OFFSETS (
1613
- input, Diag_Invalid_Utf_8_Sequence, //
1614
- sequence, std::strlen (" illegal\xc0\xc1\xc2\xc3\xc4 utf8" ),
1615
- " \xfe\xff " _s8v),
1616
- }));
1617
- });
1607
+ DIAGNOSTIC_ASSERTION_SPAN (Diag_Invalid_Utf_8_Sequence, //
1608
+ sequence, std::strlen (" illegal" ),
1609
+ " \xc0\xc1\xc2\xc3\xc4 " _s8v),
1610
+ DIAGNOSTIC_ASSERTION_SPAN (Diag_Invalid_Utf_8_Sequence, //
1611
+ sequence,
1612
+ std::strlen (" illegal\xc0\xc1\xc2\xc3\xc4 utf8" ),
1613
+ " \xfe\xff " _s8v),
1614
+ " illegal\xc0\xc1\xc2\xc3\xc4 utf8\xfe\xff " _s8v);
1618
1615
}
1619
1616
1620
1617
TEST_F (Test_Lex, lex_identifier_with_disallowed_character_escape_sequence) {
@@ -2988,6 +2985,22 @@ void Test_Lex::check_single_token_with_errors(
2988
2985
void Test_Lex::check_single_token_with_errors (
2989
2986
String8_View input, Diagnostic_Assertion diag0,
2990
2987
String8_View expected_identifier_name, Source_Location caller) {
2988
+ return this ->check_single_token_with_errors (
2989
+ input, Span<const Diagnostic_Assertion>({diag0}),
2990
+ expected_identifier_name, caller);
2991
+ }
2992
+
2993
+ void Test_Lex::check_single_token_with_errors (
2994
+ String8_View input, Diagnostic_Assertion diag0, Diagnostic_Assertion diag1,
2995
+ String8_View expected_identifier_name, Source_Location caller) {
2996
+ return this ->check_single_token_with_errors (
2997
+ input, Span<const Diagnostic_Assertion>({diag0, diag1}),
2998
+ expected_identifier_name, caller);
2999
+ }
3000
+
3001
+ void Test_Lex::check_single_token_with_errors (
3002
+ String8_View input, Span<const Diagnostic_Assertion> diagnostic_assertions,
3003
+ String8_View expected_identifier_name, Source_Location caller) {
2991
3004
Padded_String code (input);
2992
3005
Diag_List_Diag_Reporter errors (&this ->memory_ );
2993
3006
std::vector<Token> lexed_tokens = this ->lex_to_eof (&code, errors);
@@ -3006,7 +3019,7 @@ void Test_Lex::check_single_token_with_errors(
3006
3019
expected_identifier_name);
3007
3020
}
3008
3021
3009
- assert_diagnostics (&code, errors.diags (), {diag0} , caller);
3022
+ assert_diagnostics (&code, errors.diags (), diagnostic_assertions , caller);
3010
3023
}
3011
3024
3012
3025
void Test_Lex::check_tokens (
0 commit comments