mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Auto merge of #19868 - CYBAI:specific-assertion, r=emilio
Use specific assertions Similar to #19865 r? jdm Note: Should I squash all the commits into one commit? --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because it should not break anything <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19868) <!-- Reviewable:end -->
This commit is contained in:
commit
c9ba16f9fb
40 changed files with 90 additions and 90 deletions
|
@ -442,7 +442,7 @@ fn wait_for_response(response: &mut Response, target: Target, done_chan: &mut Do
|
|||
// We should still send the body across as a chunk
|
||||
target.process_response_chunk(vec.clone());
|
||||
} else {
|
||||
assert!(*body == ResponseBody::Empty)
|
||||
assert_eq!(*body, ResponseBody::Empty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -585,7 +585,7 @@ impl HttpCache {
|
|||
/// Freshening Stored Responses upon Validation.
|
||||
/// <https://tools.ietf.org/html/rfc7234#section-4.3.4>
|
||||
pub fn refresh(&mut self, request: &Request, response: Response, done_chan: &mut DoneChannel) -> Option<Response> {
|
||||
assert!(response.status == Some(StatusCode::NotModified));
|
||||
assert_eq!(response.status, Some(StatusCode::NotModified));
|
||||
let entry_key = CacheKey::new(request.clone());
|
||||
if let Some(cached_resources) = self.entries.get_mut(&entry_key) {
|
||||
for cached_resource in cached_resources.iter_mut() {
|
||||
|
|
|
@ -44,13 +44,13 @@ fn test_path_match() {
|
|||
|
||||
#[test]
|
||||
fn test_default_path() {
|
||||
assert!(&*Cookie::default_path("/foo/bar/baz/") == "/foo/bar/baz");
|
||||
assert!(&*Cookie::default_path("/foo/bar/baz") == "/foo/bar");
|
||||
assert!(&*Cookie::default_path("/foo/") == "/foo");
|
||||
assert!(&*Cookie::default_path("/foo") == "/");
|
||||
assert!(&*Cookie::default_path("/") == "/");
|
||||
assert!(&*Cookie::default_path("") == "/");
|
||||
assert!(&*Cookie::default_path("foo") == "/");
|
||||
assert_eq!(&*Cookie::default_path("/foo/bar/baz/"), "/foo/bar/baz");
|
||||
assert_eq!(&*Cookie::default_path("/foo/bar/baz"), "/foo/bar");
|
||||
assert_eq!(&*Cookie::default_path("/foo/"), "/foo");
|
||||
assert_eq!(&*Cookie::default_path("/foo"), "/");
|
||||
assert_eq!(&*Cookie::default_path("/"), "/");
|
||||
assert_eq!(&*Cookie::default_path(""), "/");
|
||||
assert_eq!(&*Cookie::default_path("foo"), "/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -69,7 +69,7 @@ fn fn_cookie_constructor() {
|
|||
let cookie = cookie_rs::Cookie::parse(" baz = bar; Domain = ").unwrap();
|
||||
assert!(Cookie::new_wrapped(cookie.clone(), url, CookieSource::HTTP).is_some());
|
||||
let cookie = Cookie::new_wrapped(cookie, url, CookieSource::HTTP).unwrap();
|
||||
assert!(&**cookie.cookie.domain().as_ref().unwrap() == "example.com");
|
||||
assert_eq!(&**cookie.cookie.domain().as_ref().unwrap(), "example.com");
|
||||
|
||||
// cookie public domains test
|
||||
let cookie = cookie_rs::Cookie::parse(" baz = bar; Domain = gov.ac").unwrap();
|
||||
|
@ -88,11 +88,11 @@ fn fn_cookie_constructor() {
|
|||
|
||||
let cookie = cookie_rs::Cookie::parse(" baz = bar ; Secure; Path = /foo/bar/").unwrap();
|
||||
let cookie = Cookie::new_wrapped(cookie, url, CookieSource::HTTP).unwrap();
|
||||
assert!(cookie.cookie.value() == "bar");
|
||||
assert!(cookie.cookie.name() == "baz");
|
||||
assert_eq!(cookie.cookie.value(), "bar");
|
||||
assert_eq!(cookie.cookie.name(), "baz");
|
||||
assert!(cookie.cookie.secure());
|
||||
assert!(&cookie.cookie.path().as_ref().unwrap()[..] == "/foo/bar/");
|
||||
assert!(&cookie.cookie.domain().as_ref().unwrap()[..] == "example.com");
|
||||
assert_eq!(&cookie.cookie.path().as_ref().unwrap()[..], "/foo/bar/");
|
||||
assert_eq!(&cookie.cookie.domain().as_ref().unwrap()[..], "example.com");
|
||||
assert!(cookie.host_only);
|
||||
|
||||
let u = &ServoUrl::parse("http://example.com/foobar").unwrap();
|
||||
|
@ -192,11 +192,11 @@ fn test_sort_order() {
|
|||
let b = Cookie::new_wrapped(b, url, CookieSource::HTTP).unwrap();
|
||||
|
||||
assert!(b.cookie.path().as_ref().unwrap().len() > a.cookie.path().as_ref().unwrap().len());
|
||||
assert!(CookieStorage::cookie_comparator(&a, &b) == Ordering::Greater);
|
||||
assert!(CookieStorage::cookie_comparator(&b, &a) == Ordering::Less);
|
||||
assert!(CookieStorage::cookie_comparator(&a, &a_prime) == Ordering::Less);
|
||||
assert!(CookieStorage::cookie_comparator(&a_prime, &a) == Ordering::Greater);
|
||||
assert!(CookieStorage::cookie_comparator(&a, &a) == Ordering::Equal);
|
||||
assert_eq!(CookieStorage::cookie_comparator(&a, &b), Ordering::Greater);
|
||||
assert_eq!(CookieStorage::cookie_comparator(&b, &a), Ordering::Less);
|
||||
assert_eq!(CookieStorage::cookie_comparator(&a, &a_prime), Ordering::Less);
|
||||
assert_eq!(CookieStorage::cookie_comparator(&a_prime, &a), Ordering::Greater);
|
||||
assert_eq!(CookieStorage::cookie_comparator(&a, &a), Ordering::Equal);
|
||||
}
|
||||
|
||||
fn add_cookie_to_storage(storage: &mut CookieStorage, url: &ServoUrl, cookie_str: &str)
|
||||
|
|
|
@ -74,7 +74,7 @@ fn test_fetch_on_bad_port_is_network_error() {
|
|||
let fetch_response = fetch(&mut request, None);
|
||||
assert!(fetch_response.is_network_error());
|
||||
let fetch_error = fetch_response.get_network_error().unwrap();
|
||||
assert!(fetch_error == &NetworkError::Internal("Request attempted on bad port".into()))
|
||||
assert_eq!(fetch_error, &NetworkError::Internal("Request attempted on bad port".into()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -110,7 +110,7 @@ fn test_fetch_aboutblank() {
|
|||
request.referrer = Referrer::NoReferrer;
|
||||
let fetch_response = fetch(&mut request, None);
|
||||
assert!(!fetch_response.is_network_error());
|
||||
assert!(*fetch_response.body.lock().unwrap() == ResponseBody::Done(vec![]));
|
||||
assert_eq!(*fetch_response.body.lock().unwrap(), ResponseBody::Done(vec![]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -166,7 +166,7 @@ fn test_fetch_file() {
|
|||
assert!(!fetch_response.is_network_error());
|
||||
assert_eq!(fetch_response.headers.len(), 1);
|
||||
let content_type: &ContentType = fetch_response.headers.get().unwrap();
|
||||
assert!(**content_type == Mime(TopLevel::Text, SubLevel::Css, vec![]));
|
||||
assert_eq!(**content_type, Mime(TopLevel::Text, SubLevel::Css, vec![]));
|
||||
|
||||
let resp_body = fetch_response.body.lock().unwrap();
|
||||
let mut file = File::open(path).unwrap();
|
||||
|
|
|
@ -92,7 +92,7 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() {
|
|||
list.push(HstsEntry::new("mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded, Some(0)).unwrap());
|
||||
|
||||
assert!(list.is_host_secure("mozilla.org") == false)
|
||||
assert_eq!(list.is_host_secure("mozilla.org"), false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -107,7 +107,7 @@ fn test_push_entry_to_hsts_list_should_not_add_subdomains_whose_superdomain_is_a
|
|||
list.push(HstsEntry::new("servo.mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded, None).unwrap());
|
||||
|
||||
assert!(list.entries_map.get("mozilla.org").unwrap().len() == 1)
|
||||
assert_eq!(list.entries_map.get("mozilla.org").unwrap().len(), 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -139,7 +139,7 @@ fn test_push_entry_to_hsts_list_should_not_create_duplicate_entry() {
|
|||
list.push(HstsEntry::new("mozilla.org".to_owned(),
|
||||
IncludeSubdomains::NotIncluded, None).unwrap());
|
||||
|
||||
assert!(list.entries_map.get("mozilla.org").unwrap().len() == 1)
|
||||
assert_eq!(list.entries_map.get("mozilla.org").unwrap().len(), 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue