summaryrefslogtreecommitdiff
path: root/tests/basic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic.rs')
-rw-r--r--tests/basic.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/basic.rs b/tests/basic.rs
index 431695d..ce3abf8 100644
--- a/tests/basic.rs
+++ b/tests/basic.rs
@@ -1,22 +1,40 @@
mod foo {
use feluments::Builder;
- #[derive(Builder)]
+ #[derive(Debug, PartialEq, Eq, Builder)]
#[allow(dead_code)]
- #[builder(makro)]
+ #[builder(name = "FooBuild", makro)]
pub struct Foo {
#[builder(into, vis = pub)]
- bar: String,
+ pub bar: String,
#[builder(default = 32)]
pub baz: i32,
- pub bat: (),
+ #[builder(default = baz * 2)]
+ pub bat: i32,
}
}
use foo::Foo;
fn main() {
- let _x = Foo::builder().baz(32).bar("hello").bat(()).build();
+ let x = Foo::builder().baz(42).bar("hello").bat(5).build();
+ assert_eq!(
+ x,
+ Foo {
+ bar: "hello".into(),
+ baz: 42,
+ bat: 5
+ }
+ );
+
let bar = "hello";
- let _: Foo = Foo! { bar, bat: () };
+ let _: Foo = Foo! { bar };
+ assert_eq!(
+ x,
+ Foo {
+ bar: "hello".into(),
+ baz: 32,
+ bat: 64
+ }
+ );
}