Skip to content

Commit 61745de

Browse files
authored
tests: Actually test skip_debug for prost::Oneof (#1148)
1 parent ef8c040 commit 61745de

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/src/skip_debug.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ pub enum OneofWithEnumCustomDebug {
3737
#[prost(enumeration = "BasicEnumeration", tag = "10")]
3838
Enumeration(i32),
3939
}
40+
impl fmt::Debug for OneofWithEnumCustomDebug {
41+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42+
f.write_str("OneofWithEnumCustomDebug {..}")
43+
}
44+
}
4045

4146
#[derive(Clone, PartialEq, prost::Message)]
4247
#[prost(skip_debug)]
@@ -54,11 +59,9 @@ impl fmt::Debug for MessageWithOneofCustomDebug {
5459
/// Enumerations inside oneofs
5560
#[test]
5661
fn oneof_with_enum_custom_debug() {
57-
let msg = MessageWithOneofCustomDebug {
58-
of: Some(OneofWithEnumCustomDebug::Enumeration(
59-
BasicEnumeration::TWO as i32,
60-
)),
61-
};
62+
let of = OneofWithEnumCustomDebug::Enumeration(BasicEnumeration::TWO as i32);
63+
assert_eq!(format!("{:?}", of), "OneofWithEnumCustomDebug {..}");
64+
let msg = MessageWithOneofCustomDebug { of: Some(of) };
6265
assert_eq!(format!("{:?}", msg), "MessageWithOneofCustomDebug {..}");
6366
}
6467

0 commit comments

Comments
 (0)