| 5 | #include "malloc1/malloc1.h" |
| 6 | |
| 7 | void slog_tests() { |
| 8 | struct hc_memory_stream out; |
| 9 | hc_memory_stream_init(&out, &hc_malloc_default); |
| 10 | |
| 11 | struct hc_slog_stream s; |
| 12 | hc_slog_stream_init(&s, &out.stream, .close_out=true); |
| 13 | |
| 14 | hc_slog_do(&s) { |
| 15 | hc_slog_context_do(hc_slog_string("string", "abc")) { |
| 16 | hc_time_t t = hc_time(2025, 4, 13, 1, 40, 0); |
| 17 | |
| 18 | hc_slog_write(hc_slog_bool("bool", true), |
| 19 | hc_slog_int("int", 42), |
| 20 | hc_slog_time("time", t)); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | assert(strcmp("string=\"abc\", " |
| 25 | "bool=true, " |
| 26 | "int=42, " |
| 27 | "time=2025-04-13T01:40:00\n", |
| 28 | hc_memory_stream_string(&out)) == 0); |
| 29 | |
| 30 | hc_slog_deinit(&s); |
| 31 | } |
no test coverage detected