You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Using Ascii so that the inline snapshots display correctly
827
+
// even with fonts where characters like '┬' take up more space.
828
+
.with_char_set(CharSet::Ascii)
829
+
}
830
+
831
+
#[test]
832
+
fnone_message(){
833
+
let msg = Report::<Range<usize>>::build(ReportKind::Error,(),0)
834
+
.with_config(no_color_and_ascii())
835
+
.with_message("can't compare apples with oranges")
836
+
.finish()
837
+
.write_to_string(Source::from(""));
838
+
assert_snapshot!(msg, @r###"
839
+
Error: can't compare apples with oranges
840
+
"###)
841
+
}
842
+
843
+
#[test]
844
+
fntwo_labels_without_messages(){
845
+
let source = "apple == orange;";
846
+
let msg = Report::<Range<usize>>::build(ReportKind::Error,(),0)
847
+
.with_config(no_color_and_ascii())
848
+
.with_message("can't compare apples with oranges")
849
+
.with_label(Label::new(0..5))
850
+
.with_label(Label::new(9..15))
851
+
.finish()
852
+
.write_to_string(Source::from(source));
853
+
// TODO: it would be nice if these spans still showed up (like codespan-reporting does)
854
+
assert_snapshot!(msg, @r###"
855
+
Error: can't compare apples with oranges
856
+
,-[<unknown>:1:1]
857
+
|
858
+
1 | apple == orange;
859
+
---'
860
+
"###);
861
+
}
862
+
863
+
#[test]
864
+
fntwo_labels_with_messages(){
865
+
let source = "apple == orange;";
866
+
let msg = Report::<Range<usize>>::build(ReportKind::Error,(),0)
867
+
.with_config(no_color_and_ascii())
868
+
.with_message("can't compare apples with oranges")
869
+
.with_label(Label::new(0..5).with_message("This is an apple"))
870
+
.with_label(Label::new(9..15).with_message("This is an orange"))
871
+
.finish()
872
+
.write_to_string(Source::from(source));
873
+
// TODO: it would be nice if these lines didn't cross
874
+
assert_snapshot!(msg, @r###"
875
+
Error: can't compare apples with oranges
876
+
,-[<unknown>:1:1]
877
+
|
878
+
1 | apple == orange;
879
+
| ^^|^^ ^^^|^^
880
+
| `-------------- This is an apple
881
+
| |
882
+
| `---- This is an orange
883
+
---'
884
+
"###);
885
+
}
886
+
887
+
#[test]
888
+
#[should_panic]
889
+
fnbackwards_label_should_panic(){
890
+
let _ = Report::<Range<usize>>::build(ReportKind::Error,(),0)
891
+
.with_label(Label::new(5..0))
892
+
.finish()
893
+
.write_to_string(Source::from(""));
894
+
}
895
+
896
+
#[test]
897
+
fnlabel_at_end_of_long_line(){
898
+
let source = format!("{}orange","apple == ".repeat(100));
899
+
let msg = Report::<Range<usize>>::build(ReportKind::Error,(),0)
900
+
.with_config(no_color_and_ascii())
901
+
.with_message("can't compare apples with oranges")
902
+
.with_label(
903
+
Label::new(source.len() - 5..source.len()).with_message("This is an orange"),
904
+
)
905
+
.finish()
906
+
.write_to_string(Source::from(source));
907
+
// TODO: it would be nice if the start of long lines would be omitted (like rustc does)
908
+
assert_snapshot!(msg, @r###"
909
+
Error: can't compare apples with oranges
910
+
,-[<unknown>:1:1]
911
+
|
912
+
1 | apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == apple == orange
913
+
| ^^|^^
914
+
| `---- This is an orange
915
+
---'
916
+
"###);
917
+
}
918
+
919
+
#[test]
920
+
fnmultiline_label(){
921
+
let source = "apple\n==\norange";
922
+
let msg = Report::<Range<usize>>::build(ReportKind::Error,(),0)
0 commit comments