|
|
@ -273,15 +273,10 @@ fn test_oneof_accessors() { |
|
|
|
assert_that!(msg.oneof_uint32_opt(), eq(Optional::Unset(0))); |
|
|
|
assert_that!(msg.oneof_uint32_opt(), eq(Optional::Unset(0))); |
|
|
|
assert_that!(msg.oneof_field(), matches_pattern!(not_set(_))); |
|
|
|
assert_that!(msg.oneof_field(), matches_pattern!(not_set(_))); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: the submessage api is still in progress so we can't yet
|
|
|
|
msg.oneof_nested_message_mut().or_default(); // Cause the nested_message field to become set.
|
|
|
|
// cause a submsg to be set here.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// msg.oneof_nested_message_mut().or_default(); // Cause the nested_message
|
|
|
|
assert_that!(msg.oneof_bytes_opt(), matches_pattern!(Optional::Unset(_))); |
|
|
|
// field to become set.
|
|
|
|
assert_that!(msg.oneof_field(), matches_pattern!(OneofNestedMessage(_))); |
|
|
|
|
|
|
|
|
|
|
|
// assert_that!(msg.oneof_bytes_opt(),
|
|
|
|
|
|
|
|
// eq(Optional::Unset(_))); assert_that!(msg.oneof_field(),
|
|
|
|
|
|
|
|
// matches_pattern!(OneofNestedMessage(_)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msg.set_oneof_uint32(7); |
|
|
|
msg.set_oneof_uint32(7); |
|
|
|
msg.set_oneof_bytes(b"123"); |
|
|
|
msg.set_oneof_bytes(b"123"); |
|
|
@ -292,6 +287,22 @@ fn test_oneof_accessors() { |
|
|
|
assert_that!(msg.oneof_field(), matches_pattern!(not_set(_))); |
|
|
|
assert_that!(msg.oneof_field(), matches_pattern!(not_set(_))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
|
|
|
fn test_oneof_accessors_view_long_lifetime() { |
|
|
|
|
|
|
|
use TestAllTypes_::OneofField::*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut msg = TestAllTypes::new(); |
|
|
|
|
|
|
|
msg.set_oneof_uint32(7); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The oneof-view accessor on MsgViews should maintain the longest lifetime (can
|
|
|
|
|
|
|
|
// outlive the message view).
|
|
|
|
|
|
|
|
let oneof = { |
|
|
|
|
|
|
|
let view = msg.as_view(); |
|
|
|
|
|
|
|
view.oneof_field() |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
assert_that!(oneof, matches_pattern!(OneofUint32(eq(7)))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_oneof_enum_accessors() { |
|
|
|
fn test_oneof_enum_accessors() { |
|
|
|
use unittest_proto3::{ |
|
|
|
use unittest_proto3::{ |
|
|
|