pub struct Options<'a> {
pub separate_before_non_alphabets: bool,
pub separate_after_non_alphabets: bool,
pub separators: &'a str,
pub keep: &'a str,
}
impl<'a> Options<'a> {
pub fn new(
separate_before_non_alphabets: bool,
separate_after_non_alphabets: bool,
separators: &'a str,
keep: &'a str,
) -> Self {
Self {
separate_before_non_alphabets,
separate_after_non_alphabets,
separators,
keep,
}
}
}
impl Default for Options<'_> {
fn default() -> Self {
Self {
separate_before_non_alphabets: false,
separate_after_non_alphabets: true,
separators: "",
keep: "",
}
}
}
#[cfg(test)]
mod tests_of_options {
use super::*;
#[test]
fn test_of_new() {
let opts = Options::new(true, true, "-_", "#@");
assert_eq!(opts.separate_before_non_alphabets, true);
assert_eq!(opts.separate_after_non_alphabets, true);
assert_eq!(opts.separators, "-_");
assert_eq!(opts.keep, "#@");
}
#[test]
fn test_of_default() {
let opts = Options::default();
assert_eq!(opts.separate_before_non_alphabets, false);
assert_eq!(opts.separate_after_non_alphabets, true);
assert_eq!(opts.separators, "");
assert_eq!(opts.keep, "");
}
#[test]
fn test_of_default_by_fields() {
let opts = Options {
separate_before_non_alphabets: true,
separators: "-#@",
..Default::default()
};
assert_eq!(opts.separate_before_non_alphabets, true);
assert_eq!(opts.separate_after_non_alphabets, true);
assert_eq!(opts.separators, "-#@");
assert_eq!(opts.keep, "");
}
}