Skip to content

Commit 4ee7884

Browse files
committed
multiboot2: more unit tests
1 parent c47b7ac commit 4ee7884

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

multiboot2/src/boot_loader_name.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ mod tests {
121121
assert_eq!(bytes, &get_bytes()[..tag.size()]);
122122
assert_eq!(tag.name(), Ok("hello"));
123123

124+
// With terminating null.
125+
let tag = BootLoaderNameTag::new("hello\0");
126+
let bytes = tag.as_bytes();
127+
assert_eq!(bytes, &get_bytes()[..tag.size()]);
128+
assert_eq!(tag.name(), Ok("hello"));
129+
124130
// test also some bigger message
125131
let tag = BootLoaderNameTag::new("AbCdEfGhUjK YEAH");
126132
assert_eq!(tag.name(), Ok("AbCdEfGhUjK YEAH"));

multiboot2/src/command_line.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ mod tests {
115115
assert_eq!(bytes, &get_bytes()[..tag.size()]);
116116
assert_eq!(tag.cmdline(), Ok("hello"));
117117

118+
// With terminating null.
119+
let tag = CommandLineTag::new("hello\0");
120+
let bytes = tag.as_bytes();
121+
assert_eq!(bytes, &get_bytes()[..tag.size()]);
122+
assert_eq!(tag.cmdline(), Ok("hello"));
123+
118124
// test also some bigger message
119125
let tag = CommandLineTag::new("AbCdEfGhUjK YEAH");
120126
assert_eq!(tag.cmdline(), Ok("AbCdEfGhUjK YEAH"));

multiboot2/src/module.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ mod tests {
166166
assert_eq!(bytes, &get_bytes()[..tag.size()]);
167167
assert_eq!(tag.cmdline(), Ok("hello"));
168168

169+
// With terminating null.
170+
let tag = ModuleTag::new(0xff00, 0xffff, "hello\0");
171+
let bytes = tag.as_bytes();
172+
assert_eq!(bytes, &get_bytes()[..tag.size()]);
173+
assert_eq!(tag.cmdline(), Ok("hello"));
174+
169175
// test also some bigger message
170176
let tag = ModuleTag::new(0, 1, "AbCdEfGhUjK YEAH");
171177
assert_eq!(tag.cmdline(), Ok("AbCdEfGhUjK YEAH"));

0 commit comments

Comments
 (0)