File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1722,3 +1722,32 @@ fn format_inline_marks(
1722
1722
}
1723
1723
Ok ( ( ) )
1724
1724
}
1725
+
1726
+ #[ cfg( test) ]
1727
+ mod tests {
1728
+ use super :: * ;
1729
+ use crate :: { Level , Snippet } ;
1730
+
1731
+ #[ test]
1732
+ fn test_fold_prefix_suffix ( ) {
1733
+ // No folding
1734
+ let snippets = Snippet :: source ( "No folding" ) ;
1735
+ let unfold_snippets = fold_prefix_suffix ( snippets) ;
1736
+
1737
+ assert_eq ! ( unfold_snippets. fold, false ) ;
1738
+ assert_eq ! ( unfold_snippets. line_start, 1 ) ;
1739
+ assert_eq ! ( unfold_snippets. source, "No folding" ) ;
1740
+ assert_eq ! ( unfold_snippets. annotations. len( ) , 0 ) ;
1741
+
1742
+ // Folding
1743
+ let snippets = Snippet :: source ( "First line\r \n Second line\r \n Third oops line" )
1744
+ . annotation ( Level :: Error . span ( 32 ..36 ) . label ( "oops" ) )
1745
+ . fold ( true ) ;
1746
+
1747
+ let fold_snippets = fold_prefix_suffix ( snippets) ;
1748
+ assert_eq ! ( fold_snippets. fold, true ) ;
1749
+ assert_eq ! ( fold_snippets. line_start, 3 ) ;
1750
+ assert_eq ! ( fold_snippets. source, "Third oops line" ) ;
1751
+ assert_eq ! ( fold_snippets. annotations. len( ) , 1 ) ;
1752
+ }
1753
+ }
You can’t perform that action at this time.
0 commit comments