@@ -369,6 +369,11 @@ fn specification() {
369
369
spec. translate . from . push_str ( "1" ) ;
370
370
spec. translate . to . push_str ( "0" ) ;
371
371
assert_eq ! ( errmsg( spec. encoding( ) ) , "'1' has conflicting definitions" ) ;
372
+ spec. translate . from . push_str ( "12" ) ;
373
+ assert_eq ! ( errmsg( spec. encoding( ) ) , "translate from/to length mismatch" ) ;
374
+ spec. translate . from = "Z" . to_string ( ) ;
375
+ spec. translate . to = "2" . to_string ( ) ;
376
+ assert_eq ! ( errmsg( spec. encoding( ) ) , "'2' is undefined" ) ;
372
377
let mut spec = Specification :: new ( ) ;
373
378
spec. wrap . width = 1 ;
374
379
spec. wrap . separator . push_str ( "\n " ) ;
@@ -394,6 +399,28 @@ fn specification() {
394
399
"invalid wrap width or separator length" ) ;
395
400
}
396
401
402
+ #[ test]
403
+ fn round_trip ( ) {
404
+ let test = |e : Encoding | {
405
+ assert_eq ! ( e. specification( ) . encoding( ) . unwrap( ) , e) ;
406
+ } ;
407
+ test ( data_encoding:: HEXLOWER ) ;
408
+ test ( data_encoding:: HEXLOWER_PERMISSIVE ) ;
409
+ test ( data_encoding:: HEXUPPER ) ;
410
+ test ( data_encoding:: HEXUPPER_PERMISSIVE ) ;
411
+ test ( data_encoding:: BASE32 ) ;
412
+ test ( data_encoding:: BASE32_NOPAD ) ;
413
+ test ( data_encoding:: BASE32HEX ) ;
414
+ test ( data_encoding:: BASE32HEX_NOPAD ) ;
415
+ test ( data_encoding:: BASE32_DNSSEC ) ;
416
+ test ( data_encoding:: BASE32_DNSCURVE ) ;
417
+ test ( data_encoding:: BASE64 ) ;
418
+ test ( data_encoding:: BASE64_NOPAD ) ;
419
+ test ( data_encoding:: BASE64_MIME ) ;
420
+ test ( data_encoding:: BASE64URL ) ;
421
+ test ( data_encoding:: BASE64URL_NOPAD ) ;
422
+ }
423
+
397
424
#[ test]
398
425
fn is_canonical ( ) {
399
426
fn test ( expect : bool , update : & Fn ( & mut Specification ) ) {
0 commit comments