-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for disabling #[non_exhaustive]
- Loading branch information
1 parent
77e87d2
commit 764eb29
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
test-crates/protobuf-codegen-protoc-test/src/common/v2/test_oneof_nonexhaustive.rs
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,15 @@ | ||
use protobuf::OneofFull; | ||
use protobuf_test_common::*; | ||
|
||
use super::test_oneof_nonexhaustive_pb::*; | ||
|
||
#[test] | ||
fn test_oneof_nonexhaustive_disabled() { | ||
use message_with_oneof_nonexhaustive_disabled::One; | ||
match MessageWithOneofNonexhaustiveDisabled::default().one { | ||
None => (), | ||
Some(one) => match one { | ||
One::FirstField(_) | One::SecondField(_) => (), | ||
}, | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test-crates/protobuf-codegen-protoc-test/src/common/v2/test_oneof_nonexhaustive_pb.proto
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 = "proto2"; | ||
|
||
import "rustproto.proto"; | ||
|
||
package test_oneof; | ||
|
||
message MessageWithOneofNonexhaustiveDisabled{ | ||
option (rustproto.oneofs_non_exhaustive) = false; | ||
|
||
oneof one { | ||
uint32 first_field = 1; | ||
string second_field = 2; | ||
} | ||
} |