-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
45 lines (42 loc) · 1.48 KB
/
main.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
44
45
#include <stdio.h>
#include "ft_string.h"
int main()
{
t_string *s = {String("test")};
printf("begin: %s\n", s->begin());
printf("data: %s\n", s->data);
printf("current: %s\n", s->current);
printf("capacity: %ld\n", s->capacity);
printf("end(): %s\n", s->end() - 1);
printf("at(): %c\n", s->at(2));
printf("empty(): %s\n",s->empty()? "true" : "false");
printf("compare %d\n", s->compare("tess"));
printf("substr: %s\n", s->substr((pos){.start=1, .skip='t'}));
printf("find: %d\n", s->find('e'));
printf("equal true: %s\n", s->equal("test")? "true" : "false");
printf("equal false: %s\n", s->equal("testo")? "true" : "false");
s->push_back('e');
s->push_back('s');
s->push_back('t');
printf("data: %s\n", s->data);
s->append(" prova");
printf("data: %s\n", s->data);
const char *c_str = s->c_str();
printf("c_str: %s\n", c_str);
printf("contain: %s\n", s->contain("es") ? "true" : "false");
printf("contain: %s\n", s->contain("pippo") ? "true" : "false");
printf("\ncopy constructor test:\n\n");
t_string *s2 = {String(s)};
printf("begin: %s\n", s2->begin());
printf("data: %s\n", s2->data);
printf("current: %s\n", s2->current);
printf("capacity: %ld\n", s2->capacity);
printf("end(): %s\n", s2->end() - 1);
printf("at(): %c\n", s2->at(2));
printf("empty(): %s\n",s2->empty()? "true" : "false");
printf("compare %d\n", s2->compare("tess"));
printf("substr: %s\n", s2->substr((pos){.start=1}));
s2->clear();
printf("data: %s\n", s2->data);
printf("current: %s\n", s2->current);
}