-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_string.c
41 lines (26 loc) · 917 Bytes
/
test_string.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
#include <core/structures/string.h>
#include <string.h>
#include "test.h"
int main(int argc, char **argv)
{
BEGIN_TESTS();
struct core_string string;
core_string_init(&string, NULL);
TEST_POINTER_EQUALS(core_string_get(&string), NULL);
TEST_INT_EQUALS(core_string_length(&string), 0);
core_string_append(&string, "foo");
TEST_INT_EQUALS(core_string_length(&string), 3);
core_string_destroy(&string);
{
char sequence1[] = "0123456789";
char expected1[] = "9876543210";
char sequence2[] = "0123456789";
char expected2[] = "3456789012";
core_string_reverse_c_string(sequence1, 0, strlen(sequence1) - 1);
TEST_INT_EQUALS(strcmp(sequence1, expected1), 0);
core_string_rotate_c_string(sequence2, strlen(sequence2), 3);
TEST_INT_EQUALS(strcmp(sequence2, expected2), 0);
}
END_TESTS();
return 0;
}