catgirl-cooking/src/tests.rs

49 lines
1.2 KiB
Rust

#[cfg(test)]
mod tests {
// Note this useful idiom: importing names from outer (for mod tests) scope.
use crate::networking::parse_tags;
use crate::structures::*;
#[test]
fn test_tag_new() {
assert_eq!(Tag::new("test".to_string()), Tag('#', "test".to_string()));
}
#[test]
fn test_tag_from_string() {
assert_eq!(
Tag::from_string("#test".to_string()),
Tag('#', "test".to_string())
);
}
#[test]
fn test_tag_to_string() {
assert_eq!(
Tag('#', "test".to_string()).to_string(),
"#test".to_string()
);
}
#[test]
fn test_shortcode_conversion() {
assert_eq!(
construct_shortcode("Test SHORtcode".to_string()),
"test-shortcode".to_string()
);
}
#[test]
fn test_parse_tags() {
assert_eq!(
parse_tags("one,TWO ,tHRee, #four".to_string()),
vec![
Tag('#', "one".to_string()),
Tag('#', "two".to_string()),
Tag('#', "three".to_string()),
Tag('#', "four".to_string())
]
);
}
}