mirror of https://github.com/Y2Z/monolith
Merge pull request #256 from snshn/more-tests-fixes-and-improvements
More tests, fixes, improvementspull/262/head v2.5.0
commit
22a031af5d
File diff suppressed because it is too large
Load Diff
@ -1,53 +0,0 @@
|
|||||||
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
|
|
||||||
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
|
|
||||||
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
|
|
||||||
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
|
|
||||||
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝
|
|
||||||
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod passing {
|
|
||||||
use crate::css;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_input_single_quotes() {
|
|
||||||
assert_eq!(css::enquote(str!(""), false), "''");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn empty_input_double_quotes() {
|
|
||||||
assert_eq!(css::enquote(str!(""), true), "\"\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn apostrophes_single_quotes() {
|
|
||||||
assert_eq!(
|
|
||||||
css::enquote(str!("It's a lovely day, don't you think?"), false),
|
|
||||||
"'It\\'s a lovely day, don\\'t you think?'"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn apostrophes_double_quotes() {
|
|
||||||
assert_eq!(
|
|
||||||
css::enquote(str!("It's a lovely day, don't you think?"), true),
|
|
||||||
"\"It's a lovely day, don't you think?\""
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn feet_and_inches_single_quotes() {
|
|
||||||
assert_eq!(
|
|
||||||
css::enquote(str!("5'2\", 6'5\""), false),
|
|
||||||
"'5\\'2\", 6\\'5\"'"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn feet_and_inches_double_quotes() {
|
|
||||||
assert_eq!(
|
|
||||||
css::enquote(str!("5'2\", 6'5\""), true),
|
|
||||||
"\"5'2\\\", 6'5\\\"\""
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,2 @@
|
|||||||
mod embed_css;
|
mod embed_css;
|
||||||
mod enquote;
|
|
||||||
mod is_image_url_prop;
|
mod is_image_url_prop;
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
|
|
||||||
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
|
|
||||||
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
|
|
||||||
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
|
|
||||||
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝
|
|
||||||
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod passing {
|
|
||||||
use reqwest::Url;
|
|
||||||
|
|
||||||
use crate::url;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn http_url() {
|
|
||||||
assert!(url::is_http_or_https_url(&Url::parse("http://kernel.org").unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn https_url() {
|
|
||||||
assert!(url::is_http_or_https_url(&Url::parse("https://www.rust-lang.org/").unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn http_url_with_backslashes() {
|
|
||||||
assert!(url::is_http_or_https_url(&Url::parse("http:\\\\freebsd.org\\").unwrap()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ███████╗ █████╗ ██╗██╗ ██╗███╗ ██╗ ██████╗
|
|
||||||
// ██╔════╝██╔══██╗██║██║ ██║████╗ ██║██╔════╝
|
|
||||||
// █████╗ ███████║██║██║ ██║██╔██╗ ██║██║ ███╗
|
|
||||||
// ██╔══╝ ██╔══██║██║██║ ██║██║╚██╗██║██║ ██║
|
|
||||||
// ██║ ██║ ██║██║███████╗██║██║ ╚████║╚██████╔╝
|
|
||||||
// ╚═╝ ╚═╝ ╚═╝╚═╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod failing {
|
|
||||||
use reqwest::Url;
|
|
||||||
|
|
||||||
use crate::url;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn url_with_no_protocol() {
|
|
||||||
assert!(!url::is_http_or_https_url(&Url::parse("//kernel.org").unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn dot_slash_filename() {
|
|
||||||
assert!(!url::is_http_or_https_url(&Url::parse("./index.html").unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn just_filename() {
|
|
||||||
assert!(!url::is_http_or_https_url(&Url::parse("some-local-page.htm").unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn https_ip_port_url() {
|
|
||||||
assert!(!url::is_http_or_https_url(&Url::parse("ftp://1.2.3.4/www/index.html").unwrap()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn data_url() {
|
|
||||||
assert!(!url::is_http_or_https_url(
|
|
||||||
&Url::parse("data:text/html;base64,V2VsY29tZSBUbyBUaGUgUGFydHksIDxiPlBhbDwvYj4h").unwrap()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue