Code

data_test: Test various unsupported expressions.
authorSebastian Harl <sh@tokkee.org>
Fri, 24 Oct 2014 18:25:17 +0000 (20:25 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 24 Oct 2014 18:25:17 +0000 (20:25 +0200)
t/unit/core/data_test.c

index 1129936f1184cea190907b4851be0ede710b60ad..a647e020bb7e63b8b34d3d95c6eee81201c00474 100644 (file)
@@ -1199,6 +1199,237 @@ START_TEST(test_expr_eval)
                        { SDB_TYPE_DATETIME, { .datetime = 0 } },
                        err,
                },
+               /* unsupported type-mismatches */
+               {
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_STRING, { .string = "20.0" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_BINARY, { .binary = { 4, (unsigned char *)"20.0" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_INTEGER, { .integer = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_DECIMAL, { .decimal = 20.0 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_STRING, { .string = "20" } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_DATETIME, { .datetime = 20 } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_BINARY, { .binary = { 2, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_BINARY, { .binary = { 3, (unsigned char *)"20" } } },
+                       err, err, err, err, err, err,
+               },
+               {
+                       { SDB_TYPE_REGEX, { .re = { ".", empty_re } } },
+                       { SDB_TYPE_REGEX + 1, { .integer = 0 } },
+                       err, err, err, err, err, err,
+               },
        };
 
        size_t i;