@@ -16,12 +16,45 @@ std::string Render(std::vector<DiagnosticDetail> details) {
16
16
} // namespace
17
17
18
18
TEST_F (ErrorDisplayTest, RenderStatus) {
19
- DiagnosticDetail::SourceLocation inline_loc;
20
- inline_loc.in_user_input = true ;
19
+ using SourceLocation = DiagnosticDetail::SourceLocation;
21
20
{
21
+ SourceLocation inline_loc;
22
+ inline_loc.in_user_input = true ;
22
23
std::string result =
23
24
Render ({DiagnosticDetail{inline_loc, eSeverityError, " foo" , " " }});
24
25
ASSERT_TRUE (StringRef (result).contains (" error:" ));
25
26
ASSERT_TRUE (StringRef (result).contains (" foo" ));
26
27
}
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
+ }
27
60
}
0 commit comments