Quellcode durchsuchen

multiboot2: more unit tests

Philipp Schuster vor 8 Monaten
Ursprung
Commit
4ee7884583
3 geänderte Dateien mit 18 neuen und 0 gelöschten Zeilen
  1. 6 0
      multiboot2/src/boot_loader_name.rs
  2. 6 0
      multiboot2/src/command_line.rs
  3. 6 0
      multiboot2/src/module.rs

+ 6 - 0
multiboot2/src/boot_loader_name.rs

@@ -121,6 +121,12 @@ mod tests {
         assert_eq!(bytes, &get_bytes()[..tag.size()]);
         assert_eq!(tag.name(), Ok("hello"));
 
+        // With terminating null.
+        let tag = BootLoaderNameTag::new("hello\0");
+        let bytes = tag.as_bytes();
+        assert_eq!(bytes, &get_bytes()[..tag.size()]);
+        assert_eq!(tag.name(), Ok("hello"));
+
         // test also some bigger message
         let tag = BootLoaderNameTag::new("AbCdEfGhUjK YEAH");
         assert_eq!(tag.name(), Ok("AbCdEfGhUjK YEAH"));

+ 6 - 0
multiboot2/src/command_line.rs

@@ -115,6 +115,12 @@ mod tests {
         assert_eq!(bytes, &get_bytes()[..tag.size()]);
         assert_eq!(tag.cmdline(), Ok("hello"));
 
+        // With terminating null.
+        let tag = CommandLineTag::new("hello\0");
+        let bytes = tag.as_bytes();
+        assert_eq!(bytes, &get_bytes()[..tag.size()]);
+        assert_eq!(tag.cmdline(), Ok("hello"));
+
         // test also some bigger message
         let tag = CommandLineTag::new("AbCdEfGhUjK YEAH");
         assert_eq!(tag.cmdline(), Ok("AbCdEfGhUjK YEAH"));

+ 6 - 0
multiboot2/src/module.rs

@@ -166,6 +166,12 @@ mod tests {
         assert_eq!(bytes, &get_bytes()[..tag.size()]);
         assert_eq!(tag.cmdline(), Ok("hello"));
 
+        // With terminating null.
+        let tag = ModuleTag::new(0xff00, 0xffff, "hello\0");
+        let bytes = tag.as_bytes();
+        assert_eq!(bytes, &get_bytes()[..tag.size()]);
+        assert_eq!(tag.cmdline(), Ok("hello"));
+
         // test also some bigger message
         let tag = ModuleTag::new(0, 1, "AbCdEfGhUjK YEAH");
         assert_eq!(tag.cmdline(), Ok("AbCdEfGhUjK YEAH"));