Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ModProg committed Jul 30, 2024
1 parent e779a39 commit 34ba680
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
//! will copy the behavior of the contained field, e.g. for [`bool`]:
//!
//! ```
//! use syn::{Attribute, parse_quote};
//! use attribute_derive::FromAttr;
//!
//! #[derive(FromAttr, PartialEq, Debug)]
Expand Down
15 changes: 15 additions & 0 deletions tests/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,18 @@ fn tuple() {
Multiple(true, "value".into())
);
}

#[test]
fn attribute_ident_option() {
#[derive(FromAttr)]
#[attribute(ident = test)]
struct Test(String);

let attr: Attribute = parse_quote!(#[test("hello")]);
assert_eq!(
Option::<Test>::from_attributes([attr]).unwrap().unwrap().0,
"hello"
);
let attr: Attribute = parse_quote!(#[not_test("hello")]);
assert!(Option::<Test>::from_attributes([attr]).unwrap().is_none());
}

0 comments on commit 34ba680

Please sign in to comment.