From: Sebastian Harl Date: Tue, 7 Oct 2014 19:30:32 +0000 (+0200) Subject: data_test: Fixed name/order of the cmp() and strcmp() tests. X-Git-Tag: sysdb-0.6.0~134 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8a5c48548731dc07c3370432dc8f951b8e4bef9f;p=sysdb.git data_test: Fixed name/order of the cmp() and strcmp() tests. ;-) --- diff --git a/t/unit/core/data_test.c b/t/unit/core/data_test.c index 9d52d22..636fd13 100644 --- a/t/unit/core/data_test.c +++ b/t/unit/core/data_test.c @@ -153,9 +153,6 @@ START_TEST(test_cmp) sdb_data_t d2; int expected; } golden_data[] = { - /* same data as for the sdb_data_cmp test; in case the types match, - * both functions should behave the same (except for some loss in - * precision, e.g. when formatting datetime values) */ { { SDB_TYPE_INTEGER, { .integer = 47 } }, { SDB_TYPE_INTEGER, { .integer = 4711 } }, @@ -227,7 +224,7 @@ START_TEST(test_cmp) 1, }, { - { SDB_TYPE_DATETIME, { .datetime = 471047114711471100 } }, + { SDB_TYPE_DATETIME, { .datetime = 471147114711471000 } }, { SDB_TYPE_DATETIME, { .datetime = 471147114711471100 } }, -1, }, @@ -238,7 +235,7 @@ START_TEST(test_cmp) }, { { SDB_TYPE_DATETIME, { .datetime = 471147114711471100 } }, - { SDB_TYPE_DATETIME, { .datetime = 471047114711471100 } }, + { SDB_TYPE_DATETIME, { .datetime = 471147114711471000 } }, 1, }, { @@ -311,43 +308,12 @@ START_TEST(test_cmp) }, 1, }, - /* type mismatches */ - { - { SDB_TYPE_INTEGER, { .integer = 123 } }, - { SDB_TYPE_STRING, { .string = "123" } }, - 0, - }, - { - { SDB_TYPE_INTEGER, { .integer = 120 } }, - { SDB_TYPE_STRING, { .string = "123" } }, - -1, - }, - { - { SDB_TYPE_STRING, { .string = "123" } }, - { SDB_TYPE_INTEGER, { .integer = 120 } }, - 1, - }, - { - { SDB_TYPE_STRING, { .string = "12.3" } }, - { SDB_TYPE_DECIMAL, { .decimal = 12.3 } }, - 0, - }, - { - { SDB_TYPE_STRING, { .string = "12.0" } }, - { SDB_TYPE_DECIMAL, { .decimal = 12.3 } }, - -1, - }, - { - { SDB_TYPE_DECIMAL, { .decimal = 12.3 } }, - { SDB_TYPE_STRING, { .string = "12.0" } }, - 1, - }, }; size_t i; for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) { - int check = sdb_data_strcmp(&golden_data[i].d1, &golden_data[i].d2); + int check = sdb_data_cmp(&golden_data[i].d1, &golden_data[i].d2); check = check < 0 ? -1 : check > 0 ? 1 : 0; if (check != golden_data[i].expected) { char d1_str[64] = "", d2_str[64] = ""; @@ -355,7 +321,7 @@ START_TEST(test_cmp) SDB_DOUBLE_QUOTED); sdb_data_format(&golden_data[i].d2, d2_str, sizeof(d2_str), SDB_DOUBLE_QUOTED); - fail("sdb_data_strcmp(%s, %s) = %d; expected: %d", + fail("sdb_data_cmp(%s, %s) = %d; expected: %d", d1_str, d2_str, check, golden_data[i].expected); } } @@ -369,6 +335,9 @@ START_TEST(test_strcmp) sdb_data_t d2; int expected; } golden_data[] = { + /* same data as for the sdb_data_cmp test; in case the types match, + * both functions should behave the same (except for some loss in + * precision, e.g. when formatting datetime values) */ { { SDB_TYPE_INTEGER, { .integer = 47 } }, { SDB_TYPE_INTEGER, { .integer = 4711 } }, @@ -440,7 +409,7 @@ START_TEST(test_strcmp) 1, }, { - { SDB_TYPE_DATETIME, { .datetime = 471147114711471000 } }, + { SDB_TYPE_DATETIME, { .datetime = 471047114711471100 } }, { SDB_TYPE_DATETIME, { .datetime = 471147114711471100 } }, -1, }, @@ -451,7 +420,7 @@ START_TEST(test_strcmp) }, { { SDB_TYPE_DATETIME, { .datetime = 471147114711471100 } }, - { SDB_TYPE_DATETIME, { .datetime = 471147114711471000 } }, + { SDB_TYPE_DATETIME, { .datetime = 471047114711471100 } }, 1, }, { @@ -524,12 +493,43 @@ START_TEST(test_strcmp) }, 1, }, + /* type mismatches */ + { + { SDB_TYPE_INTEGER, { .integer = 123 } }, + { SDB_TYPE_STRING, { .string = "123" } }, + 0, + }, + { + { SDB_TYPE_INTEGER, { .integer = 120 } }, + { SDB_TYPE_STRING, { .string = "123" } }, + -1, + }, + { + { SDB_TYPE_STRING, { .string = "123" } }, + { SDB_TYPE_INTEGER, { .integer = 120 } }, + 1, + }, + { + { SDB_TYPE_STRING, { .string = "12.3" } }, + { SDB_TYPE_DECIMAL, { .decimal = 12.3 } }, + 0, + }, + { + { SDB_TYPE_STRING, { .string = "12.0" } }, + { SDB_TYPE_DECIMAL, { .decimal = 12.3 } }, + -1, + }, + { + { SDB_TYPE_DECIMAL, { .decimal = 12.3 } }, + { SDB_TYPE_STRING, { .string = "12.0" } }, + 1, + }, }; size_t i; for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) { - int check = sdb_data_cmp(&golden_data[i].d1, &golden_data[i].d2); + int check = sdb_data_strcmp(&golden_data[i].d1, &golden_data[i].d2); check = check < 0 ? -1 : check > 0 ? 1 : 0; if (check != golden_data[i].expected) { char d1_str[64] = "", d2_str[64] = ""; @@ -537,7 +537,7 @@ START_TEST(test_strcmp) SDB_DOUBLE_QUOTED); sdb_data_format(&golden_data[i].d2, d2_str, sizeof(d2_str), SDB_DOUBLE_QUOTED); - fail("sdb_data_cmp(%s, %s) = %d; expected: %d", + fail("sdb_data_strcmp(%s, %s) = %d; expected: %d", d1_str, d2_str, check, golden_data[i].expected); } }