From 0ff46c261bcd19f53a9ea3bd777fe5ef95dabb5a Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Sat, 2 Dec 2023 10:18:03 +0800 Subject: [PATCH] test: add a unit test for index API Signed-off-by: hi-rustin --- tracing-core/src/field.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index dba4c5b615..c18deb7931 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -1025,6 +1025,17 @@ mod test { assert!(valueset.is_empty()); } + #[test] + fn index_of_field_in_fieldset_is_correct() { + let fields = TEST_META_1.fields(); + let foo = fields.field("foo").unwrap(); + assert_eq!(foo.index(), 0); + let bar = fields.field("bar").unwrap(); + assert_eq!(bar.index(), 1); + let baz = fields.field("baz").unwrap(); + assert_eq!(baz.index(), 2); + } + #[test] fn empty_value_set_is_empty() { let fields = TEST_META_1.fields();