9
9
#include < quick-lint-js/diagnostic-assertion.h>
10
10
#include < quick-lint-js/gtest.h>
11
11
12
+ using ::testing::AnyOf;
13
+
12
14
namespace quick_lint_js {
13
15
namespace {
14
16
Diagnostic_Assertion parse_or_fail (
@@ -613,9 +615,14 @@ TEST_F(Test_Diagnostic_Assertion_2, match_error_type_with_1_field_message) {
613
615
diags.add (Diag_Invalid_Break{
614
616
.break_statement = Source_Code_Span (&code[0 ], &code[5 ]),
615
617
});
616
- EXPECT_EQ (get_matcher_message (matcher, diags),
617
- " whose element #0 doesn't match, whose type (Diag_Invalid_Break) "
618
- " isn't Diag_Invalid_Continue" );
618
+ EXPECT_THAT (
619
+ get_matcher_message (matcher, diags),
620
+ AnyOf (" whose element #0 (Diag_Invalid_Break) not "
621
+ " Diag_Invalid_Continue{.continue_statement = 0..5}, "
622
+ " whose type (Diag_Invalid_Break) isn't Diag_Invalid_Continue" ,
623
+ // Old googletest:
624
+ " whose element #0 doesn't match, "
625
+ " whose type (Diag_Invalid_Break) isn't Diag_Invalid_Continue" ));
619
626
}
620
627
621
628
TEST_F (Test_Diagnostic_Assertion_2, match_offsets_of_1_field_span) {
@@ -656,9 +663,13 @@ TEST_F(Test_Diagnostic_Assertion_2, match_offsets_of_1_field_message) {
656
663
diags.add (Diag_Invalid_Continue{
657
664
.continue_statement = Source_Code_Span (&code[1 ], &code[4 ]),
658
665
});
659
- EXPECT_EQ (get_matcher_message (matcher, diags),
660
- " whose element #0 doesn't match, whose .continue_statement (1-4) "
661
- " doesn't equal 0-5" );
666
+ EXPECT_THAT (get_matcher_message (matcher, diags),
667
+ AnyOf (" whose element #0 (Diag_Invalid_Continue) not "
668
+ " Diag_Invalid_Continue{.continue_statement = 0..5}, "
669
+ " whose .continue_statement (1-4) doesn't equal 0-5" ,
670
+ // Old googletest:
671
+ " whose element #0 doesn't match, "
672
+ " whose .continue_statement (1-4) doesn't equal 0-5" ));
662
673
EXPECT_EQ (get_matcher_description (matcher),
663
674
" 1 diagnostic: {\n "
664
675
" Diag_Invalid_Continue{.continue_statement = 0..5},\n "
@@ -672,9 +683,13 @@ TEST_F(Test_Diagnostic_Assertion_2, match_offsets_of_1_field_message) {
672
683
diags.add (Diag_Invalid_Break{
673
684
.break_statement = Source_Code_Span (&code[1 ], &code[4 ]),
674
685
});
675
- EXPECT_EQ (get_matcher_message (matcher, diags),
676
- " whose element #0 doesn't match, whose .break_statement (1-4) "
677
- " doesn't equal 0-5" );
686
+ EXPECT_THAT (get_matcher_message (matcher, diags),
687
+ AnyOf (" whose element #0 (Diag_Invalid_Break) not "
688
+ " Diag_Invalid_Break{.break_statement = 0..5}, "
689
+ " whose .break_statement (1-4) doesn't equal 0-5" ,
690
+ // Old googletest:
691
+ " whose element #0 doesn't match, "
692
+ " whose .break_statement (1-4) doesn't equal 0-5" ));
678
693
EXPECT_EQ (get_matcher_description (matcher),
679
694
" 1 diagnostic: {\n "
680
695
" Diag_Invalid_Break{.break_statement = 0..5},\n "
@@ -718,9 +733,17 @@ TEST_F(Test_Diagnostic_Assertion_2, char8_message) {
718
733
.where = Source_Code_Span (&code[0 ], &code[1 ]),
719
734
.token = u8 ' (' ,
720
735
});
721
- EXPECT_EQ (get_matcher_message (matcher, diags),
722
- " whose element #0 doesn't match, whose .where (0-1) equals 0-1 and "
723
- " whose .token ('(') doesn't equal ')'" );
736
+ EXPECT_THAT (get_matcher_message (matcher, diags),
737
+ AnyOf (" whose element #0 "
738
+ " (Diag_Expected_Parenthesis_Around_Do_While_Condition) not "
739
+ " Diag_Expected_Parenthesis_Around_Do_While_Condition"
740
+ " {.where = 0..1, .token = ')'}, "
741
+ " whose .where (0-1) equals 0-1 and "
742
+ " whose .token ('(') doesn't equal ')'" ,
743
+ // Old googletest:
744
+ " whose element #0 doesn't match, "
745
+ " whose .where (0-1) equals 0-1 and "
746
+ " whose .token ('(') doesn't equal ')'" ));
724
747
EXPECT_EQ (get_matcher_description (matcher),
725
748
" 1 diagnostic: {\n "
726
749
" Diag_Expected_Parenthesis_Around_Do_While_Condition"
@@ -764,10 +787,17 @@ TEST_F(Test_Diagnostic_Assertion_2, string8_view_message) {
764
787
.characters = Source_Code_Span (&code[0 ], &code[1 ]),
765
788
.rounded_val = u8" HELLO" _sv,
766
789
});
767
- EXPECT_EQ (
790
+ EXPECT_THAT (
768
791
get_matcher_message (matcher, diags),
769
- " whose element #0 doesn't match, whose .characters (0-1) equals 0-1 and "
770
- " whose .rounded_val (\" HELLO\" ) doesn't equal \" hello\" " );
792
+ AnyOf (" whose element #0 (Diag_Integer_Literal_Will_Lose_Precision) not "
793
+ " Diag_Integer_Literal_Will_Lose_Precision"
794
+ " {.characters = 0..1, .rounded_val = \" hello\" }, "
795
+ " whose .characters (0-1) equals 0-1 and "
796
+ " whose .rounded_val (\" HELLO\" ) doesn't equal \" hello\" " ,
797
+ // Old googletest:
798
+ " whose element #0 doesn't match, "
799
+ " whose .characters (0-1) equals 0-1 and "
800
+ " whose .rounded_val (\" HELLO\" ) doesn't equal \" hello\" " ));
771
801
EXPECT_EQ (get_matcher_description (matcher),
772
802
" 1 diagnostic: {\n "
773
803
" Diag_Integer_Literal_Will_Lose_Precision"
0 commit comments