Skip to content

Commit

Permalink
tests: Don't print NULL value (null)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Mar 17, 2024
1 parent a08bfe0 commit 9d1fb35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
19 changes: 10 additions & 9 deletions tests/multiple_attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ main(void)
int i = 0;
while (list)
{
printf("\n\
Key: %s\n\
Value: %s\n\
Attribute: %s\n", list->key, list->value, list->attributes->current);

// assert (strcmp (data[i].key, list->key) == 0);
// assert (strcmp (data[i].value, list->value) == 0);
int j = 0;
Expand All @@ -37,19 +32,25 @@ Attribute: %s\n", list->key, list->value, list->attributes->current);
// Pass '&addr' to this function and it will get assigned an
// attribute, or NULL if there are none.
canfigger_free_current_attr_str_advance(list->attributes, &attr);

printf("\n\
Key: %s\n\
Value: %s\n\
Attribute: %s\n", list->key, list->value, attr != NULL ? attr : "NULL");

while (attr)
{
fprintf(stderr, "attr: %s\n", list->attributes->current);
fprintf(stderr, "attr: %s\n", attr);
switch (i)
{
case 0:
assert(strcmp(data1[j], list->attributes->current) == 0);
assert(strcmp(data1[j], attr) == 0);
break;
case 1:
assert(strcmp(data2[j], list->attributes->current) == 0);
assert(strcmp(data2[j], attr) == 0);
break;
case 2:
assert(strcmp(data3[j], list->attributes->current) == 0);
assert(strcmp(data3[j], attr) == 0);
break;
}
j++;
Expand Down
10 changes: 6 additions & 4 deletions tests/parse_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ main(void)

// call the primary library function to read your config file
struct Canfigger *list = canfigger_parse_file(test_config_file, ',');
assert (list);
assert(list);

int i = 0;
while (list)
Expand All @@ -36,14 +36,16 @@ main(void)
fprintf(stderr, "\n\
Key: %s | Expected: %s\n\
Value: %s | Expected: %s\n\
Attribute: %s | Expected: %s\n", list->key, data[i].key, list->value != NULL ? list->value : "NULL", data[i].value, attr != NULL ? attr : "NULL", data[i].attribute);
Attribute: %s | Expected: %s\n",
list->key, data[i].key,
list->value ? list->value : "NULL", data[i].value ? data[i].value : "NULL",
attr ? attr : "NULL", data[i].attribute ? data[i].attribute : "NULL");

assert(strcmp(data[i].key, list->key) == 0);
assert(strcmp
(data[i].value != NULL ? data[i].value : "NULL",
list->value != NULL ? list->value : "NULL") == 0);
fprintf(stderr, "attr: %s\n",
attr != NULL ? attr : "NULL");
fprintf(stderr, "attr: %s\n", attr != NULL ? attr : "NULL");
assert(strcmp
(attr != NULL ? data[i].attribute : "NULL",
attr != NULL ? attr : "NULL") == 0);
Expand Down

0 comments on commit 9d1fb35

Please sign in to comment.