@@ -1050,130 +1050,4 @@ fn test_unique_id() {
1050
1050
}
1051
1051
1052
1052
#[ cfg( test) ]
1053
- mod tests {
1054
- use super :: { ErrorCodes , LangString , Markdown , MarkdownHtml , IdMap } ;
1055
- use super :: plain_summary_line;
1056
- use std:: cell:: RefCell ;
1057
- use syntax:: edition:: { Edition , DEFAULT_EDITION } ;
1058
-
1059
- #[ test]
1060
- fn test_lang_string_parse ( ) {
1061
- fn t ( s : & str ,
1062
- should_panic : bool , no_run : bool , ignore : bool , rust : bool , test_harness : bool ,
1063
- compile_fail : bool , allow_fail : bool , error_codes : Vec < String > ,
1064
- edition : Option < Edition > ) {
1065
- assert_eq ! ( LangString :: parse( s, ErrorCodes :: Yes ) , LangString {
1066
- should_panic,
1067
- no_run,
1068
- ignore,
1069
- rust,
1070
- test_harness,
1071
- compile_fail,
1072
- error_codes,
1073
- original: s. to_owned( ) ,
1074
- allow_fail,
1075
- edition,
1076
- } )
1077
- }
1078
-
1079
- fn v ( ) -> Vec < String > {
1080
- Vec :: new ( )
1081
- }
1082
-
1083
- // ignore-tidy-linelength
1084
- // marker | should_panic | no_run | ignore | rust | test_harness
1085
- // | compile_fail | allow_fail | error_codes | edition
1086
- t ( "" , false , false , false , true , false , false , false , v ( ) , None ) ;
1087
- t ( "rust" , false , false , false , true , false , false , false , v ( ) , None ) ;
1088
- t ( "sh" , false , false , false , false , false , false , false , v ( ) , None ) ;
1089
- t ( "ignore" , false , false , true , true , false , false , false , v ( ) , None ) ;
1090
- t ( "should_panic" , true , false , false , true , false , false , false , v ( ) , None ) ;
1091
- t ( "no_run" , false , true , false , true , false , false , false , v ( ) , None ) ;
1092
- t ( "test_harness" , false , false , false , true , true , false , false , v ( ) , None ) ;
1093
- t ( "compile_fail" , false , true , false , true , false , true , false , v ( ) , None ) ;
1094
- t ( "allow_fail" , false , false , false , true , false , false , true , v ( ) , None ) ;
1095
- t ( "{.no_run .example}" , false , true , false , true , false , false , false , v ( ) , None ) ;
1096
- t ( "{.sh .should_panic}" , true , false , false , false , false , false , false , v ( ) , None ) ;
1097
- t ( "{.example .rust}" , false , false , false , true , false , false , false , v ( ) , None ) ;
1098
- t ( "{.test_harness .rust}" , false , false , false , true , true , false , false , v ( ) , None ) ;
1099
- t ( "text, no_run" , false , true , false , false , false , false , false , v ( ) , None ) ;
1100
- t ( "text,no_run" , false , true , false , false , false , false , false , v ( ) , None ) ;
1101
- t ( "edition2015" , false , false , false , true , false , false , false , v ( ) , Some ( Edition :: Edition2015 ) ) ;
1102
- t ( "edition2018" , false , false , false , true , false , false , false , v ( ) , Some ( Edition :: Edition2018 ) ) ;
1103
- }
1104
-
1105
- #[ test]
1106
- fn test_header ( ) {
1107
- fn t ( input : & str , expect : & str ) {
1108
- let mut map = IdMap :: new ( ) ;
1109
- let output = Markdown ( input, & [ ] , RefCell :: new ( & mut map) ,
1110
- ErrorCodes :: Yes , DEFAULT_EDITION ) . to_string ( ) ;
1111
- assert_eq ! ( output, expect, "original: {}" , input) ;
1112
- }
1113
-
1114
- t ( "# Foo bar" , "<h1 id=\" foo-bar\" class=\" section-header\" >\
1115
- <a href=\" #foo-bar\" >Foo bar</a></h1>") ;
1116
- t ( "## Foo-bar_baz qux" , "<h2 id=\" foo-bar_baz-qux\" class=\" section-\
1117
- header\" ><a href=\" #foo-bar_baz-qux\" >Foo-bar_baz qux</a></h2>") ;
1118
- t ( "### **Foo** *bar* baz!?!& -_qux_-%" ,
1119
- "<h3 id=\" foo-bar-baz--qux-\" class=\" section-header\" >\
1120
- <a href=\" #foo-bar-baz--qux-\" ><strong>Foo</strong> \
1121
- <em>bar</em> baz!?!& -<em>qux</em>-%</a></h3>") ;
1122
- t ( "#### **Foo?** & \\ *bar?!* _`baz`_ ❤ #qux" ,
1123
- "<h4 id=\" foo--bar--baz--qux\" class=\" section-header\" >\
1124
- <a href=\" #foo--bar--baz--qux\" ><strong>Foo?</strong> & *bar?!* \
1125
- <em><code>baz</code></em> ❤ #qux</a></h4>") ;
1126
- }
1127
-
1128
- #[ test]
1129
- fn test_header_ids_multiple_blocks ( ) {
1130
- let mut map = IdMap :: new ( ) ;
1131
- fn t ( map : & mut IdMap , input : & str , expect : & str ) {
1132
- let output = Markdown ( input, & [ ] , RefCell :: new ( map) ,
1133
- ErrorCodes :: Yes , DEFAULT_EDITION ) . to_string ( ) ;
1134
- assert_eq ! ( output, expect, "original: {}" , input) ;
1135
- }
1136
-
1137
- t ( & mut map, "# Example" , "<h1 id=\" example\" class=\" section-header\" >\
1138
- <a href=\" #example\" >Example</a></h1>") ;
1139
- t ( & mut map, "# Panics" , "<h1 id=\" panics\" class=\" section-header\" >\
1140
- <a href=\" #panics\" >Panics</a></h1>") ;
1141
- t ( & mut map, "# Example" , "<h1 id=\" example-1\" class=\" section-header\" >\
1142
- <a href=\" #example-1\" >Example</a></h1>") ;
1143
- t ( & mut map, "# Main" , "<h1 id=\" main\" class=\" section-header\" >\
1144
- <a href=\" #main\" >Main</a></h1>") ;
1145
- t ( & mut map, "# Example" , "<h1 id=\" example-2\" class=\" section-header\" >\
1146
- <a href=\" #example-2\" >Example</a></h1>") ;
1147
- t ( & mut map, "# Panics" , "<h1 id=\" panics-1\" class=\" section-header\" >\
1148
- <a href=\" #panics-1\" >Panics</a></h1>") ;
1149
- }
1150
-
1151
- #[ test]
1152
- fn test_plain_summary_line ( ) {
1153
- fn t ( input : & str , expect : & str ) {
1154
- let output = plain_summary_line ( input) ;
1155
- assert_eq ! ( output, expect, "original: {}" , input) ;
1156
- }
1157
-
1158
- t ( "hello [Rust](https://www.rust-lang.org) :)" , "hello Rust :)" ) ;
1159
- t ( "hello [Rust](https://www.rust-lang.org \" Rust\" ) :)" , "hello Rust :)" ) ;
1160
- t ( "code `let x = i32;` ..." , "code `let x = i32;` ..." ) ;
1161
- t ( "type `Type<'static>` ..." , "type `Type<'static>` ..." ) ;
1162
- t ( "# top header" , "top header" ) ;
1163
- t ( "## header" , "header" ) ;
1164
- }
1165
-
1166
- #[ test]
1167
- fn test_markdown_html_escape ( ) {
1168
- fn t ( input : & str , expect : & str ) {
1169
- let mut idmap = IdMap :: new ( ) ;
1170
- let output = MarkdownHtml ( input, RefCell :: new ( & mut idmap) ,
1171
- ErrorCodes :: Yes , DEFAULT_EDITION ) . to_string ( ) ;
1172
- assert_eq ! ( output, expect, "original: {}" , input) ;
1173
- }
1174
-
1175
- t ( "`Struct<'a, T>`" , "<p><code>Struct<'a, T></code></p>\n " ) ;
1176
- t ( "Struct<'a, T>" , "<p>Struct<'a, T></p>\n " ) ;
1177
- t ( "Struct<br>" , "<p>Struct<br></p>\n " ) ;
1178
- }
1179
- }
1053
+ mod tests;
0 commit comments