-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
66 lines (51 loc) · 1.44 KB
/
test.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "objstring.h"
#include "objstringcollection.h"
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <string.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsequence-point"
void each(string string, size_t index){
printf("String '%s' at index %d\n\n", string.string, index);
}
int main() {
// TESTING
string line = objstr(0);
$(line).c_copy("am O o O pisica O foarte O mare.");
stringcollection parts = $(line).c_split(" O ");
string repeat = $(parts.items[0]).repeat(2);
printf("%s <- original\n", repeat.string);
$(repeat).convert_upper();
printf("%s <- uppercase\n\n", repeat.string);
printf("starts with 'am' -> %d, ends with 'mare.' -> %d\n\n", $(line).c_starts("am"), $(line).c_ends("mare."));
$(line).c_concat("MORE DATA!!!!");
#ifndef typeof
$(parts).foreach(each);
#elif
$c(parts).foreach(each); // BOOHOO
#endif
$(line).c_copy("e");
$(line).free();
#ifndef typeof
$(parts).free();
#elif
$c(parts).free(); // BOOHOO
#endif
$(repeat).free();
// compat
printf("\n\nuser input test\n\n");
string input = objstr(0);
$(input).prealloc(128);
fgets(input.string, 128, stdin);
printf("normal : %s\n", input.string);
$(input).convert_upper();
printf("uppercase : %s\n", input.string);
$(input).convert_lower();
printf("lowercase : %s\n", input.string);
string subs = $(input).substring(0, 6);
printf("first 6 : %s\n", subs.string);
$(input).free();
$(subs).free();
return 0;
}