mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Add tests for conversion functions in text.rs
This commit is contained in:
parent
0fc84d19b2
commit
347c547e10
1 changed files with 13 additions and 4 deletions
|
@ -343,10 +343,7 @@ pub(crate) fn matches_glob(text: &str, search: &str) -> bool {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::text::without_combining;
|
use super::*;
|
||||||
use crate::text::{
|
|
||||||
extract_av_tags, strip_av_tags, strip_html, strip_html_preserving_media_filenames, AVTag,
|
|
||||||
};
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -395,4 +392,16 @@ mod test {
|
||||||
assert!(matches!(without_combining("test"), Cow::Borrowed(_)));
|
assert!(matches!(without_combining("test"), Cow::Borrowed(_)));
|
||||||
assert!(matches!(without_combining("Über"), Cow::Owned(_)));
|
assert!(matches!(without_combining("Über"), Cow::Owned(_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn conversion() {
|
||||||
|
assert_eq!(&to_re(r"[te\*st]"), r"\[te\*st\]");
|
||||||
|
assert_eq!(&to_custom_re("f_o*", r"\d"), r"f\do\d*");
|
||||||
|
assert_eq!(&to_sql("%f_o*"), r"\%f_o%");
|
||||||
|
assert_eq!(&to_text(r"\*\_*_"), "*_*_");
|
||||||
|
assert_eq!(&escape_sql(r"1\2%3_"), r"1\\2\%3\_");
|
||||||
|
assert!(is_glob(r"\\\\_"));
|
||||||
|
assert!(!is_glob(r"\\\_"));
|
||||||
|
assert!(matches_glob("foo*bar123", r"foo\*bar*"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue