MCPcopy Create free account
hub / github.com/codr7/hacktical-c / slog_tests

Function slog_tests

slog/tests.c:7–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "malloc1/malloc1.h"
6
7void 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}

Callers 1

mainFunction · 0.85

Calls 7

hc_memory_stream_initFunction · 0.85
hc_slog_stringFunction · 0.85
hc_slog_boolFunction · 0.85
hc_slog_intFunction · 0.85
hc_slog_timeFunction · 0.85
hc_memory_stream_stringFunction · 0.85
hc_timeFunction · 0.50

Tested by

no test coverage detected