@@ -26,6 +26,8 @@ pub struct ModuleTag {
26
26
impl ModuleTag {
27
27
#[ cfg( feature = "builder" ) ]
28
28
pub fn new ( start : u32 , end : u32 , cmdline : & str ) -> BoxedDst < Self > {
29
+ assert ! ( end > start, "must have a size" ) ;
30
+
29
31
let mut cmdline_bytes: Vec < _ > = cmdline. bytes ( ) . collect ( ) ;
30
32
if !cmdline_bytes. ends_with ( & [ 0 ] ) {
31
33
// terminating null-byte
@@ -135,7 +137,7 @@ mod tests {
135
137
& ( ( TagType :: Module . val ( ) ) . to_le_bytes ( ) ) ,
136
138
& size. to_le_bytes ( ) ,
137
139
& 0_u32 . to_le_bytes ( ) ,
138
- & 0_u32 . to_le_bytes ( ) ,
140
+ & 1_u32 . to_le_bytes ( ) ,
139
141
MSG . as_bytes ( ) ,
140
142
// Null Byte
141
143
& [ 0 ] ,
@@ -161,15 +163,15 @@ mod tests {
161
163
#[ test]
162
164
#[ cfg( feature = "builder" ) ]
163
165
fn test_build_str ( ) {
164
- let tag = ModuleTag :: new ( 0 , 0 , MSG ) ;
166
+ let tag = ModuleTag :: new ( 0 , 1 , MSG ) ;
165
167
let bytes = tag. as_bytes ( ) ;
166
168
assert_eq ! ( bytes, get_bytes( ) ) ;
167
169
assert_eq ! ( tag. cmdline( ) , Ok ( MSG ) ) ;
168
170
169
171
// test also some bigger message
170
- let tag = ModuleTag :: new ( 0 , 0 , "AbCdEfGhUjK YEAH" ) ;
172
+ let tag = ModuleTag :: new ( 0 , 1 , "AbCdEfGhUjK YEAH" ) ;
171
173
assert_eq ! ( tag. cmdline( ) , Ok ( "AbCdEfGhUjK YEAH" ) ) ;
172
- let tag = ModuleTag :: new ( 0 , 0 , "AbCdEfGhUjK YEAH" . repeat ( 42 ) . as_str ( ) ) ;
174
+ let tag = ModuleTag :: new ( 0 , 1 , "AbCdEfGhUjK YEAH" . repeat ( 42 ) . as_str ( ) ) ;
173
175
assert_eq ! ( tag. cmdline( ) , Ok ( "AbCdEfGhUjK YEAH" . repeat( 42 ) . as_str( ) ) ) ;
174
176
}
175
177
}
0 commit comments