From 0f5f13d27b939a4c41d6f2d6d381b3e5c9cd1a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sat, 20 Mar 2021 20:34:28 +0400 Subject: [PATCH] glib-macros: add a gerror_domain test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- glib-macros/tests/test.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/glib-macros/tests/test.rs b/glib-macros/tests/test.rs index 342c9b4f4f4c..b5c791cd14a0 100644 --- a/glib-macros/tests/test.rs +++ b/glib-macros/tests/test.rs @@ -5,7 +5,26 @@ use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::{FromGlib, ToGlib}; -use glib::{gflags, GBoxed, GEnum}; +use glib::{gflags, GBoxed, GEnum, GErrorDomain}; + +#[test] +fn derive_gerror_domain() { + #[derive(Debug, Eq, PartialEq, Clone, Copy, GErrorDomain)] + #[gerror_domain(name = "TestError")] + enum TestError { + Invalid, + Bad, + Wrong, + } + + // assert_eq!(TestError::Invalid.to_glib(), 0); + // assert_eq!(TestError::Bad.to_glib(), 1); + // assert_eq!(TestError::Wrong.to_glib(), 2); + + let err = glib::Error::new(TestError::Bad, "oh no!"); + assert!(err.is::()); + assert!(matches!(err.kind::(), Some(TestError::Bad))); +} #[test] fn derive_genum() {