@@ -393,7 +393,7 @@ impl fmt::Display for Error {
393393 use Error :: * ;
394394
395395 match * self {
396- TooLong ( len) => write ! ( f, "hrp is too long, found {} characters, must be <= 126 " , len) ,
396+ TooLong ( len) => write ! ( f, "hrp is too long, found {} characters, must be <= {} " , len, MAX_HRP_LEN ) ,
397397 Empty => write ! ( f, "hrp is empty, must have at least 1 character" ) ,
398398 NonAsciiChar ( c) => write ! ( f, "found non-ASCII character: {}" , c) ,
399399 InvalidAsciiByte ( b) => write ! ( f, "byte value is not valid US-ASCII: \' {:x}\' " , b) ,
@@ -537,4 +537,13 @@ mod tests {
537537 let hrp = Hrp :: parse_unchecked ( s) ;
538538 assert_eq ! ( hrp. as_bytes( ) , s. as_bytes( ) ) ;
539539 }
540+
541+ #[ test]
542+ fn error_messages ( ) {
543+ assert_eq ! ( "hrp is too long, found 92 characters, must be <= 83" , Error :: TooLong ( 92 ) . to_string( ) ) ;
544+ assert_eq ! ( "hrp is empty, must have at least 1 character" , Error :: Empty . to_string( ) ) ;
545+ assert_eq ! ( "found non-ASCII character: 😊" , Error :: NonAsciiChar ( '😊' ) . to_string( ) ) ;
546+ assert_eq ! ( "byte value is not valid US-ASCII: 'ff'" , Error :: InvalidAsciiByte ( 255 ) . to_string( ) ) ;
547+ assert_eq ! ( "hrp cannot mix upper and lower case" , Error :: MixedCase . to_string( ) ) ;
548+ }
540549}
0 commit comments