-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesthistory.c
43 lines (40 loc) · 1.18 KB
/
testhistory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include "message.h"
#include "history.h"
#include "tools.h"
int main(void){
/*printf("(Test écriture fichier log)\n");
//Message* msg = malloc(sizeof(Message*));
//strcpy(msg->sender,"Antoine");
//strcpy(msg->message,"Oui bonjour ceci est un test");
if(put_entry("Antoine; Oui bonjour ceci est un test")==-1){
printf("Echec du test\n");
} else {
printf("Réussite du test\n");
}
printf("(Test récupération de la ligne numéro 1)\n");
int fd;
if((fd=open(HISTORY_PATH, O_RDONLY))<0){
fprintf(stderr, "Failed to open History\n");
return -1;
}
char* buf = get_line(fd,5);
if(buf==NULL){
printf("Echec du test de lecture\n");
}
printf("%s\n",buf);
printf("%ud\n", countlines(HISTORY_PATH));
//printf("%s\n", get_history_brief());
char buf[strlen(get_line(20))];
printf("Test getLine");
printf("%s\n",get_line(20));
printf("Test cpy buf");
memcpy(buf,get_line(20),strlen(get_line(20)));
printf("%s\n",buf); */
printf("%s\n", get_history_brief());
}