forked from tokio-rs/prost
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for no package declaration (tokio-rs#343)
Co-authored-by: Jacob Kiesel <[email protected]>
- Loading branch information
1 parent
a4be973
commit 15296b8
Showing
11 changed files
with
179 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ cfg_if! { | |
} | ||
|
||
pub mod extern_paths; | ||
pub mod no_root_packages; | ||
pub mod packages; | ||
pub mod unittest; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
|
||
package gizmo; | ||
|
||
message Gizmo { | ||
message Inner { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! Tests nested packages without a root package. | ||
include!(concat!(env!("OUT_DIR"), "/no_root_packages/__.default.rs")); | ||
|
||
pub mod gizmo { | ||
include!(concat!(env!("OUT_DIR"), "/no_root_packages/gizmo.rs")); | ||
} | ||
|
||
pub mod widget { | ||
include!(concat!(env!("OUT_DIR"), "/no_root_packages/widget.rs")); | ||
pub mod factory { | ||
include!(concat!( | ||
env!("OUT_DIR"), | ||
"/no_root_packages/widget.factory.rs" | ||
)); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test() { | ||
use prost::Message; | ||
|
||
let mut widget_factory = widget::factory::WidgetFactory::default(); | ||
assert_eq!(0, widget_factory.encoded_len()); | ||
|
||
widget_factory.inner = Some(widget::factory::widget_factory::Inner {}); | ||
assert_eq!(2, widget_factory.encoded_len()); | ||
|
||
widget_factory.root = Some(Root {}); | ||
assert_eq!(4, widget_factory.encoded_len()); | ||
|
||
widget_factory.root_inner = Some(root::Inner {}); | ||
assert_eq!(6, widget_factory.encoded_len()); | ||
|
||
widget_factory.widget = Some(widget::Widget {}); | ||
assert_eq!(8, widget_factory.encoded_len()); | ||
|
||
widget_factory.widget_inner = Some(widget::widget::Inner {}); | ||
assert_eq!(10, widget_factory.encoded_len()); | ||
|
||
widget_factory.gizmo = Some(gizmo::Gizmo {}); | ||
assert_eq!(12, widget_factory.encoded_len()); | ||
|
||
widget_factory.gizmo_inner = Some(gizmo::gizmo::Inner {}); | ||
assert_eq!(14, widget_factory.encoded_len()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
syntax = "proto3"; | ||
|
||
message Root { | ||
message Inner { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package widget; | ||
|
||
message Widget { | ||
message Inner { | ||
} | ||
|
||
enum Type { | ||
A = 0; | ||
B = 1; | ||
C = 2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
syntax = "proto3"; | ||
|
||
package widget.factory; | ||
|
||
import "root.proto"; | ||
import "gizmo.proto"; | ||
import "widget.proto"; | ||
|
||
message WidgetFactory { | ||
message Inner { | ||
} | ||
|
||
Inner inner = 1; | ||
|
||
Root root = 2; | ||
Root.Inner root_inner = 3; | ||
|
||
Widget widget = 4; | ||
Widget.Inner widget_inner = 5; | ||
Widget.Type widget_type = 8; | ||
|
||
gizmo.Gizmo gizmo = 6; | ||
gizmo.Gizmo.Inner gizmo_inner = 7; | ||
} |