-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_memchr.c
executable file
·75 lines (63 loc) · 2.18 KB
/
test_memchr.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
#include "s21_string_tests.h"
START_TEST(memchr_1) {
char str[] = "This made him feel like an old-style rootbeer float smells.";
int ch = ' ';
s21_size_t len = strlen(str);
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_2) {
char str[] = "Mom didn’t understand why no one else wanted a hot tub full of jello.";
int ch = '1';
s21_size_t len = strlen(str);
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_3) {
char str[] = "Grape jelly was leaking out the hole in the roof.";
int ch = 'l';
s21_size_t len = 10;
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_4) {
char str[] = "Hello, world!";
int ch = '\0';
s21_size_t len = 10;
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_5) {
char str[] = "Being unacquainted with the chief raccoon was harming his prospects for promotion.";
int ch = '\0';
s21_size_t len = 3;
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_6) {
char str[] = "";
int ch = '7';
s21_size_t len = 1;
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_7) {
char str[] = "\0\t\b\n";
int ch = '\n';
s21_size_t len = 1;
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
START_TEST(memchr_8) {
char str[] = "\0\t\b\n\0";
int ch = ' ';
s21_size_t len = 3;
ck_assert_ptr_eq(memchr(str, ch, len), s21_memchr(str, ch, len));
} END_TEST
Suite *test_memchr() {
Suite *test_set = suite_create("s21_memchr");
TCase *test_group = tcase_create("memchr_test_group");
tcase_add_test(test_group, memchr_1);
tcase_add_test(test_group, memchr_2);
tcase_add_test(test_group, memchr_3);
tcase_add_test(test_group, memchr_4);
tcase_add_test(test_group, memchr_5);
tcase_add_test(test_group, memchr_6);
tcase_add_test(test_group, memchr_7);
tcase_add_test(test_group, memchr_8);
suite_add_tcase(test_set, test_group);
return test_set;
}