Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Method {
_ => Method::extension_inline(src),
},
_ => {
if src.len() < InlineExtension::MAX {
if src.len() <= InlineExtension::MAX {
Method::extension_inline(src)
} else {
let allocated = AllocatedExtension::new(src)?;
Expand Down Expand Up @@ -465,5 +465,18 @@ mod test {

let long_method = "This_is_a_very_long_method.It_is_valid_but_unlikely.";
assert_eq!(Method::from_str(long_method).unwrap(), long_method);

// if these two assert_eq! fail, the output message may not be helpful, because type info
// of Method.Inner is not printed
let longest_inline_method = [b'A'; InlineExtension::MAX];
assert_eq!(
Method::from_bytes(&longest_inline_method).unwrap(),
Method(ExtensionInline(InlineExtension::new(&longest_inline_method).unwrap()))
);
let shortest_allocated_method = [b'A'; InlineExtension::MAX + 1];
assert_eq!(
Method::from_bytes(&shortest_allocated_method).unwrap(),
Method(ExtensionAllocated(AllocatedExtension::new(&shortest_allocated_method).unwrap()))
);
}
}