Skip to content

Commit

Permalink
chore: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Nov 29, 2024
1 parent cea6907 commit 2bf4344
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions iced_layershell/tests/test_macro.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use iced_layershell::to_layer_message;
use iced_layershell::actions::IsSingleton;
use iced_layershell::{to_layer_message, LayerSingleton};

#[test]
fn test_macro() {
fn test_layer_message_macro() {
#[to_layer_message]
#[derive(Debug, Clone)]
enum TestEnum {
Expand All @@ -10,3 +11,24 @@ fn test_macro() {
let e = TestEnum::SizeChange((10, 10));
let _ = e.clone();
}

#[test]
fn test_layersingleton_derive() {
#[allow(unused)]
#[derive(LayerSingleton)]
enum SingleToneTest {
#[singleton]
SingleTon,
NotSingleTon,
#[singleton]
SingleTonTwo {
field: bool,
},
#[singleton]
SingleTonThird(i32),
}
assert!(SingleToneTest::SingleTon.is_singleton());
assert!(!SingleToneTest::NotSingleTon.is_singleton());
assert!(SingleToneTest::SingleTonTwo { field: false }.is_singleton());
assert!(SingleToneTest::SingleTonThird(10).is_singleton());
}

0 comments on commit 2bf4344

Please sign in to comment.