Skip to content

Commit 9d9c5a4

Browse files
committed
Add tests
1 parent b423c16 commit 9d9c5a4

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

structlog.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ pub fn (mut h TextHandler) handle(rec Record) ! {
431431
}
432432
}
433433
}
434+
434435
if i + 1 != rec.fields.len {
435436
if i in [0, 1] {
436437
buf.write_byte(` `)

tests/struct_adapter_test.v

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import structlog
2+
3+
struct Simple {
4+
foo int
5+
bar string
6+
}
7+
8+
fn test_struct_adapter() {
9+
assert structlog.struct_adapter(Simple{10, 'fooo'}) == [
10+
structlog.Field{'foo', 10},
11+
structlog.Field{'bar', 'fooo'},
12+
]
13+
}
14+
15+
/* FIXME
16+
enum SomeEnum {
17+
one
18+
two
19+
three
20+
}
21+
22+
struct WithEnum {
23+
foo int
24+
bar string
25+
some_enum SomeEnum
26+
}
27+
28+
fn test_struct_adapter_with_enum() {
29+
assert structlog.struct_adapter(WithEnum{10, 'fooo', .two}) == [
30+
structlog.Field{'foo', 10},
31+
structlog.Field{'bar', 'fooo'},
32+
structlog.Field{'some_enum', 'two'},
33+
]
34+
}
35+
*/

0 commit comments

Comments
 (0)