/src/prost/tests/src/packages/mod.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! Tests nested packages. |
2 | | |
3 | | include!(concat!(env!("OUT_DIR"), "/packages.rs")); |
4 | | |
5 | | pub mod gizmo { |
6 | | include!(concat!(env!("OUT_DIR"), "/packages.gizmo.rs")); |
7 | | } |
8 | | |
9 | | pub mod widget { |
10 | | include!(concat!(env!("OUT_DIR"), "/packages.widget.rs")); |
11 | | pub mod factory { |
12 | | include!(concat!(env!("OUT_DIR"), "/packages.widget.factory.rs")); |
13 | | } |
14 | | } |
15 | | |
16 | | // Trait used in extern_paths.rs. |
17 | | pub trait DoIt { |
18 | | fn do_it(&self); |
19 | | } |
20 | | |
21 | | impl DoIt for gizmo::Gizmo { |
22 | 0 | fn do_it(&self) {} |
23 | | } |
24 | | |
25 | | #[test] |
26 | | fn test() { |
27 | | use prost::Message; |
28 | | |
29 | | let mut widget_factory = widget::factory::WidgetFactory::default(); |
30 | | assert_eq!(0, widget_factory.encoded_len()); |
31 | | |
32 | | widget_factory.inner = Some(widget::factory::widget_factory::Inner {}); |
33 | | assert_eq!(2, widget_factory.encoded_len()); |
34 | | |
35 | | widget_factory.root = Some(Root {}); |
36 | | assert_eq!(4, widget_factory.encoded_len()); |
37 | | |
38 | | widget_factory.root_inner = Some(root::Inner {}); |
39 | | assert_eq!(6, widget_factory.encoded_len()); |
40 | | |
41 | | widget_factory.widget = Some(widget::Widget {}); |
42 | | assert_eq!(8, widget_factory.encoded_len()); |
43 | | |
44 | | widget_factory.widget_inner = Some(widget::widget::Inner {}); |
45 | | assert_eq!(10, widget_factory.encoded_len()); |
46 | | |
47 | | widget_factory.gizmo = Some(gizmo::Gizmo {}); |
48 | | assert_eq!(12, widget_factory.encoded_len()); |
49 | | |
50 | | widget_factory.gizmo_inner = Some(gizmo::gizmo::Inner {}); |
51 | | assert_eq!(14, widget_factory.encoded_len()); |
52 | | } |