mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: prepare common test infrastructure for CLI args
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
12493db144
commit
1f13165fae
24
src/test_util.rs
Normal file
24
src/test_util.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright © 2025 Cyberus Technology GmbH
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use clap::Arg;
|
||||
|
||||
pub fn assert_args_sorted<'a, F: Fn() -> R, R: Iterator<Item = &'a Arg>>(get_base_iter: F) {
|
||||
let iter = get_base_iter().zip(get_base_iter().skip(1));
|
||||
for (arg, next) in iter {
|
||||
assert_ne!(
|
||||
arg.get_id().cmp(next.get_id()),
|
||||
Ordering::Greater,
|
||||
"args not alphabetically sorted: arg={}, next={}",
|
||||
arg.get_id(),
|
||||
next.get_id()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user