Code

data_test: Fixed name/order of the cmp() and strcmp() tests.
authorSebastian Harl <sh@tokkee.org>
Tue, 7 Oct 2014 19:30:32 +0000 (21:30 +0200)
committerSebastian Harl <sh@tokkee.org>
Tue, 7 Oct 2014 19:30:32 +0000 (21:30 +0200)
;-)

t/unit/core/data_test.c

index 9d52d2279f2622fdf845999a9de5bc0a22fa3b0a..636fd13e7523dd403c1ed84f169d494ff0f2cdad 100644 (file)
@@ -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);
                }
        }