-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(boxed_field): Box an oneof field (#1235)
- Loading branch information
1 parent
ac98f0f
commit 3de8526
Showing
3 changed files
with
14 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
include!(concat!(env!("OUT_DIR"), "/boxed_field.rs")); | ||
|
||
use self::foo::OneofField; | ||
|
||
#[test] | ||
/// Confirm `Foo::bar` is boxed by creating an instance | ||
fn test_bar_is_boxed() { | ||
/// Confirm `Foo::bar` and `OneofField::BoxQux` is boxed by creating an instance | ||
fn test_boxed_field() { | ||
use alloc::boxed::Box; | ||
let _ = Foo { | ||
bar: Some(Box::new(Bar {})), | ||
oneof_field: Some(OneofField::BoxQux(Box::new(Bar {}))), | ||
}; | ||
let _ = Foo { | ||
bar: Some(Box::new(Bar {})), | ||
oneof_field: Some(OneofField::Baz("hello".into())), | ||
}; | ||
} |