File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -609,7 +609,7 @@ mod tests {
609
609
610
610
#[ test]
611
611
fn validate_crate_name ( ) {
612
- use super :: InvalidCrateName ;
612
+ use super :: { InvalidCrateName , MAX_NAME_LENGTH } ;
613
613
614
614
assert_ok ! ( Crate :: validate_crate_name( "foo" ) ) ;
615
615
assert_err_eq ! (
@@ -627,6 +627,7 @@ mod tests {
627
627
Crate :: validate_crate_name( "foo+plus" ) ,
628
628
InvalidCrateName :: Char ( '+' , "foo+plus" . into( ) )
629
629
) ;
630
+ // Crate names cannot start with an underscore on crates.io.
630
631
assert_err_eq ! (
631
632
Crate :: validate_crate_name( "_foo" ) ,
632
633
InvalidCrateName :: Start ( '_' , "_foo" . into( ) )
@@ -635,6 +636,14 @@ mod tests {
635
636
Crate :: validate_crate_name( "-foo" ) ,
636
637
InvalidCrateName :: Start ( '-' , "-foo" . into( ) )
637
638
) ;
639
+ assert_err_eq ! (
640
+ Crate :: validate_crate_name( "123" ) ,
641
+ InvalidCrateName :: StartWithDigit ( "123" . into( ) )
642
+ ) ;
643
+ assert_err_eq ! (
644
+ Crate :: validate_crate_name( "o" . repeat( MAX_NAME_LENGTH + 1 ) . as_str( ) ) ,
645
+ InvalidCrateName :: TooLong ( "o" . repeat( MAX_NAME_LENGTH + 1 ) . as_str( ) . into( ) )
646
+ ) ;
638
647
}
639
648
640
649
#[ test]
You can’t perform that action at this time.
0 commit comments