better tests
This commit is contained in:
@@ -29,13 +29,16 @@ test_it()
|
|||||||
str_deinit(&s);
|
str_deinit(&s);
|
||||||
|
|
||||||
// TEST str_init_data
|
// TEST str_init_data
|
||||||
|
printf("testing str_init_data...\n");
|
||||||
str_init_data(&s, "hello");
|
str_init_data(&s, "hello");
|
||||||
my_assert(s.len == strlen("hello"),
|
my_assert(s.len == strlen("hello"),
|
||||||
"str_init_data, неправильный размер строки");
|
"str_init_data, неправильный размер строки");
|
||||||
|
my_assert(str_data(&s) != NULL, "str_data вернула NULL, а должна указатель на строку");
|
||||||
my_assert(strcmp(str_data(&s), "hello") == 0,
|
my_assert(strcmp(str_data(&s), "hello") == 0,
|
||||||
"str_init_data, не правильная строка '%s' != 'hello'", str_data(&s));
|
"str_init_data, не правильная строка '%s' != 'hello'", str_data(&s));
|
||||||
|
|
||||||
// TEST str_set
|
// TEST str_set
|
||||||
|
printf("testing str_set...\n");
|
||||||
str_set(&s, "");
|
str_set(&s, "");
|
||||||
my_assert(s.len == 0,
|
my_assert(s.len == 0,
|
||||||
"str_set, нулевая строка, неверный размер");
|
"str_set, нулевая строка, неверный размер");
|
||||||
@@ -50,6 +53,7 @@ test_it()
|
|||||||
"str_set, нулевая строка, не верное содержимое %s", str_data(&s));
|
"str_set, нулевая строка, не верное содержимое %s", str_data(&s));
|
||||||
|
|
||||||
// TEST str_copy
|
// TEST str_copy
|
||||||
|
printf("testing str_copy...\n");
|
||||||
str s2;
|
str s2;
|
||||||
s2 = str_copy(&s);
|
s2 = str_copy(&s);
|
||||||
my_assert(s2.len == s.len,
|
my_assert(s2.len == s.len,
|
||||||
@@ -61,6 +65,7 @@ test_it()
|
|||||||
str_deinit(&s2);
|
str_deinit(&s2);
|
||||||
|
|
||||||
// TEST str_append
|
// TEST str_append
|
||||||
|
printf("testing str_append...\n");
|
||||||
str_set(&s, "hello");
|
str_set(&s, "hello");
|
||||||
str_append(&s, " world");
|
str_append(&s, " world");
|
||||||
my_assert(strcmp(s.ptr, "hello world") == 0,
|
my_assert(strcmp(s.ptr, "hello world") == 0,
|
||||||
@@ -114,4 +119,4 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
test_it();
|
test_it();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user