mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Format remaining files
This commit is contained in:
parent
bf47f90da6
commit
cb07debcb6
252 changed files with 5944 additions and 3744 deletions
|
@ -12,48 +12,104 @@ fn no_value() {
|
|||
|
||||
#[test]
|
||||
fn width_one_value() {
|
||||
let first_descriptor = Descriptor { wid: Some(320), den: None };
|
||||
let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: Some(320),
|
||||
den: None,
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "small-image.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg, 320w"), sources);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn width_two_value() {
|
||||
let first_descriptor = Descriptor { wid: Some(320), den: None };
|
||||
let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor };
|
||||
let second_descriptor = Descriptor { wid: Some(480), den: None };
|
||||
let second_imagesource = ImageSource { url: "medium-image.jpg".to_string(), descriptor: second_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: Some(320),
|
||||
den: None,
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "small-image.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let second_descriptor = Descriptor {
|
||||
wid: Some(480),
|
||||
den: None,
|
||||
};
|
||||
let second_imagesource = ImageSource {
|
||||
url: "medium-image.jpg".to_string(),
|
||||
descriptor: second_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource, second_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg 320w, medium-image.jpg 480w"), sources);
|
||||
assert_eq!(
|
||||
parse_a_srcset_attribute("small-image.jpg 320w, medium-image.jpg 480w"),
|
||||
sources
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn width_three_value() {
|
||||
let first_descriptor = Descriptor { wid: Some(320), den: None };
|
||||
let first_imagesource = ImageSource { url: "smallImage.jpg".to_string(), descriptor: first_descriptor };
|
||||
let second_descriptor = Descriptor { wid: Some(480), den: None };
|
||||
let second_imagesource = ImageSource { url: "mediumImage.jpg".to_string(), descriptor: second_descriptor };
|
||||
let third_descriptor = Descriptor { wid: Some(800), den: None };
|
||||
let third_imagesource = ImageSource { url: "largeImage.jpg".to_string(), descriptor: third_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: Some(320),
|
||||
den: None,
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "smallImage.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let second_descriptor = Descriptor {
|
||||
wid: Some(480),
|
||||
den: None,
|
||||
};
|
||||
let second_imagesource = ImageSource {
|
||||
url: "mediumImage.jpg".to_string(),
|
||||
descriptor: second_descriptor,
|
||||
};
|
||||
let third_descriptor = Descriptor {
|
||||
wid: Some(800),
|
||||
den: None,
|
||||
};
|
||||
let third_imagesource = ImageSource {
|
||||
url: "largeImage.jpg".to_string(),
|
||||
descriptor: third_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource, second_imagesource, third_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("smallImage.jpg 320w,
|
||||
assert_eq!(
|
||||
parse_a_srcset_attribute(
|
||||
"smallImage.jpg 320w,
|
||||
mediumImage.jpg 480w,
|
||||
largeImage.jpg 800w"), sources);
|
||||
largeImage.jpg 800w"
|
||||
),
|
||||
sources
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn density_value() {
|
||||
let first_descriptor = Descriptor { wid: None, den: Some(1.0) };
|
||||
let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: None,
|
||||
den: Some(1.0),
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "small-image.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg 1x"), sources);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_descriptor() {
|
||||
let first_descriptor = Descriptor { wid: None, den: None };
|
||||
let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: None,
|
||||
den: None,
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "small-image.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg"), sources);
|
||||
}
|
||||
|
@ -62,23 +118,47 @@ fn without_descriptor() {
|
|||
#[test]
|
||||
fn two_descriptor() {
|
||||
let empty_vec = Vec::new();
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg 320w 1.1x"), empty_vec);
|
||||
assert_eq!(
|
||||
parse_a_srcset_attribute("small-image.jpg 320w 1.1x"),
|
||||
empty_vec
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decimal_descriptor() {
|
||||
let first_descriptor = Descriptor { wid: None, den: Some(2.2) };
|
||||
let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: None,
|
||||
den: Some(2.2),
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "small-image.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg 2.2x"), sources);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn different_descriptor() {
|
||||
let first_descriptor = Descriptor { wid: Some(320), den: None };
|
||||
let first_imagesource = ImageSource { url: "small-image.jpg".to_string(), descriptor: first_descriptor };
|
||||
let second_descriptor = Descriptor { wid: None, den: Some(2.2) };
|
||||
let second_imagesource = ImageSource { url: "medium-image.jpg".to_string(), descriptor: second_descriptor };
|
||||
let first_descriptor = Descriptor {
|
||||
wid: Some(320),
|
||||
den: None,
|
||||
};
|
||||
let first_imagesource = ImageSource {
|
||||
url: "small-image.jpg".to_string(),
|
||||
descriptor: first_descriptor,
|
||||
};
|
||||
let second_descriptor = Descriptor {
|
||||
wid: None,
|
||||
den: Some(2.2),
|
||||
};
|
||||
let second_imagesource = ImageSource {
|
||||
url: "medium-image.jpg".to_string(),
|
||||
descriptor: second_descriptor,
|
||||
};
|
||||
let sources = &[first_imagesource, second_imagesource];
|
||||
assert_eq!(parse_a_srcset_attribute("small-image.jpg 320w, medium-image.jpg 2.2x"), sources);
|
||||
assert_eq!(
|
||||
parse_a_srcset_attribute("small-image.jpg 320w, medium-image.jpg 2.2x"),
|
||||
sources
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue