clap/clap_generate_fig/tests/completions/mod.rs

29 lines
696 B
Rust
Raw Normal View History

use clap::{App, Arg, ValueHint};
use clap_generate::{generate, generators::*};
use std::fmt;
mod fig;
#[derive(PartialEq, Eq)]
pub struct PrettyString<'a>(pub &'a str);
impl<'a> fmt::Debug for PrettyString<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.0)
}
}
macro_rules! assert_eq {
($left:expr, $right:expr) => {
pretty_assertions::assert_eq!(PrettyString($left), PrettyString($right));
};
}
2021-10-12 12:57:26 +00:00
pub fn common<G: Generator>(gen: G, app: &mut App, name: &str, fixture: &str) {
let mut buf = vec![];
2021-10-12 12:57:26 +00:00
generate(gen, app, name, &mut buf);
let string = String::from_utf8(buf).unwrap();
assert_eq!(&string, fixture);
}