Skip to content

Commit

Permalink
Add tests for impl Value for Option<V: Value>
Browse files Browse the repository at this point in the history
Add tests for making an `Option<T> where T: Value` a value in itself.
  • Loading branch information
bryanburgers committed Sep 21, 2021
1 parent 723563f commit 67c1246
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tracing/tests/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,30 @@ fn explicit_child_at_levels() {

handle.assert_finished();
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn option_values() {
let (collector, handle) = collector::mock()
.event(event::mock()
.with_fields(
field::mock("some_str").with_value(&Some("yes"))
.and(field::mock("some_bool").with_value(&Some(true)))
.and(field::mock("some_u64").with_value(&Some(42_u64)))
)
)
.done()
.run_with_handle();

with_default(collector, || {
let some_str = Some("yes");
let none_str: Option<&'static str> = None;
let some_bool = Some(true);
let none_bool: Option<bool> = None;
let some_u64 = Some(42_u64);
let none_u64: Option<u64> = None;
trace!(some_str = some_str, none_str = none_str, some_bool = some_bool, none_bool = none_bool, some_u64 = some_u64, none_u64 = none_u64);
});

handle.assert_finished();
}

0 comments on commit 67c1246

Please sign in to comment.