-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfstr_tests.c
79 lines (62 loc) · 1.49 KB
/
fstr_tests.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
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// Created by tobin on 3/20/2024.
//
#include <stdio.h>
#include <malloc.h>
#include "fstr_tests.h"
#include "fstr.h"
#define linebreak printf("\n\n")
#define assert(a, b) printf("%d\n", fstr_equals_C(a,b))
void test_from_C() {
printf("Test From C: ");
fstr *str = fstr_from_C("0123456789");
assert(str, "0123456789");
free(str);
}
void test_from_format_c() {
printf("Test From C Format: ");
fstr *str = fstr_from_format_C("%d %.5f %s", 10, 12.123456789, "abcd");
assert(str, "10 12.12346 abcd");
free(str);
}
void test_from_length() {
printf("Test From Length: ");
fstr *str = fstr_from_length(10, '.');
assert(str, "..........");
free(str);
}
void test_append_c() {
printf("Test Append C: ");
fstr *str = fstr_from_C("Hello");
fstr_append_C(str, " World");
assert(str, "Hello World");
free(str);
}
void test_append() {
printf("Test Append: ");
fstr *str = fstr_from_C("Hello");
fstr *add = fstr_from_C(" World!");
fstr_append(str, add);
assert(str, "Hello World");
free(str);
free(add);
}
void fstr_run_tests() {
usize i = 0;
usize iterations = 1;
for (i = 0; i < iterations; i++) {
test_from_C();
}
for (i = 0; i < iterations; i++) {
test_from_format_c();
}
for (i = 0; i < iterations; i++) {
test_from_length();
}
for (i = 0; i < iterations; i++) {
test_append_c();
}
for (i = 0; i < iterations; i++) {
test_append();
}
}