/*
- * test_bt_values.c
+ * SPDX-License-Identifier: GPL-2.0-only
*
- * Babeltrace value objects tests
- *
- * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation
- * Copyright (c) 2015 Philippe Proulx <pproulx@efficios.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; under version 2 of the License.
+ * Copyright (C) 2015 EfficiOS Inc. and Linux Foundation
+ * Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Babeltrace value objects tests
*/
#include <babeltrace2/babeltrace.h>
#include <string.h>
#include "tap/tap.h"
-#define NR_TESTS 188
+#define NR_TESTS 190
static
void test_null(void)
}
static
-bt_bool test_map_foreach_cb_count(const char *key, bt_value *object,
+bt_value_map_foreach_entry_func_status test_map_foreach_cb_count(
+ const char *key, bt_value *object,
void *data)
{
int *count = data;
if (*count == 3) {
- return BT_FALSE;
+ return BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_INTERRUPT;
+ } else if (*count == 4) {
+ return BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_ERROR;
+ } else if (*count == 5) {
+ return BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_MEMORY_ERROR;
}
(*count)++;
- return BT_TRUE;
+ return BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_OK;
}
struct map_foreach_checklist {
};
static
-bt_bool test_map_foreach_cb_check(const char *key, bt_value *object,
- void *data)
+bt_value_map_foreach_entry_func_status test_map_foreach_cb_check(
+ const char *key, bt_value *object, void *data)
{
struct map_foreach_checklist *checklist = data;
key);
}
- return BT_TRUE;
+ return BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_OK;
}
static
ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_count,
&count);
ok(ret == BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED && count == 3,
- "bt_value_map_foreach_entry() breaks the loop when the user function returns BT_FALSE");
+ "bt_value_map_foreach_entry() breaks the loop when the user function returns BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_INTERRUPT");
+
+ count = 4;
+ ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_count,
+ &count);
+ ok(ret == BT_VALUE_MAP_FOREACH_ENTRY_STATUS_USER_ERROR,
+ "bt_value_map_foreach_entry() fails when the user function returns BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_ERROR");
+ bt_current_thread_clear_error();
+
+ count = 5;
+ ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_count,
+ &count);
+ ok(ret == BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR,
+ "bt_value_map_foreach_entry() fails when the user function returns BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_MEMORY_ERROR");
+ bt_current_thread_clear_error();
memset(&checklist, 0, sizeof(checklist));
ret = bt_value_map_foreach_entry(map_obj, test_map_foreach_cb_check,
test_is_equal();
test_copy();
test_extend();
- return 0;
+ return exit_status();
}