Commit e645eba1 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Read file in binary mode in vcard tester + test if fopen did work

parent 5b869f8d
......@@ -64,9 +64,9 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) {
clock_t start, end;
double elapsed = 0;
const MSList *friends = NULL;
FILE *infile;
char *buffer;
long numbytes;
FILE *infile = NULL;
char *buffer = NULL;
long numbytes = 0;
start = clock();
linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
......@@ -82,17 +82,21 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) {
#endif
lfl = linphone_core_create_friend_list(manager->lc);
infile = fopen(import_filepath, "r");
fseek(infile, 0L, SEEK_END);
numbytes = ftell(infile);
fseek(infile, 0L, SEEK_SET);
buffer = (char*)ms_malloc(numbytes * sizeof(char));
numbytes = fread(buffer, sizeof(char), numbytes, infile);
fclose(infile);
start = clock();
linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
end = clock();
infile = fopen(import_filepath, "rb");
BC_ASSERT_PTR_NOT_NULL(infile);
if (infile) {
fseek(infile, 0L, SEEK_END);
numbytes = ftell(infile);
fseek(infile, 0L, SEEK_SET);
buffer = (char*)ms_malloc(numbytes * sizeof(char));
numbytes = fread(buffer, sizeof(char), numbytes, infile);
fclose(infile);
start = clock();
linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
end = clock();
ms_free(buffer);
}
friends = linphone_friend_list_get_friends(lfl);
BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI
......@@ -103,7 +107,6 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) {
BC_ASSERT_TRUE(elapsed < 1500000); // 1.5 seconds
#endif
ms_free(buffer);
linphone_friend_list_unref(lfl);
ms_free(import_filepath);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment