|
|
|
@ -524,7 +524,7 @@ fn test_message_opt_set() { |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(true)); |
|
|
|
|
|
|
|
|
|
msg.clear_optional_nested_message(); |
|
|
|
|
assert_that!(msg.optional_nested_message_mut().is_set(), eq(false)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
@ -532,28 +532,27 @@ fn test_setting_submsg() { |
|
|
|
|
let mut msg = TestAllTypes::new(); |
|
|
|
|
let submsg = TestAllTypes_::NestedMessage::new(); |
|
|
|
|
|
|
|
|
|
let fieldentry = msg.optional_nested_message_mut(); |
|
|
|
|
assert_that!(fieldentry.is_set(), eq(false)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); |
|
|
|
|
|
|
|
|
|
fieldentry.or_default().set(submsg); |
|
|
|
|
msg.set_optional_nested_message(submsg); |
|
|
|
|
// confirm that invoking .set on a submsg indeed flips the set bit
|
|
|
|
|
assert_that!(msg.optional_nested_message_mut().is_set(), eq(true)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(true)); |
|
|
|
|
|
|
|
|
|
msg.clear_optional_nested_message(); |
|
|
|
|
assert_that!(msg.optional_nested_message_mut().is_set(), eq(false)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn test_msg_or_default() { |
|
|
|
|
let mut msg = TestAllTypes::new(); |
|
|
|
|
assert_that!(msg.optional_nested_message_mut().is_set(), eq(false)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); |
|
|
|
|
|
|
|
|
|
let _ = msg.optional_nested_message_mut().or_default(); |
|
|
|
|
// confirm that that or_default makes the field Present
|
|
|
|
|
assert_that!(msg.optional_nested_message_mut().is_set(), eq(true)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(true)); |
|
|
|
|
|
|
|
|
|
msg.clear_optional_nested_message(); |
|
|
|
|
assert_that!(msg.optional_nested_message_mut().is_set(), eq(false)); |
|
|
|
|
assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|