summaryrefslogtreecommitdiffstats
path: root/vendor/derive_builder/tests/lifetime.rs
blob: 13f2a08e2f27bbc0d1e67e7267208c60560e141b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate derive_builder;

#[derive(Debug, PartialEq, Default, Builder, Clone)]
struct Lorem<'a> {
    ipsum: &'a str,
}

#[test]
fn error_if_uninitialized() {
    let error = LoremBuilder::default().build().unwrap_err();
    assert_eq!(&error.to_string(), "`ipsum` must be initialized");
}

#[test]
fn builder_test() {
    let x = LoremBuilder::default().ipsum("ipsum").build().unwrap();

    assert_eq!(x, Lorem { ipsum: "ipsum" });
}