#[cfg(test)]
mod tests {
use random_zh::{RandomZhOptions, random_zh};
#[test]
fn test_random_zh_default() {
let chars = random_zh(RandomZhOptions::default());
assert_eq!(chars.len(), 1);
}
#[test]
fn test_random_zh_with_count() {
let count = 10;
let chars = random_zh(RandomZhOptions {
count: Some(count),
..Default::default()
});
assert_eq!(chars.len(), count);
}
#[test]
fn test_random_zh_allow_duplicates() {
let count = 50;
let chars = random_zh(RandomZhOptions {
count: Some(count),
stroke_count_range: Some((1, 1)),
allow_duplicates: true,
..Default::default()
});
assert_eq!(chars.len(), count);
}
#[test]
fn test_random_zh_disallow_duplicates() {
let count = 50;
let chars = random_zh(RandomZhOptions {
count: Some(count),
stroke_count_range: Some((1, 1)),
allow_duplicates: false,
..Default::default()
});
assert!(chars.len() < count);
}
#[test]
fn test_empty_candidates() {
let chars = random_zh(RandomZhOptions {
level_range: Some((99, 100)), stroke_count_range: Some((99, 100)), count: Some(10),
..Default::default()
});
assert!(chars.is_empty());
}
}