File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ impl Method {
123123 _ => Method :: extension_inline ( src) ,
124124 } ,
125125 _ => {
126- if src. len ( ) < InlineExtension :: MAX {
126+ if src. len ( ) <= InlineExtension :: MAX {
127127 Method :: extension_inline ( src)
128128 } else {
129129 let allocated = AllocatedExtension :: new ( src) ?;
@@ -465,6 +465,21 @@ mod test {
465465
466466 let long_method = "This_is_a_very_long_method.It_is_valid_but_unlikely." ;
467467 assert_eq ! ( Method :: from_str( long_method) . unwrap( ) , long_method) ;
468+
469+ let longest_inline_method = [ b'A' ; InlineExtension :: MAX ] ;
470+ assert_eq ! (
471+ Method :: from_bytes( & longest_inline_method) . unwrap( ) ,
472+ Method ( ExtensionInline (
473+ InlineExtension :: new( & longest_inline_method) . unwrap( )
474+ ) )
475+ ) ;
476+ let shortest_allocated_method = [ b'A' ; InlineExtension :: MAX + 1 ] ;
477+ assert_eq ! (
478+ Method :: from_bytes( & shortest_allocated_method) . unwrap( ) ,
479+ Method ( ExtensionAllocated (
480+ AllocatedExtension :: new( & shortest_allocated_method) . unwrap( )
481+ ) )
482+ ) ;
468483 }
469484
470485 #[ test]
You can’t perform that action at this time.
0 commit comments