do { \
/* Evaluate 'actual' only once. */ \
const char *got__ = actual; \
- if (strcmp(expect, got__) != 0) { \
+ if ((expect == NULL) != (got__ == NULL)) { \
+ printf("not ok %i - %s = \"%s\", want \"%s\"\n", ++check_count__, \
+ #actual, got__ ? got__ : "(null)", expect ? expect : "(null)"); \
+ return -1; \
+ } \
+ if ((expect != NULL) && (strcmp(expect, got__) != 0)) { \
printf("not ok %i - %s = \"%s\", want \"%s\"\n", ++check_count__, \
#actual, got__, expect); \
return -1; \
} \
- printf("ok %i - %s = \"%s\"\n", ++check_count__, #actual, got__); \
+ printf("ok %i - %s = \"%s\"\n", ++check_count__, #actual, \
+ got__ ? got__ : "(null)"); \
} while (0)
#define EXPECT_EQ_INT(expect, actual) \
.type = "single",
};
- char want[1024];
- ssnprintf(want, sizeof(want), "%s 42 1480063672\r\n", cases[i].want_name);
+ strbuf_t want = STRBUF_CREATE;
+ if (cases[i].want_name != NULL) {
+ strbuf_print(&want, cases[i].want_name);
+ strbuf_print(&want, " 42 1480063672\r\n");
+ }
if (cases[i].plugin_instance != NULL)
sstrncpy(vl.plugin_instance, cases[i].plugin_instance,
EXPECT_EQ_INT(0, format_graphite(got, sizeof(got), &ds_single, &vl,
cases[i].prefix, cases[i].suffix, '@',
cases[i].flags));
- EXPECT_EQ_STR(want, got);
+ EXPECT_EQ_STR(want.ptr, got);
+ STRBUF_DESTROY(want);
}
return 0;