File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ impl<'a> HeaderRecord<'a> {
139
139
/// * `tag` - the tag identifier
140
140
/// * `value` - the value. Can be any type convertible into a string. Preferably numbers or
141
141
/// strings.
142
- pub fn push_tag < V : ToString > ( & mut self , tag : & ' a [ u8 ] , value : & V ) -> & mut Self {
142
+ pub fn push_tag < V : ToString > ( & mut self , tag : & ' a [ u8 ] , value : V ) -> & mut Self {
143
143
self . tags . push ( ( tag, value. to_string ( ) . into_bytes ( ) ) ) ;
144
144
self
145
145
}
@@ -156,3 +156,22 @@ impl<'a> HeaderRecord<'a> {
156
156
out
157
157
}
158
158
}
159
+
160
+ #[ cfg( test) ]
161
+ mod tests {
162
+ use super :: HeaderRecord ;
163
+
164
+ #[ test]
165
+ fn test_push_tag ( ) {
166
+ let mut record = HeaderRecord :: new ( b"HD" ) ;
167
+ record. push_tag ( b"X1" , 0 ) ;
168
+ record. push_tag ( b"X2" , & 0 ) ;
169
+
170
+ let x = "x" . to_string ( ) ;
171
+ record. push_tag ( b"X3" , x. as_str ( ) ) ;
172
+ record. push_tag ( b"X4" , & x) ;
173
+ record. push_tag ( b"X5" , x) ;
174
+
175
+ assert_eq ! ( record. to_bytes( ) , b"@HD\t X1:0\t X2:0\t X3:x\t X4:x\t X5:x" ) ;
176
+ }
177
+ }
You can’t perform that action at this time.
0 commit comments