This change implements a custom Debug for messages, views and muts in the C++ kernel. Debug defers to proto2::Utf8Format. It implements this only for the C++ kernel. We will need to pull in additional dependencies beyond minitables to implement it for UPB as well. This will be done at a later point. PiperOrigin-RevId: 613191236pull/16077/head
parent
997281b5bb
commit
03687b798b
7 changed files with 188 additions and 5 deletions
@ -0,0 +1,8 @@ |
||||
syntax = "proto3"; |
||||
|
||||
package debug; |
||||
|
||||
message DebugMsg { |
||||
int32 id = 1; |
||||
string secret_user_data = 2 [debug_redact = true]; |
||||
} |
@ -0,0 +1,12 @@ |
||||
use debug_proto::DebugMsg; |
||||
use googletest::prelude::*; |
||||
|
||||
#[test] |
||||
fn test_debug() { |
||||
let mut msg = DebugMsg::new(); |
||||
msg.set_id(1); |
||||
msg.secret_user_data_mut().set("password"); |
||||
|
||||
assert_that!(format!("{msg:?}"), contains_substring("id: 1")); |
||||
assert_that!(format!("{msg:?}"), not(contains_substring("password"))); |
||||
} |
Loading…
Reference in new issue