END_TEST START_TEST(test_mm_strings_put_and_get_multiple) { ck_assert(multimap_put(map, strdup("k1"), strdup("v1"))); ck_assert(multimap_put(map, strdup("k1"), strdup("v2"))); ck_assert(multimap_put(map, strdup("k1"), strdup("v3"))); multimap_values_t * values = multimap_get(map, "k1"); ck_assert(!!values->next); ck_assert(!!values->next->next); ck_assert(!values->next->next->next); ck_assert_str_eq(values->value, "v1"); ck_assert_str_eq(values->next->value, "v2"); ck_assert_str_eq(values->next->next->value, "v3"); ck_assert_uint_eq(3, multimap_size(map)); }
END_TEST /******************************************************************************* * is_asn1 */ START_TEST(test_is_asn1) { typedef struct { bool asn1; chunk_t chunk; } testdata_t; u_char buf[8]; chunk_t chunk_zero = { buf, 0 }; chunk_t chunk_mean = { 0, 1 }; testdata_t test[] = { { FALSE, chunk_zero }, { FALSE, chunk_empty }, { FALSE, chunk_mean }, { TRUE, chunk_from_chars(0x30, 0x00) }, { TRUE, chunk_from_chars(0x31, 0x00) }, { TRUE, chunk_from_chars(0x04, 0x00) }, { FALSE, chunk_from_chars(0x02, 0x00) }, { FALSE, chunk_from_chars(0x30, 0x01) }, { FALSE, chunk_from_chars(0x30, 0x80) }, { TRUE, chunk_from_chars(0x30, 0x01, 0xa1) }, { FALSE, chunk_from_chars(0x30, 0x01, 0xa1, 0xa2) }, { TRUE, chunk_from_chars(0x30, 0x01, 0xa1, 0x0a) }, { FALSE, chunk_from_chars(0x30, 0x01, 0xa1, 0xa2, 0x0a) }, }; int i; for (i = 0; i < countof(test); i++) { ck_assert(is_asn1(test[i].chunk) == test[i].asn1); } }
} END_TEST START_TEST (test_RFS_NT) { struct RFstring *s1 = RFS_NT("a string"); struct RFstring *s2 = RFS_NT("a string %s %d", "with", 123); ck_assert_rf_str_eq_cstr(s1, "a string"); ck_assert(rf_string_data(s1)[rf_string_length_bytes(s1)] == '\0'); ck_assert_rf_str_eq_cstr(s2, "a string with 123"); ck_assert(rf_string_data(s2)[rf_string_length_bytes(s2)] == '\0'); struct RFstring *s3 = RFS_NT_OR_DIE("a string"); struct RFstring *s4 = RFS_NT("a string %s %d", "with", 123); ck_assert_rf_str_eq_cstr(s3, "a string"); ck_assert(rf_string_data(s3)[rf_string_length_bytes(s3)] == '\0'); ck_assert_rf_str_eq_cstr(s4, "a string with 123"); ck_assert(rf_string_data(s4)[rf_string_length_bytes(s4)] == '\0'); // test that subsequent allocations don't overwite the null terminating // character ck_assert(rf_string_data(s1)[rf_string_length_bytes(s1)] == '\0'); ck_assert(rf_string_data(s2)[rf_string_length_bytes(s2)] == '\0'); ck_assert(rf_string_data(s3)[rf_string_length_bytes(s3)] == '\0'); ck_assert(rf_string_data(s4)[rf_string_length_bytes(s4)] == '\0'); } END_TEST
static UA_StatusCode sym_sign_testing(const UA_SecurityPolicy *securityPolicy, void *channelContext, const UA_ByteString *message, UA_ByteString *signature) { SET_CALLED(sym_sign); ck_assert(securityPolicy != NULL); ck_assert(channelContext != NULL); ck_assert(message != NULL); ck_assert(signature != NULL); ck_assert(signature->length != 0); ck_assert(signature->data != NULL); memset(signature->data, 'S', signature->length); return UA_STATUSCODE_GOOD; }
END_TEST START_TEST (array_reseed_delay_64) { unsigned int size=ARRAY_SIZE-1; unsigned int offset=16; unsigned int multiplier=8; // 1 - 8bit, 2 - 64bit, 4 - 32bit, ... /* Generate one size */ {{{ unsigned char dst[ARRAY_SIZE] = {0}; ck_assert_int_eq (rdrand_get_uint64_array_reseed_delay((uint64_t *)&dst, size/multiplier, RETRY_LIMIT), size/multiplier); // test if it wrote just into the place it should ck_assert(test_zeros(dst, ARRAY_SIZE, size, ARRAY_SIZE)); // test if it wrote something (rarely can fail) ck_assert(test_ones(dst, ARRAY_SIZE, 0, size)); }}} /* Generate half size */ {{{ unsigned char dst[ARRAY_SIZE] = {0}; ck_assert_int_eq (rdrand_get_uint64_array_reseed_delay((uint64_t *)&dst, size/(2*multiplier), RETRY_LIMIT), size/(2*multiplier)); // test if it wrote just into the place it should ck_assert(test_zeros(dst, ARRAY_SIZE, size/2, ARRAY_SIZE)); // test if it wrote something (rarely can fail) ck_assert(test_ones(dst, ARRAY_SIZE, 0, size/2)); }}} /* Generate half size with offset */ {{{ unsigned char dst[ARRAY_SIZE] = {0}; ck_assert_int_eq (rdrand_get_uint64_array_reseed_delay((uint64_t *)&dst+offset/multiplier, size/(2*multiplier), RETRY_LIMIT), size/(2*multiplier)); // test if it wrote just into the place it should ck_assert(test_zeros(dst, ARRAY_SIZE, size/2+offset, ARRAY_SIZE)); // test if it wrote just into the place it should ck_assert(test_zeros(dst, ARRAY_SIZE, 0, offset)); // test if it wrote something (rarely can fail) ck_assert(test_ones(dst, ARRAY_SIZE, offset, size/2)); }}} }
END_TEST /** * url length test * * uses access dataset and test unit */ START_TEST(nsurl_length_test) { nserror err; nsurl *res_url; const struct test_triplets *tst = &access_tests[_i]; /* not testing create, this should always succeed */ err = nsurl_create(tst->test1, &res_url); ck_assert(err == NSERROR_OK); ck_assert_int_eq(nsurl_length(res_url), strlen(tst->test2)); nsurl_unref(res_url); }
END_TEST START_TEST (parse_node_descr_test_1) { char *descr = "1 | 2 3 4 | 5 6 7"; node_t *node = parse_node_descr(descr); ck_assert (node != NULL); if (node != NULL) { ck_assert_int_eq(node->id, 1); ck_assert_int_eq(node->out[0], 2); ck_assert_int_eq(node->out[1], 3); ck_assert_int_eq(node->out[2], 4); ck_assert_int_eq(node->in[0], 5); ck_assert_int_eq(node->in[1], 6); ck_assert_int_eq(node->in[2], 7); node_delete(node); } }
} END_TEST /** * \brief Verify deletion of image on given index * * Remove one image pointer from the middle of the image group array and * verify the image references are handled correctly. */ START_TEST(test_delete_index) { ck_assert( OK == group_delete_index(image_group, 2) ); ck_assert_str_eq( pointer_list[0]->name, group_get_image(image_group, 0)->name ); ck_assert_str_eq( pointer_list[1]->name, group_get_image(image_group, 1)->name ); ck_assert_str_eq( pointer_list[3]->name, group_get_image(image_group, 2)->name ); ck_assert_int_eq( 2, pointer_list[0]->ref ); ck_assert_int_eq( 2, pointer_list[1]->ref ); ck_assert_int_eq( 1, pointer_list[2]->ref ); ck_assert_int_eq( 2, pointer_list[3]->ref ); ck_assert_int_eq( 9, group_get_size(image_group) ); } END_TEST
END_TEST START_TEST(test_minmea_scan_d) { int direction; ck_assert(minmea_scan("K", "d", &direction) == false); ck_assert(minmea_scan("", "d", &direction) == true); ck_assert(minmea_scan(",foo", "d", &direction) == true); ck_assert_int_eq(direction, 0); ck_assert(minmea_scan("N", "d", &direction) == true); ck_assert_int_eq(direction, 1); ck_assert(minmea_scan("S,foo", "d", &direction) == true); ck_assert_int_eq(direction, -1); ck_assert(minmea_scan("W", "d", &direction) == true); ck_assert_int_eq(direction, -1); ck_assert(minmea_scan("E,foo", "d", &direction) == true); ck_assert_int_eq(direction, 1); }
}END_TEST START_TEST(ReadSingleAttributeUserExecutableWithoutTimestamp) { UA_Server *server = makeTestSequence(); UA_DataValue resp; UA_DataValue_init(&resp); UA_ReadRequest rReq; UA_ReadRequest_init(&rReq); rReq.nodesToRead = UA_ReadValueId_new(); rReq.nodesToReadSize = 1; rReq.nodesToRead[0].nodeId.identifier.numeric = UA_NS0ID_METHODNODE; rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_USEREXECUTABLE; readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp); ck_assert_int_eq(-1, resp.value.arrayLength); ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type); ck_assert(*(UA_Boolean*)resp.value.data==UA_FALSE); }END_TEST
}END_TEST START_TEST(ReadSingleAttributeHistorizingWithoutTimestamp) { UA_Server *server = makeTestSequence(); UA_DataValue resp; UA_DataValue_init(&resp); UA_ReadRequest rReq; UA_ReadRequest_init(&rReq); rReq.nodesToRead = UA_ReadValueId_new(); rReq.nodesToReadSize = 1; rReq.nodesToRead[0].nodeId = UA_NODEID_STRING(1, "the.answer"); rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_HISTORIZING; readValue(server, UA_TIMESTAMPSTORETURN_NEITHER, &rReq.nodesToRead[0], &resp); ck_assert_int_eq(-1, resp.value.arrayLength); ck_assert_ptr_eq(&UA_TYPES[UA_TYPES_BOOLEAN], resp.value.type); ck_assert(*(UA_Boolean* )resp.value.data==UA_FALSE); }END_TEST
END_TEST START_TEST(test_telnet_single_byte_commands) { unsigned char byte; for(byte = TELNET_NOP; byte <= TELNET_GA; ++byte) { // Arrange. telnet *tel = telnet_create(); // Act. telnet_update(tel, TELNET_IAC); telnet_update(tel, byte); // Assert. ck_assert_int_eq(tel->cmd_len, 2); ck_assert_int_eq(tel->cmd_ready, 1); unsigned char expected_cmd[] = {TELNET_IAC, byte}; ck_assert(memcmp(tel->cmd, expected_cmd, sizeof(expected_cmd)) == 0); // Clean up. telnet_destroy(tel); } }
END_TEST /******************************************************************************* * host_create_from_string_and_family */ static void test_create_from_string_and_family_any(char *string, int family, int expected) { host_t *host; host = host_create_from_string_and_family(string, family, 500); if (expected == AF_UNSPEC) { ck_assert(host == NULL); } else { verify_any(host, expected, 500); host->destroy(host); } }
END_TEST START_TEST (test_find_common_prefix_double_middle) { node * n = r3_tree_create(10); edge * e = r3_edge_createl(zstrdup("{slug}/foo/{name}"), sizeof("{slug}/foo/{name}")-1, NULL); r3_node_append_edge(n,e); int prefix_len; edge *ret_edge = NULL; char *errstr; errstr = NULL; ret_edge = r3_node_find_common_prefix(n, "{slug}/foo/{number}", sizeof("{slug}/foo/{number}")-1, &prefix_len, &errstr); ck_assert(ret_edge); ck_assert_int_eq(prefix_len, 11); SAFE_FREE(errstr); r3_tree_free(n); }
END_TEST START_TEST(path_add_invalid_path) { struct libinput *li; struct libinput_event *event; struct libinput_device *device; li = litest_create_context(); litest_disable_log_handler(li); device = libinput_path_add_device(li, "/tmp/"); litest_restore_log_handler(li); ck_assert(device == NULL); libinput_dispatch(li); while ((event = libinput_get_event(li))) ck_abort(); libinput_unref(li); }
} END_TEST START_TEST (test_type_comparison_for_sum_fncall_with_conversion) { struct type *t_i8 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_INT_8); struct type *t_i64 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_INT_64); struct type *t_f64 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_FLOAT_64); struct type *t_string = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_STRING); struct type *t_sum = testsupport_analyzer_type_create_operator(TYPEOP_SUM, t_i64, t_f64, t_string); typecmp_ctx_set_flags(TYPECMP_FLAG_FUNCTION_CALL); ck_assert(type_compare(t_i8, t_sum, TYPECMP_PATTERN_MATCHING)); const struct type *matched_type = typemp_ctx_get_matched_type(); ck_assert_msg( matched_type == t_i64, "Unexpected match type "RFS_PF" found", RFS_PA(type_str_or_die(matched_type, TSTR_DEFAULT)) ); } END_TEST
}END_TEST START_TEST(test_correct_code_find) { fl64 * result = NULL; si32 resSize = 0; fl64 vector[10] = { 2, 3, 4, 2, 6, 7, 8, 9, 0, 0 }; fl64 trueVal[3] = { 5, 6, 7 }; si32 size = 10; pi8 * operation = ">"; fl64 target = 6; pi8 * howMany = "all"; si32 inda = 0; findfl64(&result, &resSize, vector, size, operation, target, howMany); ck_assert(result != NULL); for (inda = 0; inda < resSize; inda++) { ck_assert_int_eq(trueVal[inda], result[inda]); } free(result); }END_TEST
END_TEST START_TEST(test_http_10_keepalive) { const gchar *headers = "POST / HTTP/1.0\n" "Connection: keep-alive\n" "Content-Length: 0\n\n"; gint err; qev_fd_t s = test_socket(); struct client *client = test_get_client_raw(); err = send(s, headers, strlen(headers), 0); ck_assert_int_eq(err, strlen(headers)); _assert_status_code(s, 403); ck_assert(!client->qev_client._flags.closed); close(s); }
END_TEST #define ref_unref_test(T, a) \ { \ int i; \ struct T *tmp = NULL; \ \ for (i = 0; i <= 256; i++) { \ tmp = T##_ref(a); \ ck_assert(tmp == a); \ } \ for (i = 0; i <= 256; i++) { \ tmp = T##_unref(a); \ ck_assert(tmp == NULL); \ } \ for (i = 0; i <= 256; i++) { \ tmp = T##_ref(a); \ ck_assert(tmp == a); \ tmp = T##_unref(a); \ ck_assert(tmp == NULL); \ } \ } START_TEST(device_ref_unref) { struct ratbag *r; struct ratbag_device *d; struct ratbag_test_device td = sane_device; r = ratbag_create_context(&abort_iface, NULL); d = ratbag_device_new_test_device(r, &td); ck_assert(d != NULL); ratbag_unref(r); ref_unref_test(ratbag_device, d); ratbag_device_unref(d); }
END_TEST START_TEST(test_single_resnum_08) { /* range */ strcpy(chain, "A"); resnum1 = 10 ; strcpy(insert1, "B"); resnum2 = 10 ; strcpy(insert2, "B"); /* pdb */ strcpy(pdb->chain, "A"); pdb->resnum = 10 ; strcpy(pdb->insert,"A"); /* expected output */ expected_output = FALSE; output = blInPDBZone(pdb, chain, resnum1, insert1, resnum2, insert2); ck_assert( output == expected_output ); }
} END_TEST START_TEST (test_IDSET_includes_guid_glob) { struct GUID server_guid = GUID_random(); struct GUID random_guid = GUID_random(); int i; struct idset *idset_in; struct rawidset *rawidset_in; const uint16_t repl_id = 0x0001; const uint64_t ids[] = {0x180401000000, 0x190401000000, 0x1a0401000000, 0x1b0401000000, 0x500401000000, 0x520401000000, 0x530401000000, 0x710401000000}; const uint64_t not_in_id = 0x2a0401000000; const size_t ids_size = sizeof(ids) / sizeof(uint64_t); rawidset_in = RAWIDSET_make(mem_ctx, true, false); ck_assert(rawidset_in != NULL); for (i = 0; i < ids_size; i++) { RAWIDSET_push_eid(rawidset_in, (ids[i] << 16) | repl_id); } ck_assert_int_eq(rawidset_in->count, ids_size); rawidset_in->idbased = false; rawidset_in->repl.guid = server_guid; idset_in = RAWIDSET_convert_to_idset(mem_ctx, rawidset_in); ck_assert(idset_in != NULL); /* Case: All inserted elements in the range */ for (i = 0; i < ids_size; i++) { ck_assert(IDSET_includes_guid_glob(idset_in, &server_guid, ids[i])); } /* Case: a different guid for the same id */ ck_assert(!IDSET_includes_guid_glob(idset_in, &random_guid, ids[0])); /* Case: Not in range and different guid */ ck_assert(!IDSET_includes_guid_glob(idset_in, &random_guid, not_in_id)); /* Case: Not in range */ ck_assert(!IDSET_includes_guid_glob(idset_in, &server_guid, not_in_id)); } END_TEST
END_TEST /******************************************************************************* * chunk_create_cat */ START_TEST(test_chunk_create_cat) { chunk_t foo, bar; chunk_t a, b, c; u_char *ptra, *ptrb; foo = chunk_from_str("foo"); bar = chunk_from_str("bar"); /* to simplify things we use the chunk_cata macro */ a = chunk_empty; b = chunk_empty; c = chunk_cata("cc", a, b); ck_assert_int_eq(c.len, 0); ck_assert(c.ptr != NULL); a = foo; b = bar; c = chunk_cata("cc", a, b); ck_assert_int_eq(c.len, 6); ck_assert(chunk_equals(c, chunk_from_str("foobar"))); a = chunk_clone(foo); b = chunk_clone(bar); c = chunk_cata("mm", a, b); ck_assert_int_eq(c.len, 6); ck_assert(chunk_equals(c, chunk_from_str("foobar"))); a = chunk_clone(foo); b = chunk_clone(bar); ptra = a.ptr; ptrb = b.ptr; c = chunk_cata("ss", a, b); ck_assert_int_eq(c.len, 6); ck_assert(chunk_equals(c, chunk_from_str("foobar"))); /* check memory area of cleared chunk */ ck_assert(!chunk_equals(foo, chunk_create(ptra, 3))); ck_assert(!chunk_equals(bar, chunk_create(ptrb, 3))); }
END_TEST START_TEST(test_error_double) { ck_assert(escdf_error_add(ESCDF_EFILE_CORRUPT, "test_2_1.c", 1234, "dummy21") == ESCDF_EFILE_CORRUPT); ck_assert(escdf_error_get_last(NULL) == ESCDF_EFILE_CORRUPT); ck_assert(escdf_error_len() == 1); ck_assert(escdf_error_add(ESCDF_ENOSUPPORT, "test_2_2.c", 202, "dummy22") == ESCDF_ENOSUPPORT); ck_assert(escdf_error_get_last(NULL) == ESCDF_ENOSUPPORT); ck_assert(escdf_error_len() == 2); escdf_error_fetchall(&err_str); ck_assert_str_eq(err_str, "libescdf: ERROR:\n" " * in test_2_1.c(dummy21):1234:\n" " file corrupted (ESCDF_EFILE_CORRUPT)\n" " * in test_2_2.c(dummy22):202:\n" " unsupported option in file (ESCDF_ENOSUPPORT)\n"); free(err_str); ck_assert(escdf_error_get_last(NULL) == ESCDF_SUCCESS); ck_assert(escdf_error_len() == 0); }
END_TEST START_TEST (test_set_method_type) { ck_assert(check_enter_method("program", parser_data) != NULL); set_method_type((Type){INT,0,0,0}, parser_data); ck_assert(get_type("program", parser_data).std_type == PGNAME); ck_assert(check_enter_method("fun", parser_data) != NULL); set_method_type((Type){INT,0,0,0}, parser_data); SymbolTable *fun = get_symbol("fun", parser_data, 1); ck_assert(fun != NULL); ck_assert(fun->symbol->type.std_type == INT); ck_assert(fun->symbol->type.fun == 1); }
} END_TEST START_TEST(test_typecheck_valid_custom_sum_type_constructor2) { static const struct RFstring s = RF_STRING_STATIC_INIT( "type person { name:string, b:u64 | id:u32, foo:f64}" "fn do_something()\n" "{\n" "a:person = person(\"Celina\", 53342)\n" "b:person = person(13, 54.231)\n" "}\n" ); front_testdriver_new_ast_main_source(&s); ck_assert_typecheck_ok(); struct ast_node *fn_impl = ast_node_get_child(front_testdriver_root(), 1); ck_assert(fn_impl->type == AST_FUNCTION_IMPLEMENTATION); struct ast_node *block = ast_fnimpl_body_get(fn_impl); struct ast_node *bop1 = ast_node_get_child(block, 0); struct ast_node *bop2 = ast_node_get_child(block, 1); ck_assert(ast_node_is_specific_binaryop(bop1, BINARYOP_ASSIGN)); ck_assert(ast_node_is_specific_binaryop(bop2, BINARYOP_ASSIGN)); struct ast_node *ctor1 = ast_binaryop_right(bop1); struct ast_node *ctor2 = ast_binaryop_right(bop2); ck_assert(ctor1->type = AST_FUNCTION_CALL); ck_assert(ctor2->type = AST_FUNCTION_CALL); struct type *t_string = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_STRING); struct type *t_u64 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_UINT_64); struct type *t_u32 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_UINT_32); struct type *t_f64 = testsupport_analyzer_type_create_simple_elementary(ELEMENTARY_TYPE_FLOAT_64); struct type *t_prod_1 = testsupport_analyzer_type_create_operator(TYPEOP_PRODUCT, t_string, t_u64); struct type *t_prod_2 = testsupport_analyzer_type_create_operator(TYPEOP_PRODUCT, t_u32, t_f64); ck_assert(type_compare(ctor1->fncall.params_type, t_prod_1, TYPECMP_IDENTICAL)); ck_assert(type_compare(ctor2->fncall.params_type, t_prod_2, TYPECMP_IDENTICAL)); } END_TEST
END_TEARDOWN /******************************************************************************* * insert first/last */ START_TEST(test_insert_first) { void *a = (void*)1, *b = (void*)2, *x = NULL; list->insert_first(list, a); ck_assert_int_eq(list->get_count(list), 1); ck_assert(list->get_first(list, &x) == SUCCESS); ck_assert(x == a); ck_assert(list->get_last(list, &x) == SUCCESS); ck_assert(x == a); list->insert_first(list, b); ck_assert_int_eq(list->get_count(list), 2); ck_assert(list->get_first(list, &x) == SUCCESS); ck_assert(x == b); ck_assert(list->get_last(list, &x) == SUCCESS); ck_assert(x == a); }
END_TEST START_TEST(test_fpn) { test_reset(); ck_assert(test_metrics->f.fpn == 0.0); INCR(test_metrics, f); ck_assert(test_metrics->f.fpn == 0.0); INCR_N(test_metrics, f, 2); ck_assert(test_metrics->f.fpn == 0.0); UPDATE_VAL(test_metrics, f, 2.1); ck_assert(test_metrics->f.fpn == 2.1); DECR(test_metrics, f); ck_assert(test_metrics->f.fpn == 2.1); DECR_N(test_metrics, f, 5); ck_assert(test_metrics->f.fpn == 2.1); }
END_TEST START_TEST(test_remove_last) { void *a = (void*)1, *b = (void*)2, *x = NULL; list->insert_first(list, a); list->insert_first(list, b); ck_assert(list->remove_last(list, &x) == SUCCESS); ck_assert_int_eq(list->get_count(list), 1); ck_assert(x == a); ck_assert(list->remove_last(list, &x) == SUCCESS); ck_assert_int_eq(list->get_count(list), 0); ck_assert(x == b); ck_assert(list->remove_first(list, &x) == NOT_FOUND); ck_assert(list->remove_last(list, &x) == NOT_FOUND); }
END_TEST START_TEST (test_iterate_many) { emhashmap_put(&map, key, value); emhashmap_put(&map, 2, value); MapIterator iterator = emhashmap_iterator(&map); MapEntry* entry = emhashmap_iterator_next(&iterator); ck_assert(entry != NULL); ck_assert(entry->key == key); ck_assert(entry->value == value); entry = emhashmap_iterator_next(&iterator); ck_assert(entry != NULL); ck_assert(entry->key == 2); ck_assert(entry->value == value); entry = emhashmap_iterator_next(&iterator); ck_assert(entry == NULL); }
static void assert_sorted(FSS *fss) { int i; MonitoredElement *prev = NULL; bool saw_unset = false; for (i = 0; i < fss->m; i++) { MonitoredElement *elt = &fss->monitored_elements[i]; if (!elt->set) { saw_unset = true; continue; } if (saw_unset) goto fail; if (!prev) continue; if (elt->frequency > prev->frequency) goto fail; if (elt->frequency == prev->frequency && elt->error < prev->error) goto fail; prev = elt; } return; fail: FSSPrint(fss); ck_assert(false); }