40 {
42
45 present_option = example_option_from(
46 (
struct example_data){.value = 42, .description = strdup(
"A present option")});
47
49 DC_SCOPED(example_option) empty_option = example_option_empty();
50
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
66 bool was_present = example_option_replace(
67 &empty_option,
68 (
struct example_data){.value = 100, .description = strdup(
"Replaced value")});
70 DC_ASSERT(example_option_is_present(&empty_option));
71
72 struct example_data const* replaced_data = example_option_get_const(&empty_option);
76
78}
#define DC_DEBUG(DEBUG_FN, DEBUG_PTR)
#define DC_ASSERT(expr,...)
#define DC_SCOPED(type,...)
RAII in C. Call the destructor when the variable goes out of scope.
#define DC_LOGGER_NEW(...)