-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_trim.c
More file actions
110 lines (95 loc) · 3.04 KB
/
test_trim.c
File metadata and controls
110 lines (95 loc) · 3.04 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "s21_string_tests.h"
START_TEST(trim_1) {
char s1[] = "Shakespeare was a famous 17th-century diesel mechanic";
char s2[] = "Shakespeare mechanic";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "was a famous 17th-century diesel");
if (s3) free(s3);
} END_TEST
START_TEST(trim_2) {
char s1[] = "It was the first time he had ever seen someone cook dinner on an elephant";
char s2[] = "It was";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "he first time he had ever seen someone cook dinner on an elephan");
if (s3) free(s3);
} END_TEST
START_TEST(trim_3) {
char s1[] = "She learned that water bottles are no longer just to hold liquid";
char s2[] = "She learned liquid";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "that water bottles are no longer just to ho");
if (s3) free(s3);
} END_TEST
START_TEST(trim_4) {
char s1[] = "";
char s2[] = "";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, s21_NULL);
if (s3) free(s3);
} END_TEST
START_TEST(trim_5) {
char s1[] = " ";
char s2[] = " ";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, s21_NULL);
if (s3) free(s3);
} END_TEST
START_TEST(trim_6) {
char s1[] = "test";
char s2[] = "test";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, s21_NULL);
if (s3) free(s3);
} END_TEST
START_TEST(trim_7) {
char s1[] = "Had he known what was going to happen";
char s2[] = "going";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "Had he known what was going to happe");
if (s3) free(s3);
} END_TEST
START_TEST(trim_8) {
char s1[] = "Everyone says they love nature until they realize how dangerous she can be...";
char s2[] = "... ";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "Everyone says they love nature until they realize how dangerous she can be");
if (s3) free(s3);
} END_TEST
START_TEST(trim_9) {
char s1[] = "obligation";
char s2[] = "onb";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "ligati");
if (s3) free(s3);
} END_TEST
START_TEST(trim_10) {
char s1[] = " free(!s1)";
char s2[] = "!s1() ";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "free");
if (s3) free(s3);
} END_TEST
START_TEST(trim_11) {
char s1[] = "spokesperson";
char s2[] = "spon";
char *s3 = s21_trim(s1, s2);
ck_assert_pstr_eq(s3, "kesper");
if (s3) free(s3);
} END_TEST
Suite *test_trim() {
Suite *test_set = suite_create("s21_trim");
TCase *test_group = tcase_create("trim_test_group");
tcase_add_test(test_group, trim_1);
tcase_add_test(test_group, trim_2);
tcase_add_test(test_group, trim_3);
tcase_add_test(test_group, trim_4);
tcase_add_test(test_group, trim_5);
tcase_add_test(test_group, trim_6);
tcase_add_test(test_group, trim_7);
tcase_add_test(test_group, trim_8);
tcase_add_test(test_group, trim_9);
tcase_add_test(test_group, trim_10);
tcase_add_test(test_group, trim_11);
suite_add_tcase(test_set, test_group);
return test_set;
}