[librsvg: 13/53] Move the test for 515-too-many-elements.svgz to Rust




commit 31866940ca1f2d3c9ef55838d3f01423bc9d6fde
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 13 18:00:48 2020 -0500

    Move the test for 515-too-many-elements.svgz to Rust

 tests/errors.c      | 23 -----------------------
 tests/src/errors.rs | 16 ++++++++++++++++
 tests/src/main.rs   |  3 +++
 3 files changed, 19 insertions(+), 23 deletions(-)
---
diff --git a/tests/errors.c b/tests/errors.c
index ae439cba..9173d833 100644
--- a/tests/errors.c
+++ b/tests/errors.c
@@ -23,23 +23,6 @@ get_test_filename (const char *basename) {
                              NULL);
 }
 
-static void
-test_loading_error (gconstpointer data)
-{
-    const char *basename = data;
-    char *filename = get_test_filename (basename);
-    RsvgHandle *handle;
-    GError *error = NULL;
-
-    handle = rsvg_handle_new_from_file (filename, &error);
-    g_free (filename);
-
-    g_assert_null (handle);
-    g_assert_error (error, RSVG_ERROR, RSVG_ERROR_FAILED);
-
-    g_error_free (error);
-}
-
 static void
 test_instancing_limit (gconstpointer data)
 {
@@ -92,11 +75,5 @@ main (int argc, char **argv)
                                test_instancing_limit,
                                NULL);
 
-    g_test_add_data_func_full ("/errors/515-too-many-elements.svgz",
-                               "515-too-many-elements.svgz",
-                               test_loading_error,
-                               NULL);
-
-
     return g_test_run ();
 }
diff --git a/tests/src/errors.rs b/tests/src/errors.rs
new file mode 100644
index 00000000..ccadbf84
--- /dev/null
+++ b/tests/src/errors.rs
@@ -0,0 +1,16 @@
+//! Tests for loading errors.
+
+#![cfg(test)]
+use test_generator::test_resources;
+
+use librsvg::{Loader, LoadingError};
+
+use crate::utils::fixture_path;
+
+#[test_resources("tests/fixtures/errors/515-too-many-elements.svgz")]
+fn loading_crash(name: &str) {
+    assert!(matches!(
+        Loader::new().read_path(fixture_path(name)),
+        Err(LoadingError::XmlParseError(_))
+    ));
+}
diff --git a/tests/src/main.rs b/tests/src/main.rs
index 793dfb47..8bd5ba4a 100644
--- a/tests/src/main.rs
+++ b/tests/src/main.rs
@@ -5,6 +5,9 @@ extern crate float_cmp;
 #[cfg(test)]
 mod cmdline;
 
+#[cfg(test)]
+mod errors;
+
 #[cfg(test)]
 mod loading_crash;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]