summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorpeter <peter@pmikkelsen.com>2026-08-31 19:44:56 +0000
committerpeter <peter@pmikkelsen.com>2026-08-31 19:44:56 +0000
commit7f7a2fb4fb23433e7be3d6953725690c8ea958d2 (patch)
treee73bc6f3bd9d5132a0262966cd99986027142144 /tests
parent729964bea692f9683860978b89848784a7fc2f46 (diff)
The objects returned to the user are now integer-based references,
not actual pointers. This means the aplwc internals can update those pointers without the user noticing. FossilOrigin-Name: 654c7d0ec85da295a7fb6ed381500410686b280f342fa81a30481f5e9a20c58a
Diffstat (limited to 'tests')
-rw-r--r--tests/aplwc_errstr.c9
-rw-r--r--tests/aplwc_eval.c10
-rw-r--r--tests/aplwc_read.c6
-rw-r--r--tests/aplwc_utf8.c8
4 files changed, 16 insertions, 17 deletions
diff --git a/tests/aplwc_errstr.c b/tests/aplwc_errstr.c
index 1a5ebc4..fe9fa0e 100644
--- a/tests/aplwc_errstr.c
+++ b/tests/aplwc_errstr.c
@@ -20,19 +20,19 @@ my_dealloc(void *p)
int
main(void)
{
+ enum aplwc_rc ret;
struct aplwc_fns fns;
struct aplwc *aplwc;
- int ret, success;
+ int success;
const char *err;
success = 0;
- aplwc = NULL;
memset(&fns, 0, sizeof(fns));
fns.alloc = my_alloc;
fns.dealloc = my_dealloc;
- ret = aplwc_new(&aplwc, fns);
+ aplwc = aplwc_new(fns, &ret);
if(ret)
goto end;
@@ -50,10 +50,9 @@ main(void)
goto end;
aplwc_destroy(aplwc);
- aplwc = NULL;
fns.alloc = NULL;
- ret = aplwc_new(&aplwc, fns);
+ aplwc = aplwc_new(fns, &ret);
if(ret == 0)
goto end;
err = aplwc_errstr_rc(ret);
diff --git a/tests/aplwc_eval.c b/tests/aplwc_eval.c
index 68ea4a8..3fd8c27 100644
--- a/tests/aplwc_eval.c
+++ b/tests/aplwc_eval.c
@@ -23,8 +23,8 @@ main(int argc, char *argv[])
{
char *input;
struct aplwc *aplwc;
- struct aplwc_line *line;
- struct aplwc_value *value;
+ AplwcLine line;
+ AplwcValue value;
struct aplwc_fns fns;
enum aplwc_rc ret;
FILE *f;
@@ -56,7 +56,7 @@ main(int argc, char *argv[])
fns.alloc = my_alloc;
fns.dealloc = my_dealloc;
- ret = aplwc_new(&aplwc, fns);
+ aplwc = aplwc_new(fns, &ret);
if(ret)
return 1;
@@ -66,11 +66,11 @@ main(int argc, char *argv[])
input[i] = 0;
line = aplwc_read(aplwc, &input[j]);
- if(line == NULL)
+ if(!aplwc_valid_line(line))
return 1;
value = aplwc_eval(line);
- if((value == NULL) && (aplwc_last_error(aplwc) != APLWC_OUT_OF_MEMORY))
+ if((!aplwc_valid_value(value)) && (aplwc_last_error(aplwc) != APLWC_OUT_OF_MEMORY))
return 1;
aplwc_free_value(value);
diff --git a/tests/aplwc_read.c b/tests/aplwc_read.c
index 42a47c2..d090494 100644
--- a/tests/aplwc_read.c
+++ b/tests/aplwc_read.c
@@ -24,7 +24,7 @@ main(int argc, char *argv[])
struct aplwc_fns fns;
char *input;
struct aplwc *aplwc;
- struct aplwc_line *line;
+ AplwcLine line;
enum aplwc_rc ret;
FILE *f;
long input_size;
@@ -53,12 +53,12 @@ main(int argc, char *argv[])
return 1;
input[input_size] = 0;
- ret = aplwc_new(&aplwc, fns);
+ aplwc = aplwc_new(fns, &ret);
if(ret)
return 1;
line = aplwc_read(aplwc, input);
- if((line == NULL) && (aplwc_last_error(aplwc) != APLWC_OUT_OF_MEMORY))
+ if((!aplwc_valid_line(line)) && (aplwc_last_error(aplwc) != APLWC_OUT_OF_MEMORY))
return 1;
aplwc_free_line(line);
aplwc_destroy(aplwc);
diff --git a/tests/aplwc_utf8.c b/tests/aplwc_utf8.c
index 4f9f2a4..367db5d 100644
--- a/tests/aplwc_utf8.c
+++ b/tests/aplwc_utf8.c
@@ -35,7 +35,7 @@ int
main(void)
{
struct aplwc *aplwc;
- struct aplwc_line *line;
+ AplwcLine line;
struct aplwc_fns fns;
enum aplwc_rc ret;
size_t i;
@@ -62,13 +62,13 @@ main(void)
fns.alloc = my_alloc;
fns.dealloc = my_dealloc;
- ret = aplwc_new(&aplwc, fns);
+ aplwc = aplwc_new(fns, &ret);
if(ret)
return 1;
for(i = 0; i < (sizeof(bad_tests)/sizeof(*bad_tests)); i++){
line = aplwc_read(aplwc, (char *)bad_tests[i]);
- if(line != NULL)
+ if(aplwc_valid_line(line))
return 1;
if(aplwc_last_error(aplwc) != APLWC_INVALID_UTF8)
return 1;
@@ -77,7 +77,7 @@ main(void)
for(i = 0; i < (sizeof(good_tests)/sizeof(*good_tests)); i++){
line = aplwc_read(aplwc, (char *)good_tests[i]);
- if((line == NULL) && (aplwc_last_error(aplwc) == APLWC_INVALID_UTF8))
+ if((!aplwc_valid_line(line)) && (aplwc_last_error(aplwc) == APLWC_INVALID_UTF8))
return 1;
aplwc_free_line(line);
}