summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2f85566)
raw | patch | inline | side by side (parent: 2f85566)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 20 Oct 2014 17:17:53 +0000 (19:17 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 20 Oct 2014 17:17:53 +0000 (19:17 +0200) |
… returning an array of strings.
src/core/store.c | patch | blob | history | |
t/unit/core/store_test.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index 81aedfb7600a9243accbe4e49cceffcf87f8c54b..d9ca4c0eb113a7a2824249d92d83fa45f4d4e56c 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
tmp.data.datetime = obj->interval;
break;
case SDB_FIELD_BACKEND:
- /* TODO: add support for storing array values in a data object
- * for now, fall thru to the error case */
+ {
+ tmp.type = SDB_TYPE_ARRAY | SDB_TYPE_STRING;
+ tmp.data.array.length = obj->backends_num;
+ tmp.data.array.values = obj->backends;
+ return sdb_data_copy(res, &tmp);
+ break;
+ }
default:
return -1;
}
index c1071fb584e0f18b333eb18607c1193f374a4fc1..826d938fc4444a5d02a0bde60812dcb83ebc0933 100644 (file)
--- a/t/unit/core/store_test.c
+++ b/t/unit/core/store_test.c
"sdb_store_get_field(<host>, SDB_FIELD_INTERVAL, <value>) "
"returned value {%d, %lu}; expected {%d, 10}",
value.type, value.data.datetime, SDB_TYPE_DATETIME);
+
+ check = sdb_store_get_field(host, SDB_FIELD_BACKEND, &value);
+ fail_unless(check == 0,
+ "sdb_store_get_field(<host>, SDB_FIELD_BACKEND, <value>) = "
+ "%d; expected: 0");
+ /* there are no backends in this test */
+ fail_unless((value.type == (SDB_TYPE_ARRAY | SDB_TYPE_STRING))
+ && (value.data.array.length == 0)
+ && (value.data.array.values == NULL),
+ "sdb_store_get_field(<host>, SDB_FIELD_BACKEND, <value>) "
+ "returned value {%d, %lu, %p}; expected {%d, 0, NULL}",
+ value.type, value.data.array.length, value.data.array.values,
+ SDB_TYPE_ARRAY | SDB_TYPE_STRING);
}
END_TEST