-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_insert.c
More file actions
101 lines (87 loc) · 3 KB
/
test_insert.c
File metadata and controls
101 lines (87 loc) · 3 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
#include "s21_string_tests.h"
START_TEST(insert_1) {
char s1[] = "crowd";
char s2[] = "crowd";
char *s3 = s21_insert(s1, s2, 5);
ck_assert_pstr_eq(s3, "crowdcrowd");
if (s3) free(s3);
} END_TEST
START_TEST(insert_2) {
char s1[] = "shop";
char s2[] = "roof";
char *s3 = s21_insert(s1, s2, 3);
ck_assert_pstr_eq(s3, "shoroofp");
if (s3) free(s3);
} END_TEST
START_TEST(insert_3) {
char s1[] = "She used her own hair to give it more flavor";
char s2[] = "in the soup ";
char *s3 = s21_insert(s1, s2, 22);
ck_assert_pstr_eq(s3, "She used her own hair in the soup to give it more flavor");
if (s3) free(s3);
} END_TEST
START_TEST(insert_4) {
char s1[] = "The doll spun around ";
char s2[] = "about being paranoid ";
char *s3 = s21_insert(s1, s2, 14);
ck_assert_pstr_eq(s3, "The doll spun about being paranoid around ");
if (s3) free(s3);
} END_TEST
START_TEST(insert_5) {
char s1[] = "";
char s2[] = "The Great Dane looked more like a horse than a dog.";
char *s3 = s21_insert(s1, s2, 0);
ck_assert_pstr_eq(s3, "The Great Dane looked more like a horse than a dog.");
if (s3) free(s3);
} END_TEST
START_TEST(insert_6) {
char s1[] = "Dan took the deep dive down the rabbit hole.";
char s2[] = "";
char *s3 = s21_insert(s1, s2, 7);
ck_assert_pstr_eq(s3, "Dan took the deep dive down the rabbit hole.");
if (s3) free(s3);
} END_TEST
START_TEST(insert_7) {
char s1[] = "";
char s2[] = "";
char *s3 = s21_insert(s1, s2, 0);
ck_assert_pstr_eq(s3, "");
if (s3) free(s3);
} END_TEST
START_TEST(insert_8) {
char s1[] = "";
char s2[] = "";
char *s3 = s21_insert(s1, s2, 8);
ck_assert_pstr_eq(s3, NULL);
if (s3) free(s3);
} END_TEST
START_TEST(insert_9) {
char s1[] = "Pat ordered a ghost pepper pie.";
char s2[] = "He appeared to be confusingly perplexed.";
char *s3 = s21_insert(s1, s2, 4);
ck_assert_pstr_eq(s3, "Pat He appeared to be confusingly perplexed.ordered a ghost pepper pie.");
if (s3) free(s3);
} END_TEST
START_TEST(insert_10) {
char s1[] = "The sign said there was road work ahead so he decided to speed up.";
char s2[] = "~!@#$^&*()_+:|<>?`-=[]{}',./";
char *s3 = s21_insert(s1, s2, 15);
ck_assert_pstr_eq(s3, "The sign said t~!@#$^&*()_+:|<>?`-=[]{}',./here was road work ahead so he decided to speed up.");
if (s3) free(s3);
} END_TEST
Suite *test_insert() {
Suite *test_set = suite_create("s21_insert");
TCase *test_group = tcase_create("insert_test_group");
tcase_add_test(test_group, insert_1);
tcase_add_test(test_group, insert_2);
tcase_add_test(test_group, insert_3);
tcase_add_test(test_group, insert_4);
tcase_add_test(test_group, insert_5);
tcase_add_test(test_group, insert_6);
tcase_add_test(test_group, insert_7);
tcase_add_test(test_group, insert_8);
tcase_add_test(test_group, insert_9);
tcase_add_test(test_group, insert_10);
suite_add_tcase(test_set, test_group);
return test_set;
}