@@ -16,12 +16,45 @@ std::string Render(std::vector<DiagnosticDetail> details) {
1616} // namespace
1717
1818TEST_F (ErrorDisplayTest, RenderStatus) {
19- DiagnosticDetail::SourceLocation inline_loc;
20- inline_loc.in_user_input = true ;
19+ using SourceLocation = DiagnosticDetail::SourceLocation;
2120 {
21+ SourceLocation inline_loc;
22+ inline_loc.in_user_input = true ;
2223 std::string result =
2324 Render ({DiagnosticDetail{inline_loc, eSeverityError, " foo" , " " }});
2425 ASSERT_TRUE (StringRef (result).contains (" error:" ));
2526 ASSERT_TRUE (StringRef (result).contains (" foo" ));
2627 }
28+
29+ {
30+ // Test that diagnostics on the same column can be handled and all
31+ // three errors are diagnosed.
32+ SourceLocation loc1 = {FileSpec{" a.c" }, 13 , 11 , 0 , false , true };
33+ SourceLocation loc2 = {FileSpec{" a.c" }, 13 , 13 , 0 , false , true };
34+ std::string result =
35+ Render ({DiagnosticDetail{loc1, eSeverityError, " 1" , " 1" },
36+ DiagnosticDetail{loc1, eSeverityError, " 2" , " 2" },
37+ DiagnosticDetail{loc2, eSeverityError, " 3" , " 3" }});
38+ ASSERT_TRUE (StringRef (result).contains (" error: 1" ));
39+ ASSERT_TRUE (StringRef (result).contains (" error: 2" ));
40+ ASSERT_TRUE (StringRef (result).contains (" error: 3" ));
41+ }
42+ {
43+ // Test that diagnostics in reverse order are emitted correctly.
44+ SourceLocation loc1 = {FileSpec{" a.c" }, 1 , 20 , 0 , false , true };
45+ SourceLocation loc2 = {FileSpec{" a.c" }, 2 , 10 , 0 , false , true };
46+ std::string result =
47+ Render ({DiagnosticDetail{loc2, eSeverityError, " X" , " X" },
48+ DiagnosticDetail{loc1, eSeverityError, " Y" , " Y" }});
49+ ASSERT_LT (StringRef (result).find (" Y" ), StringRef (result).find (" X" ));
50+ }
51+ {
52+ // Test that diagnostics in reverse order are emitted correctly.
53+ SourceLocation loc1 = {FileSpec{" a.c" }, 2 , 10 , 0 , false , true };
54+ SourceLocation loc2 = {FileSpec{" a.c" }, 1 , 20 , 0 , false , true };
55+ std::string result =
56+ Render ({DiagnosticDetail{loc2, eSeverityError, " X" , " X" },
57+ DiagnosticDetail{loc1, eSeverityError, " Y" , " Y" }});
58+ ASSERT_LT (StringRef (result).find (" Y" ), StringRef (result).find (" X" ));
59+ }
2760}
0 commit comments