ntfsanitise 0.3.0

Sanitise filenames for use on NTFS filesystems
Documentation
#[cfg(feature = "std")]
mod path;
#[cfg(all(windows, feature = "std"))]
mod windows;

#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::string::String;

#[cfg(feature = "alloc")]
use proptest::property_test;

#[cfg(feature = "alloc")]
use crate::{generate_banned, sanitise};
use crate::{is_clean, is_dirty};

#[test]
fn clean() {
	let clean = ["a", "bb", "ccc"];
	for example in clean {
		assert!(is_clean(example));
		assert!(!is_dirty(example));

		#[cfg(feature = "alloc")]
		assert_eq!(example, sanitise(example, "_"));
	}
}

#[test]
fn dirty() {
	let dirty = ["<", "?", ":"];
	for example in dirty {
		assert!(!is_clean(example));
		assert!(is_dirty(example));

		#[cfg(feature = "alloc")]
		assert_eq!(String::from("_"), sanitise(example, "_"));
	}
}

#[test]
fn empty() {
	assert!(is_clean(""));
	assert!(!is_dirty(""));
	#[cfg(feature = "alloc")]
	assert_eq!("", sanitise("", "_"));
}

#[property_test]
#[cfg(feature = "alloc")]
fn random_clean(#[strategy = r"[\w \.,]+"] input: String) {
	assert!(is_clean(&input));
	assert!(!is_dirty(&input));
	assert_eq!(input, sanitise(&input, "_"));
}

#[property_test]
#[cfg(feature = "alloc")]
fn random_dirty(#[strategy = r#"[\t\?\:<>/\\\|\*"]+"#] input: String) {
	assert!(!is_clean(&input));
	assert!(is_dirty(&input));
	assert_eq!(input.len(), sanitise(&input, "X").chars().filter(|c| *c == 'X').count());
}

#[property_test]
#[cfg(feature = "alloc")]
fn sanitise_sanitises(input: String) {
	assert_eq!(sanitise(&input, "_"), input.replace(generate_banned(), "_"));
}