@@ -19,15 +19,90 @@ mod method {
19
19
}
20
20
21
21
mod parse_tag {
22
- use crate :: borrowed:: tag:: parse_tag;
23
- use crate :: tests:: borrowed:: fixture_bytes;
24
- use crate :: tests:: borrowed:: tag:: tag_fixture;
22
+ use crate :: {
23
+ borrowed:: { tag:: parse_tag, Signature , Tag } ,
24
+ tests:: { borrowed:: fixture_bytes, borrowed:: tag:: tag_fixture} ,
25
+ Kind , Sign , Time ,
26
+ } ;
27
+ use bstr:: ByteSlice ;
25
28
26
29
#[ test]
27
30
fn signed ( ) {
28
31
let fixture = fixture_bytes ( "signed.txt" ) ;
29
32
assert_eq ! ( parse_tag( & fixture) . unwrap( ) . 1 , tag_fixture( 9000 ) ) ;
30
33
}
34
+
35
+ #[ test]
36
+ fn empty ( ) {
37
+ let fixture = fixture_bytes ( "empty.txt" ) ;
38
+ assert_eq ! (
39
+ parse_tag( & fixture) . unwrap( ) . 1 ,
40
+ Tag {
41
+ target: b"01dd4e2a978a9f5bd773dae6da7aa4a5ac1cdbbc" . as_bstr( ) ,
42
+ name: b"empty" . as_bstr( ) ,
43
+ target_kind: Kind :: Commit ,
44
+ message: b"" . as_bstr( ) ,
45
+ signature: Signature {
46
+ name: b"Sebastian Thiel" . as_bstr( ) ,
47
+ email: b"sebastian.thiel@icloud.com" . as_bstr( ) ,
48
+ time: Time {
49
+ time: 1592381636 ,
50
+ offset: 28800 ,
51
+ sign: Sign :: Plus ,
52
+ } ,
53
+ } ,
54
+ pgp_signature: None
55
+ }
56
+ ) ;
57
+ }
58
+
59
+ #[ test]
60
+ fn with_newlines ( ) {
61
+ let fixture = fixture_bytes ( "with-newlines.txt" ) ;
62
+ assert_eq ! (
63
+ parse_tag( & fixture) . unwrap( ) . 1 ,
64
+ Tag {
65
+ target: b"ebdf205038b66108c0331aa590388431427493b7" . as_bstr( ) ,
66
+ name: b"baz" . as_bstr( ) ,
67
+ target_kind: Kind :: Commit ,
68
+ message: b"hello\n \n world" . as_bstr( ) ,
69
+ signature: Signature {
70
+ name: b"Sebastian Thiel" . as_bstr( ) ,
71
+ email: b"sebastian.thiel@icloud.com" . as_bstr( ) ,
72
+ time: Time {
73
+ time: 1592311808 ,
74
+ offset: 28800 ,
75
+ sign: Sign :: Plus ,
76
+ } ,
77
+ } ,
78
+ pgp_signature: None
79
+ }
80
+ ) ;
81
+ }
82
+
83
+ #[ test]
84
+ fn whitespace ( ) {
85
+ let fixture = fixture_bytes ( "whitespace.txt" ) ;
86
+ assert_eq ! (
87
+ parse_tag( & fixture) . unwrap( ) . 1 ,
88
+ Tag {
89
+ target: b"01dd4e2a978a9f5bd773dae6da7aa4a5ac1cdbbc" . as_bstr( ) ,
90
+ name: b"whitespace" . as_bstr( ) ,
91
+ target_kind: Kind :: Commit ,
92
+ message: b" \t tab\n newline\n \n last-with-trailer\n " . as_bstr( ) , // odd, was created with \n\n actually
93
+ signature: Signature {
94
+ name: b"Sebastian Thiel" . as_bstr( ) ,
95
+ email: b"sebastian.thiel@icloud.com" . as_bstr( ) ,
96
+ time: Time {
97
+ time: 1592382888 ,
98
+ offset: 28800 ,
99
+ sign: Sign :: Plus ,
100
+ } ,
101
+ } ,
102
+ pgp_signature: None
103
+ }
104
+ ) ;
105
+ }
31
106
}
32
107
33
108
fn tag_fixture ( offset : i32 ) -> Tag < ' static > {
0 commit comments