History

More message parsing tests, now with legit failure… (#198)

…showing that we as always want some greedy parsing based on parsers, not based on input.

Sebastian Thiel committed 5 years ago

Commit 625be8d1 parent 6150b2d4 files · +56 −29Browse files

Showing the changes to git-object/tests/immutable/commit (2 of 4 files). Show all

Unified · Split

2 files
  1. git-object/tests/immutable/commit/message.rs +28 −0
  2. git-object/tests/immutable/commit/mod.rs +1 −17
git-object/tests/immutable/commit/message.rs+28−0
@@ -0,0 +1,28 @@
1use bstr::ByteSlice;
2use git_object::commit::MessageRef;
3
4#[test]
5fn 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]
18fn 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}
git-object/tests/immutable/commit/mod.rs+1−17
@@ -148,20 +148,4 @@ mod method { · 147 unmodified lines
148 148
149mod from_bytes;149mod from_bytes;
150mod iter;150mod iter;
151mod message {151mod 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}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t