mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 23:28:09 +00:00
Read file in binary mode in vcard tester + test if fopen did work
This commit is contained in:
parent
5b869f8d48
commit
e645eba147
1 changed files with 17 additions and 14 deletions
|
|
@ -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);
|
||||
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();
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue