Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
glib-macros: add a gerror_domain test
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-André Lureau <[email protected]>
  • Loading branch information
elmarco committed Mar 20, 2021
1 parent 7e4399c commit 0f5f13d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion glib-macros/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<TestError>());
assert!(matches!(err.kind::<TestError>(), Some(TestError::Bad)));
}

#[test]
fn derive_genum() {
Expand Down

0 comments on commit 0f5f13d

Please sign in to comment.