From: Sebastian Harl Date: Thu, 20 Feb 2014 20:57:04 +0000 (+0100) Subject: data_test: Print type of datum in case of a test failure. X-Git-Tag: sysdb-0.1.0~204 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1830b6288476b5b680482bbcd8f4d04b4455549f;p=sysdb.git data_test: Print type of datum in case of a test failure. --- diff --git a/src/include/core/data.h b/src/include/core/data.h index 58e92cd..c7c51b8 100644 --- a/src/include/core/data.h +++ b/src/include/core/data.h @@ -46,6 +46,19 @@ enum { SDB_TYPE_BINARY, }; +#define SDB_TYPE_TO_STRING(t) \ + (((t) == SDB_TYPE_INTEGER) \ + ? "INTEGER" \ + : ((t) == SDB_TYPE_DECIMAL) \ + ? "DECIMAL" \ + : ((t) == SDB_TYPE_STRING) \ + ? "STRING" \ + : ((t) == SDB_TYPE_DATETIME) \ + ? "DATETIME" \ + : ((t) == SDB_TYPE_BINARY) \ + ? "BINARY" \ + : "UNKNOWN") + /* * sdb_data_t: * A datum retrieved from an arbitrary data source. diff --git a/t/core/data_test.c b/t/core/data_test.c index 9542014..d6bd014 100644 --- a/t/core/data_test.c +++ b/t/core/data_test.c @@ -163,10 +163,12 @@ START_TEST(test_format) check = sdb_data_format(&golden_data[i].datum, buf); fail_unless(! check, - "sdb_data_format() = %d; expected: 0", check); + "sdb_data_format(type=%s) = %d; expected: 0", + SDB_TYPE_TO_STRING(golden_data[i].datum.type), check); string = sdb_strbuf_string(buf); fail_unless(! strcmp(string, golden_data[i].expected), - "sdb_data_format() used wrong format: %s; expected: %s", + "sdb_data_format(type=%s) used wrong format: %s; expected: %s", + SDB_TYPE_TO_STRING(golden_data[i].datum.type), string, golden_data[i].expected); sdb_strbuf_clear(buf); }