1 //! Legacy tests from 0.0.7 version.
2
3 use derive_getters::Getters;
4
5 #[derive(Getters)]
6 struct Number {
7 num: u64,
8 }
9
number_num()10 fn number_num() {
11 let number = Number { num: 655 };
12 assert!(number.num() == &655);
13 }
14
15 #[derive(Getters)]
16 struct ManyNumbers {
17 integer: u64,
18 floating: f64,
19 byte: u8,
20 }
21
many_numbers()22 fn many_numbers() {
23 let numbers = ManyNumbers {
24 integer: 655,
25 floating: 45.5,
26 byte: 122,
27 };
28
29 assert!(numbers.integer() == &655);
30 assert!(numbers.floating() == &45.5);
31 assert!(numbers.byte() == &122);
32 }
33
34 #[derive(Getters)]
35 struct Textual {
36 author: Option<String>,
37 heading: String,
38 lines: Vec<String>,
39 }
40
textual_struct()41 fn textual_struct() {
42 let article = Textual {
43 author: None,
44 heading: "abcdefg".to_string(),
45 lines: vec![
46 "hijk".to_string(),
47 "lmno".to_string(),
48 "pqrs".to_string(),
49 "tuvw".to_string(),
50 ],
51 };
52
53 assert!(article.author() == &None);
54 assert!(article.heading() == "abcdefg");
55 assert!(article.lines().len() == 4);
56 assert!(article.lines()[0] == "hijk");
57 assert!(article.lines()[1] == "lmno");
58 assert!(article.lines()[2] == "pqrs");
59 assert!(article.lines()[3] == "tuvw");
60
61 let book = Textual {
62 author: Some("name".to_string()),
63 heading: "1234".to_string(),
64 lines: vec![
65 "2345".to_string(),
66 "3456".to_string(),
67 "4567".to_string(),
68 "5678".to_string(),
69 ],
70 };
71
72 assert!(book.author() == &Some("name".to_string()));
73 }
74
75 /// There shouldn't be any dead code warnings on unused methods, only on unused slots which
76 /// are not the libraries fault.
77 #[derive(Getters)]
78 struct DeadCode {
79 x: u64,
80 y: u64,
81 z: u64,
82 }
83
84 #[test]
dead_code_struct()85 fn dead_code_struct() {
86 let dc = DeadCode {
87 x: 1,
88 y: 2,
89 z: 3,
90 };
91
92 assert!(*dc.x() == 1);
93 }
94
main()95 fn main() {
96 number_num();
97 many_numbers();
98 textual_struct();
99 }
100
101