[librsvg/wip/aruiz/rust-pixbuf-loader] pixbuf-loader: add unit test to check error is returned
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/wip/aruiz/rust-pixbuf-loader] pixbuf-loader: add unit test to check error is returned
- Date: Wed, 10 Aug 2022 11:03:27 +0000 (UTC)
commit 93c4ade4d8022b27fb56431274ca7c639bb45a67
Author: Alberto Ruiz <aruiz redhat com>
Date: Tue Aug 9 20:04:00 2022 +0100
pixbuf-loader: add unit test to check error is returned
gdk-pixbuf-loader/src/lib.rs | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/gdk-pixbuf-loader/src/lib.rs b/gdk-pixbuf-loader/src/lib.rs
index 40d992e30..e93c270e5 100644
--- a/gdk-pixbuf-loader/src/lib.rs
+++ b/gdk-pixbuf-loader/src/lib.rs
@@ -310,6 +310,13 @@ mod tests {
</svg>
"#;
+ const SVG_BROKEN: &'static str = r#"<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ <svg
+ width="100px"
+ height="150px"
+ viewBox="0 0 26.458333 26.458333"
+ version="1.1" BROKEN DATA"#;
+
#[test]
fn minimal_svg() {
unsafe extern "C" fn prep_cb(
@@ -369,4 +376,24 @@ mod tests {
unsafe { crate::stop_load(ctx, null_mut()) };
}
+
+ #[test]
+ fn broken_svg () {
+ let mut err: *mut glib_sys::GError = null_mut();
+
+ let ctx = unsafe { crate::begin_load(None, None, None, null_mut(), null_mut()) };
+ assert_ne!(ctx, null_mut());
+
+ let inc = unsafe {
+ crate::load_increment(ctx, SVG_BROKEN.as_ptr(), SVG_DATA.len() as u32, null_mut())
+ };
+ assert_ne!(inc, 0);
+
+ unsafe { crate::stop_load(ctx, &mut err as *mut *mut glib_sys::GError) };
+
+ // We just check if the error was set
+ assert!(err != null_mut());
+
+ unsafe { glib_sys::g_error_free(err) };
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]