…showing that we as always want some greedy parsing based on parsers, not based on input.
Showing the changes to git-object/tests/immutable/commit (2 of 4 files). Show all
Unified · Split
| @@ -0,0 +1,28 @@ | ||
| 1 | +use bstr::ByteSlice; | |
| 2 | +use git_object::commit::MessageRef; | |
| 3 | + | |
| 4 | +#[test] | |
| 5 | +fn only_title_no_trailing_newline() { | |
| 6 | + let msg = MessageRef::from_bytes(b"hello there"); | |
| 7 | + assert_eq!( | |
| 8 | + msg, | |
| 9 | + MessageRef { | |
| 10 | + title: b"hello there".as_bstr(), | |
| 11 | + body: None | |
| 12 | + } | |
| 13 | + ); | |
| 14 | + assert_eq!(msg.summary().as_ref(), "hello there"); | |
| 15 | +} | |
| 16 | + | |
| 17 | +#[test] | |
| 18 | +fn only_title_trailing_newline_is_retained() { | |
| 19 | + let msg = MessageRef::from_bytes(b"hello there\n"); | |
| 20 | + assert_eq!( | |
| 21 | + msg, | |
| 22 | + MessageRef { | |
| 23 | + title: b"hello there\n".as_bstr(), | |
| 24 | + body: None | |
| 25 | + } | |
| 26 | + ); | |
| 27 | + assert_eq!(msg.summary().as_ref(), "hello there\n"); | |
| 28 | +} | |
| @@ -148,20 +148,4 @@ mod method { · 147 unmodified lines | ||
| 148 | 148 | |
| 149 | 149 | mod from_bytes; |
| 150 | 150 | mod iter; |
| 151 | −mod message { | |
| 152 | − use bstr::ByteSlice; | |
| 153 | − use git_object::commit::MessageRef; | |
| 154 | − | |
| 155 | − #[test] | |
| 156 | − fn only_title_no_trailing_newline() { | |
| 157 | − let msg = MessageRef::from_bytes(b"hello there"); | |
| 158 | − assert_eq!( | |
| 159 | − msg, | |
| 160 | − MessageRef { | |
| 161 | − title: b"hello there".as_bstr(), | |
| 162 | − body: None | |
| 163 | − } | |
| 164 | − ); | |
| 165 | − assert_eq!(msg.summary().as_ref(), "hello there"); | |
| 166 | − } | |
| 167 | −} | |
| 151 | +mod message; | |