diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2024-02-20 23:49:31 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2024-02-20 23:49:31 +0300 |
commit | 03e8366b7e11e1b6c971f70d22fef07f7ad32448 (patch) | |
tree | 5bfcb0c7f11f85b70a18ecdd308bc2057828c6e9 /optional/optional-test.c | |
parent | cb1a40859029f33184355475e51fec95afb79a73 (diff) | |
download | c-wares-03e8366b7e11e1b6c971f70d22fef07f7ad32448.tar.gz c-wares-03e8366b7e11e1b6c971f70d22fef07f7ad32448.zip |
optionals v0.2.0: custom-named optionals
Can now declare custom named optionals, in order to declare optionals
for two-token type names.
Diffstat (limited to 'optional/optional-test.c')
-rw-r--r-- | optional/optional-test.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/optional/optional-test.c b/optional/optional-test.c index 88577d3..73597e5 100644 --- a/optional/optional-test.c +++ b/optional/optional-test.c @@ -2,9 +2,11 @@ #include "../utest/utest.h" #include <stdio.h> +#include <string.h> -OPTIONALDEC(int); -OPTIONALDEC(char); +DECL_OPTIONAL(int); +DECL_OPTIONAL(char); +DECL_NAMED_OPTIONAL(str, char *); struct my_struct { OPTIONAL(int) a; @@ -27,6 +29,12 @@ TEST_BEGIN(test_optional_example) OPTIONAL(char) y = OPTNONE; OPTIONAL(char) z = OPTSOME('z'); + + OPTIONAL(str) s = OPTSOME("hello, world!"); + + expect(!strcmp(opt_default(s, "NULL!"), "hello, world!"), + "expected to contain string \"hello, world!\""); + float xy, xz; expect(opt_has(my.a), "expected to contain something"); |