mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
option_parser: Move test_option_parser to option_parser crate
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
868d1f6902
commit
d295de4cd5
@ -334,3 +334,27 @@ impl FromStr for StringList {
|
||||
Ok(StringList(string_list))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_option_parser() {
|
||||
let mut parser = OptionParser::new();
|
||||
parser
|
||||
.add("size")
|
||||
.add("mergeable")
|
||||
.add("hotplug_method")
|
||||
.add("hotplug_size");
|
||||
|
||||
assert!(parser.parse("size=128M,hanging_param").is_err());
|
||||
assert!(parser.parse("size=128M,too_many_equals=foo=bar").is_err());
|
||||
assert!(parser.parse("size=128M,file=/dev/shm").is_err());
|
||||
assert!(parser.parse("size=128M").is_ok());
|
||||
|
||||
assert_eq!(parser.get("size"), Some("128M".to_owned()));
|
||||
assert!(!parser.is_set("mergeable"));
|
||||
assert!(parser.is_set("size"));
|
||||
}
|
||||
}
|
||||
|
@ -2692,25 +2692,6 @@ impl VmConfig {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_option_parser() {
|
||||
let mut parser = OptionParser::new();
|
||||
parser
|
||||
.add("size")
|
||||
.add("mergeable")
|
||||
.add("hotplug_method")
|
||||
.add("hotplug_size");
|
||||
|
||||
assert!(parser.parse("size=128M,hanging_param").is_err());
|
||||
assert!(parser.parse("size=128M,too_many_equals=foo=bar").is_err());
|
||||
assert!(parser.parse("size=128M,file=/dev/shm").is_err());
|
||||
assert!(parser.parse("size=128M").is_ok());
|
||||
|
||||
assert_eq!(parser.get("size"), Some("128M".to_owned()));
|
||||
assert!(!parser.is_set("mergeable"));
|
||||
assert!(parser.is_set("size"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cpu_parsing() -> Result<()> {
|
||||
assert_eq!(CpusConfig::parse("")?, CpusConfig::default());
|
||||
|
Loading…
Reference in New Issue
Block a user