Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLauC committed Dec 3, 2023
1 parent 3445829 commit 12650f7
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/encode/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ impl FormattedChunk {
Ok(())
}
FormattedChunk::Release(ref chunks) => {
if cfg!(release_assertions) {
if !cfg!(debug_assertions) {
for chunk in chunks {
chunk.encode(w, record)?;
}
Expand Down Expand Up @@ -1030,4 +1030,29 @@ mod tests {

assert_eq!(buf, b"missing value");
}

#[test]
#[cfg(feature = "simple_writer")]
fn debug_release() {
let debug_pat = "{D({l})}";
let release_pat = "{R({l})}";

let debug_encoder = PatternEncoder::new(debug_pat);
let release_encoder = PatternEncoder::new(release_pat);
let mut debug_buf = vec![];
let mut release_buf = vec![];

debug_encoder.encode(&mut SimpleWriter(&mut debug_buf), &Record::builder().level(Level::Info).build())
.unwrap();
release_encoder.encode(&mut SimpleWriter(&mut release_buf), &Record::builder().level(Level::Info).build())
.unwrap();

if cfg!(debug_assertions) {
assert_eq!(debug_buf, b"INFO");
assert!(release_buf.is_empty());
} else {
assert_eq!(release_buf, b"INFO");
assert!(debug_buf.is_empty());
}
}
}

0 comments on commit 12650f7

Please sign in to comment.