summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d93f08)
raw | patch | inline | side by side (parent: 4d93f08)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 12 Nov 2014 21:59:03 +0000 (22:59 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 12 Nov 2014 21:59:03 +0000 (22:59 +0100) |
src/core/data.c | patch | blob | history | |
t/unit/core/data_test.c | patch | blob | history |
diff --git a/src/core/data.c b/src/core/data.c
index 88c7f8246953d58f1af76a01a04e1919eb96f8c2..3186aa2622ecbfdc3caf2fc877dc7ae890c7754f 100644 (file)
--- a/src/core/data.c
+++ b/src/core/data.c
else
return -1;
- assert(s1 && s2);
-
new = malloc(len1 + len2 + 1);
if (! new)
return -1;
index 956cf3108c0a5d598afcb5eb75e72f938f61c3d8..a848756a185385ae1431fb43c9119fc855bfe181 100644 (file)
--- a/t/unit/core/data_test.c
+++ b/t/unit/core/data_test.c
{ SDB_TYPE_REGEX, { .re = { "a", empty_re } } },
1,
},
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_INTEGER, { .array = { 0, NULL } } },
+ { SDB_TYPE_ARRAY | SDB_TYPE_INTEGER, { .array = { 0, NULL } } },
+ 0,
+ },
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_INTEGER, { .array = { 0, NULL } } },
+ {
+ SDB_TYPE_ARRAY | SDB_TYPE_INTEGER,
+ { .array = { SDB_STATIC_ARRAY_LEN(int_values1), int_values1 } },
+ },
+ -1,
+ },
+ {
+ {
+ SDB_TYPE_ARRAY | SDB_TYPE_INTEGER,
+ { .array = { SDB_STATIC_ARRAY_LEN(int_values1), int_values1 } },
+ },
+ { SDB_TYPE_ARRAY | SDB_TYPE_INTEGER, { .array = { 0, NULL } } },
+ 1,
+ },
{
{
SDB_TYPE_ARRAY | SDB_TYPE_INTEGER,
},
1,
},
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_STRING, { .array = { 0, NULL } } },
+ { SDB_TYPE_ARRAY | SDB_TYPE_STRING, { .array = { 0, NULL } } },
+ 0,
+ },
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_STRING, { .array = { 0, NULL } } },
+ {
+ SDB_TYPE_ARRAY | SDB_TYPE_STRING,
+ { .array = { SDB_STATIC_ARRAY_LEN(string_values1), string_values1 } },
+ },
+ -1,
+ },
+ {
+ {
+ SDB_TYPE_ARRAY | SDB_TYPE_STRING,
+ { .array = { SDB_STATIC_ARRAY_LEN(string_values1), string_values1 } },
+ },
+ { SDB_TYPE_ARRAY | SDB_TYPE_STRING, { .array = { 0, NULL } } },
+ 1,
+ },
{
{
SDB_TYPE_ARRAY | SDB_TYPE_STRING,
{ SDB_TYPE_STRING, { .string = "/regex/" } },
0,
},
+ /* TODO: add support for arrays */
};
size_t i;
{ string_array3, string_array, 0 },
{ int_array2, string_array, 0 },
{ dec_array2, string_array, 0 },
+ {
+ { SDB_TYPE_INTEGER | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ int_array, 1,
+ },
+ {
+ { SDB_TYPE_INTEGER | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ dec_array, 0,
+ },
+ {
+ { SDB_TYPE_DECIMAL | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ dec_array, 1,
+ },
+ {
+ { SDB_TYPE_DECIMAL | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ int_array, 0,
+ },
+ {
+ { SDB_TYPE_STRING | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ string_array, 1,
+ },
+ {
+ { SDB_TYPE_STRING | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ dec_array, 0,
+ },
};
size_t i;
{ string_array, 4, { -1, { .integer = 0 } } },
{ { SDB_TYPE_INTEGER, { .integer = 666 } }, 0, { -1, { .integer = 0 } } },
{ { SDB_TYPE_INTEGER, { .integer = 666 } }, 1, { -1, { .integer = 0 } } },
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_INTEGER, { .array = { 0, NULL } } },
+ 0, { -1, { .integer = 0 } },
+ },
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_DECIMAL, { .array = { 0, NULL } } },
+ 0, { -1, { .integer = 0 } },
+ },
+ {
+ { SDB_TYPE_ARRAY | SDB_TYPE_STRING, { .array = { 0, NULL } } },
+ 0, { -1, { .integer = 0 } },
+ },
};
size_t i;
} },
},
},
+ {
+ { SDB_TYPE_INTEGER | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ {
+ SDB_TYPE_INTEGER | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(int_values), int_values } },
+ },
+ err,
+ err,
+ err,
+ err,
+ err,
+ {
+ SDB_TYPE_INTEGER | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(int_values), int_values } },
+ },
+ },
+ {
+ {
+ SDB_TYPE_INTEGER | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(int_values), int_values } },
+ },
+ { SDB_TYPE_INTEGER | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ err,
+ err,
+ err,
+ err,
+ err,
+ {
+ SDB_TYPE_INTEGER | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(int_values), int_values } },
+ },
+ },
+ {
+ { SDB_TYPE_STRING | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ {
+ SDB_TYPE_STRING | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(string_values), string_values } },
+ },
+ err,
+ err,
+ err,
+ err,
+ err,
+ {
+ SDB_TYPE_STRING | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(string_values), string_values } },
+ },
+ },
+ {
+ {
+ SDB_TYPE_STRING | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(string_values), string_values } },
+ },
+ { SDB_TYPE_STRING | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ err,
+ err,
+ err,
+ err,
+ err,
+ {
+ SDB_TYPE_STRING | SDB_TYPE_ARRAY,
+ { .array = { SDB_STATIC_ARRAY_LEN(string_values), string_values } },
+ },
+ },
{
{ SDB_TYPE_NULL, { .integer = 0 } },
{ SDB_TYPE_NULL, { .integer = 0 } },
{ SDB_TYPE_REGEX, { .re = { "some regex", empty_re } } },
"\"/some regex/\"",
},
+ {
+ { SDB_TYPE_INTEGER | SDB_TYPE_ARRAY, { .array = { 0, NULL } } },
+ "[]",
+ },
{
{
SDB_TYPE_INTEGER | SDB_TYPE_ARRAY,