1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-05-09 23:56:19 +00:00

Fixed tests on travis ci.

This commit is contained in:
Shuai Lin 2016-06-28 15:40:12 +08:00
parent 28619641b8
commit f37f645998
2 changed files with 6 additions and 12 deletions

View File

@ -6,6 +6,7 @@
*/
#include <glib.h>
#include <glib-object.h>
#include "clar_test.h"

View File

@ -336,22 +336,15 @@ test_searpc__json_return_type (void)
json_decref(result);
}
// The macro `json_object_foreach` is not defined in older versions of
// libjansson.
#ifndef json_object_foreach
#define json_object_foreach(object, key, value) \
for(key = json_object_iter_key(json_object_iter(object)); \
key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
#endif
json_t *
count_json_kvs (const json_t *obj, GError **error)
{
int count = 0;
const char *key;
const json_t *value;
json_object_foreach(((json_t*)obj), key, value) {
json_t *member;
member = json_object_iter ((json_t*)obj);
while (member != NULL) {
member = json_object_iter_next ((json_t*)obj, member);
count++;
}