Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Oct 29, 2024
1 parent da094d9 commit 3caef6d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cidre/src/cg/image/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn animate_image_at_url_with_block(
#[inline]
pub fn animate_image_at_url(
url: &cf::Url,
options: Option<&cf::DictionaryOf<OptKey, cf::Number>>,
options: Option<&Opts>,
f: impl FnMut(/* index: */ usize, /* image: */ &cg::Image, /* stop: */ &mut bool) + 'static,
) -> os::Result {
let mut block = cg::ImageAnimationBlock::new3(f);
Expand All @@ -79,7 +79,7 @@ pub fn animate_image_at_url(
#[inline]
pub fn animate_image_data_with_block(
data: &cf::Data,
options: Option<&cf::DictionaryOf<OptKey, cf::Number>>,
options: Option<&Opts>,
block: &mut cg::ImageAnimationBlock,
) -> os::Result {
unsafe { CGAnimateImageDataWithBlock(data, options, block).result() }
Expand All @@ -89,7 +89,7 @@ pub fn animate_image_data_with_block(
#[inline]
pub fn animate_image_data(
data: &cf::Data,
options: Option<&cf::DictionaryOf<OptKey, cf::Number>>,
options: Option<&Opts>,
f: impl FnMut(/* index: */ usize, /* image: */ &cg::Image, /* stop: */ &mut bool) + 'static,
) -> os::Result {
let mut block = cg::ImageAnimationBlock::new3(f);
Expand Down Expand Up @@ -125,13 +125,17 @@ mod tests {
#[test]
fn error() {
let url = cf::Url::from_str("foo").unwrap();
match cg::animate_image_at_url(&url, None, |_idx, _img, _stp| {}) {
match cg::animate_image_at_url(&url, None, |_idx, _img, _stp| {
panic!("should not be called");
}) {
Err(ERROR) => {}
x => panic!("failed {x:?}"),
}

let data = cf::Data::from_slice(&[]).unwrap();
match cg::animate_image_data(&data, None, |_idx, _img, _stp| {}) {
match cg::animate_image_data(&data, None, |_idx, _img, _stp| {
panic!("should not be called");
}) {
Err(cg::image_animation_err::CORRUPT_INPUT_IMAGE) => {}
x => panic!("failed {x:?}"),
}
Expand Down

0 comments on commit 3caef6d

Please sign in to comment.