File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -262,4 +262,37 @@ fn ed_iterator_specializations() {
262
262
assert_eq ! ( '\'' . escape_default( ) . last( ) , Some ( '\'' ) ) ;
263
263
}
264
264
265
+ #[ test]
266
+ fn eu_iterator_specializations ( ) {
267
+ fn check ( c : char ) {
268
+ let len = c. escape_unicode ( ) . count ( ) ;
269
+
270
+ // Check OoB
271
+ assert_eq ! ( c. escape_unicode( ) . nth( len) , None ) ;
272
+
273
+ // For all possible in-bound offsets
274
+ let mut iter = c. escape_unicode ( ) ;
275
+ for offset in 0 ..len {
276
+ // Check last
277
+ assert_eq ! ( iter. clone( ) . last( ) , Some ( '}' ) ) ;
265
278
279
+ // Check counting
280
+ assert_eq ! ( iter. clone( ) . count( ) , len - offset) ;
281
+
282
+ // Check nth
283
+ assert_eq ! ( c. escape_unicode( ) . nth( offset) , iter. next( ) ) ;
284
+ }
285
+
286
+ // Check post-last
287
+ assert_eq ! ( iter. clone( ) . last( ) , None ) ;
288
+ assert_eq ! ( iter. clone( ) . count( ) , 0 ) ;
289
+ }
290
+
291
+ check ( '\u{0}' ) ;
292
+ check ( '\u{1}' ) ;
293
+ check ( '\u{12}' ) ;
294
+ check ( '\u{123}' ) ;
295
+ check ( '\u{1234}' ) ;
296
+ check ( '\u{12340}' ) ;
297
+ check ( '\u{10FFFF}' ) ;
298
+ }
You can’t perform that action at this time.
0 commit comments