40 {
42
44 present_option = example_option_from(
45 (
struct example_data){.value = 42, .description = strdup(
"A present option")});
46
47 DC_SCOPED(example_option) empty_option = example_option_empty();
48
50 fprintf(stdout, "\n");
52 fprintf(stdout, "\n");
53
54 DC_ASSERT(example_option_is_present(&present_option));
55 DC_ASSERT(!example_option_is_present(&empty_option));
56
57 struct example_data const* present_data = example_option_get_const(&present_option);
61
62 struct example_data const* empty_data = example_option_get_const(&empty_option);
64
65 bool was_present = example_option_replace(
66 &empty_option,
67 (
struct example_data){.value = 100, .description = strdup(
"Replaced value")});
69 DC_ASSERT(example_option_is_present(&empty_option));
70
71 struct example_data const* replaced_data = example_option_get_const(&empty_option);
75}
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_new()
#define DC_ASSERT(expr,...)
#define DC_SCOPED(type,...)
RAII in C. Call the destructor when the variable goes out of scope.