[A] Added astyle
This commit is contained in:
@@ -14,7 +14,8 @@ struct test_case test_suit [] = {
|
||||
{"test_table_tbl_options", test_table_tbl_options},
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
int n_tests = sizeof(test_suit) / sizeof(test_suit[0]);
|
||||
fprintf(stderr, "[==========] Running %d test(s).\n", n_tests);
|
||||
int i;
|
||||
|
@@ -5,14 +5,14 @@
|
||||
#include "wchar.h"
|
||||
|
||||
|
||||
size_t strchr_count(const char* str, char ch);
|
||||
size_t wstrchr_count(const wchar_t* str, wchar_t ch);
|
||||
size_t strchr_count(const char *str, char ch);
|
||||
size_t wstrchr_count(const wchar_t *str, wchar_t ch);
|
||||
|
||||
const char* str_n_substring_beg(const char* str, char ch_separator, size_t n);
|
||||
const wchar_t* wstr_n_substring_beg(const wchar_t* str, wchar_t ch_separator, size_t n);
|
||||
const char *str_n_substring_beg(const char *str, char ch_separator, size_t n);
|
||||
const wchar_t *wstr_n_substring_beg(const wchar_t *str, wchar_t ch_separator, size_t n);
|
||||
|
||||
fort_status_t str_n_substring(const char* str, char ch_separator, size_t n, const char **begin, const char **end);
|
||||
void wstr_n_substring(const wchar_t* str, wchar_t ch_separator, size_t n, const wchar_t **begin, const wchar_t **end);
|
||||
fort_status_t str_n_substring(const char *str, char ch_separator, size_t n, const char **begin, const char **end);
|
||||
void wstr_n_substring(const wchar_t *str, wchar_t ch_separator, size_t n, const wchar_t **begin, const wchar_t **end);
|
||||
|
||||
|
||||
size_t buffer_text_width(string_buffer_t *buffer);
|
||||
@@ -149,14 +149,14 @@ void test_str_n_substring(void)
|
||||
assert_true(wbeg == wstr && wend == wstr + 1);
|
||||
|
||||
str_n_substring(str, '\n', 1, &beg, &end);
|
||||
assert_true(beg == str +4 && end == str + 8);
|
||||
assert_true(beg == str + 4 && end == str + 8);
|
||||
str_n_substring(str, '\n', 2, &beg, &end);
|
||||
assert_true(beg == str + 9 && end == str + strlen(str));
|
||||
str_n_substring(str, '\n', 3, &beg, &end);
|
||||
assert_true(beg == NULL && end == NULL);
|
||||
|
||||
wstr_n_substring(wstr, L'\n', 1, &wbeg, &wend);
|
||||
assert_true(wbeg == wstr +4 && wend == wstr + 8);
|
||||
assert_true(wbeg == wstr + 4 && wend == wstr + 8);
|
||||
wstr_n_substring(wstr, L'\n', 2, &wbeg, &wend);
|
||||
assert_true(wbeg == wstr + 9 && wend == wstr + wcslen(wstr));
|
||||
wstr_n_substring(wstr, L'\n', 3, &wbeg, &wend);
|
||||
@@ -200,22 +200,22 @@ void test_buffer_text_width(void)
|
||||
buffer->type = CharBuf;
|
||||
char *old_value = buffer->str.cstr;
|
||||
|
||||
buffer->str.cstr = (char*)"";
|
||||
buffer->str.cstr = (char *)"";
|
||||
assert_true(buffer_text_width(buffer) == 0);
|
||||
|
||||
buffer->str.cstr = (char*)"\n\n\n\n";
|
||||
buffer->str.cstr = (char *)"\n\n\n\n";
|
||||
assert_true(buffer_text_width(buffer) == 0);
|
||||
|
||||
buffer->str.cstr = (char*)"12345";
|
||||
buffer->str.cstr = (char *)"12345";
|
||||
assert_true(buffer_text_width(buffer) == 5);
|
||||
|
||||
buffer->str.cstr = (char*)"12345\n1234567";
|
||||
buffer->str.cstr = (char *)"12345\n1234567";
|
||||
assert_true(buffer_text_width(buffer) == 7);
|
||||
|
||||
buffer->str.cstr = (char*)"12345\n1234567\n";
|
||||
buffer->str.cstr = (char *)"12345\n1234567\n";
|
||||
assert_true(buffer_text_width(buffer) == 7);
|
||||
|
||||
buffer->str.cstr = (char*)"12345\n1234567\n123";
|
||||
buffer->str.cstr = (char *)"12345\n1234567\n123";
|
||||
assert_true(buffer_text_width(buffer) == 7);
|
||||
|
||||
|
||||
@@ -253,25 +253,25 @@ void test_buffer_text_height(void)
|
||||
buffer->type = CharBuf;
|
||||
char *old_value = buffer->str.cstr;
|
||||
|
||||
buffer->str.cstr = (char*)"";
|
||||
buffer->str.cstr = (char *)"";
|
||||
assert_true(buffer_text_height(buffer) == 0);
|
||||
|
||||
buffer->str.cstr = (char*)"\n";
|
||||
buffer->str.cstr = (char *)"\n";
|
||||
assert_true(buffer_text_height(buffer) == 2);
|
||||
|
||||
buffer->str.cstr = (char*)"\n\n";
|
||||
buffer->str.cstr = (char *)"\n\n";
|
||||
assert_true(buffer_text_height(buffer) == 3);
|
||||
|
||||
buffer->str.cstr = (char*)"\n\n\n\n";
|
||||
buffer->str.cstr = (char *)"\n\n\n\n";
|
||||
assert_true(buffer_text_height(buffer) == 5);
|
||||
|
||||
buffer->str.cstr = (char*)"12345";
|
||||
buffer->str.cstr = (char *)"12345";
|
||||
assert_true(buffer_text_height(buffer) == 1);
|
||||
|
||||
buffer->str.cstr = (char*)"\n12345";
|
||||
buffer->str.cstr = (char *)"\n12345";
|
||||
assert_true(buffer_text_height(buffer) == 2);
|
||||
|
||||
buffer->str.cstr = (char*)"\n12345\n\n2";
|
||||
buffer->str.cstr = (char *)"\n12345\n\n2";
|
||||
assert_true(buffer_text_height(buffer) == 4);
|
||||
|
||||
|
||||
|
@@ -7,60 +7,60 @@ void test_table_basic(void)
|
||||
|
||||
WHEN("All columns are equal and not empty") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n";
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("All columns are equal and not empty (wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+---+---+-----+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+-----+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+-----+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+-----+----------+\n";
|
||||
L"+---+---+-----+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+-----+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+-----+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+-----+----------+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -69,180 +69,180 @@ void test_table_basic(void)
|
||||
|
||||
WHEN("All columns are not equal and not empty") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "c", "234", "3.140000", "3") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "234", "3.140000", "3", "c") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "3", "c", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "c", "234", "3.140000", "3") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "234", "3.140000", "3", "c") == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("All columns are not equal and not empty (wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"3") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"234", L"3.140000", L"3", L"c") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"3", L"c", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"3") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"234", L"3.140000", L"3", L"c") == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | 3 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | 3 | c |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | 3 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | 3 | c |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("All columns are not equal and some cells are empty") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWRITE_LN(table, "", "", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "c", "234", "3.140000", "") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "234", "3.140000", "", "") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "", "", "234", "3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "c", "234", "3.140000", "") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "234", "3.140000", "", "") == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| | | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | | |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| | | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | | |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("All columns are not equal and some cells are empty (wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWWRITE_LN(table, L"", L"", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"234", L"3.140000", L"", L"") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"234", L"3.140000") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"c", L"234", L"3.140000", L"") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"234", L"3.140000", L"", L"") == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("All cells are empty") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||
assert_true( FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||
assert_true(FT_NWRITE_LN(table, "", "", "", "") == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+--+--+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+--+--+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+--+--+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+--+--+--+--+\n";
|
||||
"+--+--+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+--+--+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+--+--+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+--+--+--+--+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
WHEN("All cells are empty (wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||
assert_true( FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"", L"", L"", L"") == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+--+--+--+--+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+--+--+--+--+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+--+--+--+--+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+--+--+--+--+\n";
|
||||
L"+--+--+--+--+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+--+--+--+--+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+--+--+--+--+\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"| | | | |\n"
|
||||
L"+--+--+--+--+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -257,30 +257,30 @@ void test_wcs_table_boundaries(void)
|
||||
|
||||
WHEN("All columns are not equal and not empty (wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
assert_true( FT_NWWRITE_LN(table, L"3", L"12345\x8888\x8888", L"c") == FT_SUCCESS); /* \x8888,\x8888 - occupy 2 columns each */
|
||||
assert_true( FT_NWWRITE_LN(table, L"c", L"12345678\x500", L"c") == FT_SUCCESS); /* \x500 - occupies 1 column */
|
||||
assert_true( FT_NWWRITE_LN(table, L"234", L"123456789", L"c") == FT_SUCCESS);
|
||||
assert_true(FT_NWWRITE_LN(table, L"3", L"12345\x8888\x8888", L"c") == FT_SUCCESS); /* \x8888,\x8888 - occupy 2 columns each */
|
||||
assert_true(FT_NWWRITE_LN(table, L"c", L"12345678\x500", L"c") == FT_SUCCESS); /* \x500 - occupies 1 column */
|
||||
assert_true(FT_NWWRITE_LN(table, L"234", L"123456789", L"c") == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+-----+-----------+---+\n"
|
||||
L"| | | |\n"
|
||||
L"| 3 | 12345\x8888\x8888 | c |\n"
|
||||
L"| | | |\n"
|
||||
L"+-----+-----------+---+\n"
|
||||
L"| | | |\n"
|
||||
L"| c | 12345678\x500 | c |\n"
|
||||
L"| | | |\n"
|
||||
L"+-----+-----------+---+\n"
|
||||
L"| | | |\n"
|
||||
L"| 234 | 123456789 | c |\n"
|
||||
L"| | | |\n"
|
||||
L"+-----+-----------+---+\n";
|
||||
L"+-----+-----------+---+\n"
|
||||
L"| | | |\n"
|
||||
L"| 3 | 12345\x8888\x8888 | c |\n"
|
||||
L"| | | |\n"
|
||||
L"+-----+-----------+---+\n"
|
||||
L"| | | |\n"
|
||||
L"| c | 12345678\x500 | c |\n"
|
||||
L"| | | |\n"
|
||||
L"+-----+-----------+---+\n"
|
||||
L"| | | |\n"
|
||||
L"| 234 | 123456789 | c |\n"
|
||||
L"| | | |\n"
|
||||
L"+-----+-----------+---+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -293,8 +293,8 @@ void test_table_write(void)
|
||||
|
||||
SCENARIO("Test row_write functions") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
const char *row_0[4] = {"3", "c", "234", "3.140000"};
|
||||
@@ -305,29 +305,29 @@ void test_table_write(void)
|
||||
assert_true(ft_row_write_ln(table, 4, row_2) == FT_SUCCESS);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal( table_str, table_str_etalon );
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
SCENARIO("Test row_write functions(wide strings)") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
const wchar_t *row_0[4] = {L"3", L"c", L"234", L"3.140000"};
|
||||
@@ -338,56 +338,56 @@ void test_table_write(void)
|
||||
assert_true(ft_row_wwrite_ln(table, 4, row_2) == FT_SUCCESS);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | 3 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | 3 | c |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
assert_wcs_equal( table_str, table_str_etalon );
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | c | 234 | 3.140000 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| c | 234 | 3.140000 | 3 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 234 | 3.140000 | 3 | c |\n"
|
||||
L"| | | | |\n"
|
||||
L"+-----+----------+----------+----------+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
|
||||
SCENARIO("Test printf functions") {
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
int n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
n = ft_printf_ln(table, "%c|%s|%f|%d", 'c', "234", 3.14, 3);
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
n = ft_printf_ln(table, "%s|%f|%d|%c", "234", 3.14, 3, 'c');
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal( table_str, table_str_etalon );
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| c | 234 | 3.140000 | 3 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 234 | 3.140000 | 3 | c |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+----------+----------+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
|
@@ -34,21 +34,21 @@ void test_table_border_style(void)
|
||||
|
||||
table = create_test_int_table(0);
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+***+***+****+****+\n"
|
||||
"v v v v v\n"
|
||||
"v 3 v 4 v 55 v 67 v\n"
|
||||
"v v v v v\n"
|
||||
"+***#***#****#****+\n"
|
||||
"= = = = =\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"= = = = =\n"
|
||||
"+|||#|||#||||#||||+\n"
|
||||
"= = = = =\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"= = = = =\n"
|
||||
"+|||+|||+||||+||||+\n";
|
||||
"+***+***+****+****+\n"
|
||||
"v v v v v\n"
|
||||
"v 3 v 4 v 55 v 67 v\n"
|
||||
"v v v v v\n"
|
||||
"+***#***#****#****+\n"
|
||||
"= = = = =\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"= = = = =\n"
|
||||
"+|||#|||#||||#||||+\n"
|
||||
"= = = = =\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"= = = = =\n"
|
||||
"+|||+|||+||||+||||+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
|
||||
@@ -79,14 +79,14 @@ void test_table_border_style(void)
|
||||
|
||||
table = create_test_int_table(0);
|
||||
table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
table_str_etalon =
|
||||
"+***+***+****+****+\n"
|
||||
"v 3 v 4 v 55 v 67 v\n"
|
||||
"+***#***#****#****+\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"+|||+|||+||||+||||+\n";
|
||||
"+***+***+****+****+\n"
|
||||
"v 3 v 4 v 55 v 67 v\n"
|
||||
"+***#***#****#****+\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"= 3 = 4 = 55 = 67 =\n"
|
||||
"+|||+|||+||||+||||+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -99,28 +99,28 @@ void test_table_border_style(void)
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
||||
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+===+===+====+====+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+===+===+====+====+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@
|
||||
void test_table_sizes(void)
|
||||
{
|
||||
FTABLE *table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
|
||||
size_t rows = 0;
|
||||
@@ -15,36 +15,36 @@ void test_table_sizes(void)
|
||||
|
||||
WHEN("Table is empty") {
|
||||
status = get_table_sizes(table, &rows, &cols);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( rows == 0 );
|
||||
assert_true( cols == 0 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(rows == 0);
|
||||
assert_true(cols == 0);
|
||||
}
|
||||
|
||||
WHEN("Insert one cell") {
|
||||
int n = ft_printf_ln(table, "%c", 'c');
|
||||
assert_true( n == 1 );
|
||||
assert_true(n == 1);
|
||||
status = get_table_sizes(table, &rows, &cols);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( rows == 1 );
|
||||
assert_true( cols == 1 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(rows == 1);
|
||||
assert_true(cols == 1);
|
||||
}
|
||||
|
||||
WHEN("Insert two cells in the next row") {
|
||||
int n = ft_printf_ln(table, "%c|%c", 'c', 'd');
|
||||
assert_true( n == 2 );
|
||||
assert_true(n == 2);
|
||||
status = get_table_sizes(table, &rows, &cols);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( rows == 2 );
|
||||
assert_true( cols == 2 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(rows == 2);
|
||||
assert_true(cols == 2);
|
||||
}
|
||||
|
||||
WHEN("Insert five cells in the next row") {
|
||||
int n = ft_printf_ln(table, "%d|%d|%d|%d|%d", 1, 2, 3, 4, 5);
|
||||
assert_true( n == 5 );
|
||||
assert_true(n == 5);
|
||||
status = get_table_sizes(table, &rows, &cols);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( rows == 3 );
|
||||
assert_true( cols == 5 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(rows == 3);
|
||||
assert_true(cols == 5);
|
||||
}
|
||||
|
||||
ft_destroy_table(table);
|
||||
@@ -54,8 +54,8 @@ void test_table_sizes(void)
|
||||
void test_table_geometry(void)
|
||||
{
|
||||
FTABLE *table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(table != NULL);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
|
||||
size_t height = 0;
|
||||
size_t width = 0;
|
||||
@@ -63,27 +63,27 @@ void test_table_geometry(void)
|
||||
|
||||
WHEN("Table is empty") {
|
||||
status = table_geometry(table, &height, &width);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( height == 2 );
|
||||
assert_true( width == 3 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(height == 2);
|
||||
assert_true(width == 3);
|
||||
}
|
||||
|
||||
WHEN("Table has one cell") {
|
||||
int n = ft_printf_ln(table, "%c", 'c');
|
||||
assert_true( n == 1 );
|
||||
assert_true(n == 1);
|
||||
status = table_geometry(table, &height, &width);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( height == 5 );
|
||||
assert_true( width == 6 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(height == 5);
|
||||
assert_true(width == 6);
|
||||
}
|
||||
|
||||
WHEN("Inserting 3 cells in the next row") {
|
||||
int n = ft_printf_ln(table, "%c|%s|%c", 'c', "as", 'e');
|
||||
assert_true( n == 3 );
|
||||
assert_true(n == 3);
|
||||
status = table_geometry(table, &height, &width);
|
||||
assert_true( IS_SUCCESS(status) );
|
||||
assert_true( height == 9 );
|
||||
assert_true( width == 15 );
|
||||
assert_true(IS_SUCCESS(status));
|
||||
assert_true(height == 9);
|
||||
assert_true(width == 15);
|
||||
}
|
||||
|
||||
ft_destroy_table(table);
|
||||
|
@@ -19,21 +19,21 @@ void test_table_tbl_options(void)
|
||||
table = create_test_int_table(0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
|
||||
/* Now set table options */
|
||||
@@ -42,28 +42,28 @@ void test_table_tbl_options(void)
|
||||
ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1);
|
||||
ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2);
|
||||
table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
table_str_etalon =
|
||||
" \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" \n";
|
||||
" \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" | | | | | \n"
|
||||
" | 3 | 4 | 55 | 67 | \n"
|
||||
" | | | | | \n"
|
||||
" +---+---+----+----+ \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" \n"
|
||||
" \n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
|
||||
ft_destroy_table(table);
|
||||
@@ -76,21 +76,21 @@ void test_table_tbl_options(void)
|
||||
table = create_test_int_wtable(0);
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L"+---+---+----+----+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | 4 | 55 | 67 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+----+----+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | 4 | 55 | 67 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+----+----+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | 4 | 55 | 67 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+----+----+\n";
|
||||
L"+---+---+----+----+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | 4 | 55 | 67 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+----+----+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | 4 | 55 | 67 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+----+----+\n"
|
||||
L"| | | | |\n"
|
||||
L"| 3 | 4 | 55 | 67 |\n"
|
||||
L"| | | | |\n"
|
||||
L"+---+---+----+----+\n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
|
||||
/* Now set table options */
|
||||
@@ -99,28 +99,28 @@ void test_table_tbl_options(void)
|
||||
ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1);
|
||||
ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2);
|
||||
table_str = ft_to_wstring(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
table_str_etalon =
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" | | | | | \n"
|
||||
L" | 3 | 4 | 55 | 67 | \n"
|
||||
L" | | | | | \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" | | | | | \n"
|
||||
L" | 3 | 4 | 55 | 67 | \n"
|
||||
L" | | | | | \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" | | | | | \n"
|
||||
L" | 3 | 4 | 55 | 67 | \n"
|
||||
L" | | | | | \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" \n";
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" | | | | | \n"
|
||||
L" | 3 | 4 | 55 | 67 | \n"
|
||||
L" | | | | | \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" | | | | | \n"
|
||||
L" | 3 | 4 | 55 | 67 | \n"
|
||||
L" | | | | | \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" | | | | | \n"
|
||||
L" | 3 | 4 | 55 | 67 | \n"
|
||||
L" | | | | | \n"
|
||||
L" +---+---+----+----+ \n"
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" \n"
|
||||
L" \n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
|
||||
ft_destroy_table(table);
|
||||
@@ -145,21 +145,21 @@ void test_table_cell_options(void)
|
||||
table = create_test_int_table(0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -176,15 +176,15 @@ void test_table_cell_options(void)
|
||||
table = create_test_int_table(0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"+---+---+----+----+\n";
|
||||
"+---+---+----+----+\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -199,21 +199,21 @@ void test_table_cell_options(void)
|
||||
table = create_test_int_table(0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n";
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -228,15 +228,15 @@ void test_table_cell_options(void)
|
||||
table = create_test_int_table(0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n";
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -251,27 +251,27 @@ void test_table_cell_options(void)
|
||||
|
||||
table = create_test_int_table(0);
|
||||
int n = ft_printf_ln(table, "|||");
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n"
|
||||
"| | | | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+----+----+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -288,15 +288,15 @@ void test_table_cell_options(void)
|
||||
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n";
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n"
|
||||
"|3|4|55|67|\n"
|
||||
"+-+-+--+--+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
|
||||
|
||||
@@ -307,21 +307,21 @@ void test_table_cell_options(void)
|
||||
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_EMPTY_STR_HEIGHT, 0);
|
||||
|
||||
table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
table_str_etalon =
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n";
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n"
|
||||
"| | | | |\n"
|
||||
"|3|4|55|67|\n"
|
||||
"| | | | |\n"
|
||||
"+-+-+--+--+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -342,25 +342,25 @@ void test_table_cell_options(void)
|
||||
|
||||
status |= ft_set_cell_option(table, 2, 3, FT_COPT_MIN_WIDTH, 6);
|
||||
status |= ft_set_cell_option(table, 2, 3, FT_COPT_TEXT_ALIGN, LeftAligned);
|
||||
assert_true( status == FT_SUCCESS);
|
||||
assert_true(status == FT_SUCCESS);
|
||||
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n";
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+-------+--------+------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -372,26 +372,26 @@ void test_table_cell_options(void)
|
||||
int status = FT_SUCCESS;
|
||||
status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 5);
|
||||
status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, CenterAligned);
|
||||
assert_true( status == FT_SUCCESS);
|
||||
assert_true(status == FT_SUCCESS);
|
||||
|
||||
table = create_test_int_table(0);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+-----+-----+-----+-----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+-----+-----+-----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+-----+-----+-----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+-----+-----+-----+\n";
|
||||
"+-----+-----+-----+-----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+-----+-----+-----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+-----+-----+-----+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | 4 | 55 | 67 |\n"
|
||||
"| | | | |\n"
|
||||
"+-----+-----+-----+-----+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
@@ -404,29 +404,29 @@ void test_table_cell_options(void)
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
int n = ft_printf_ln(table, "%d|%c|%s|%f", 4, 'c', "234", 3.14);
|
||||
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
n = FT_NWRITE_LN(table, "5", "c", "234\n12", "3.140000");
|
||||
assert_true( n == FT_SUCCESS );
|
||||
assert_true(n == FT_SUCCESS);
|
||||
n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
|
||||
assert_true( n == 4 );
|
||||
assert_true(n == 4);
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true( table_str != NULL );
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 4 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 5 | c | 234 | 3.140000 |\n"
|
||||
"| | | 12 | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n";
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 4 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 5 | c | 234 | 3.140000 |\n"
|
||||
"| | | 12 | |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n"
|
||||
"| | | | |\n"
|
||||
"| 3 | c | 234 | 3.140000 |\n"
|
||||
"| | | | |\n"
|
||||
"+---+---+-----+----------+\n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ int set_test_options_for_table(FTABLE *table)
|
||||
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 1);
|
||||
status |= ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_EMPTY_STR_HEIGHT, 1);
|
||||
|
||||
assert_true( status == FT_SUCCESS );
|
||||
assert_true(status == FT_SUCCESS);
|
||||
|
||||
|
||||
struct ft_border_style brdr_style;
|
||||
@@ -46,7 +46,7 @@ int set_test_options_as_default()
|
||||
status |= ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1);
|
||||
status |= ft_set_default_cell_option(FT_COPT_EMPTY_STR_HEIGHT, 1);
|
||||
|
||||
assert_true( status == FT_SUCCESS );
|
||||
assert_true(status == FT_SUCCESS);
|
||||
|
||||
|
||||
struct ft_border_style brdr_style;
|
||||
@@ -76,12 +76,12 @@ FTABLE *create_test_int_table(int set_test_opts)
|
||||
FTABLE *table = NULL;
|
||||
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true(table != NULL);
|
||||
if (set_test_opts) {
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
}
|
||||
|
||||
assert_true (table != NULL);
|
||||
assert_true(table != NULL);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
||||
@@ -106,12 +106,12 @@ FTABLE *create_test_int_wtable(int set_test_opts)
|
||||
FTABLE *table = NULL;
|
||||
|
||||
table = ft_create_table();
|
||||
assert_true( table != NULL );
|
||||
assert_true(table != NULL);
|
||||
if (set_test_opts) {
|
||||
assert_true( set_test_options_for_table(table) == FT_SUCCESS);
|
||||
assert_true(set_test_options_for_table(table) == FT_SUCCESS);
|
||||
}
|
||||
|
||||
assert_true (table != NULL);
|
||||
assert_true(table != NULL);
|
||||
|
||||
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, Header);
|
||||
// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67);
|
||||
|
@@ -12,9 +12,9 @@ void test_vector_basic(void)
|
||||
const size_t init_capacity = 10;
|
||||
vector_t *vector = create_vector(sizeof(item_t), init_capacity);
|
||||
|
||||
assert_true( vector != NULL );
|
||||
assert_true( vector_size(vector) == 0 );
|
||||
assert_true( vector_capacity(vector) == init_capacity );
|
||||
assert_true(vector != NULL);
|
||||
assert_true(vector_size(vector) == 0);
|
||||
assert_true(vector_capacity(vector) == init_capacity);
|
||||
|
||||
WHEN("Pushing less items than initial capacity") {
|
||||
for (i = 0; i < init_capacity; ++i) {
|
||||
@@ -23,8 +23,8 @@ void test_vector_basic(void)
|
||||
}
|
||||
|
||||
THEN("Then capacity is not changed") {
|
||||
assert_true( vector_size(vector) == init_capacity );
|
||||
assert_true( vector_capacity(vector) == init_capacity );
|
||||
assert_true(vector_size(vector) == init_capacity);
|
||||
assert_true(vector_capacity(vector) == init_capacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ void test_vector_basic(void)
|
||||
vector_clear(vector);
|
||||
|
||||
THEN("Then size == 0") {
|
||||
assert_true( vector_size(vector) == 0 );
|
||||
assert_true(vector_size(vector) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,37 +43,37 @@ void test_vector_basic(void)
|
||||
}
|
||||
|
||||
THEN("Then capacity is increased") {
|
||||
assert_true( vector_size(vector) == 2 * init_capacity );
|
||||
assert_true( vector_capacity(vector) > init_capacity );
|
||||
assert_true(vector_size(vector) == 2 * init_capacity);
|
||||
assert_true(vector_capacity(vector) > init_capacity);
|
||||
}
|
||||
|
||||
WHEN("Checking indexes of items") {
|
||||
item_t item = 6;
|
||||
assert_true( vector_index_of(vector, &item) == 3 );
|
||||
assert_true(vector_index_of(vector, &item) == 3);
|
||||
item = 14;
|
||||
assert_true( vector_index_of(vector, &item) == 7 );
|
||||
assert_true(vector_index_of(vector, &item) == 7);
|
||||
item = 25;
|
||||
assert_true( vector_index_of(vector, &item) == INVALID_VEC_INDEX );
|
||||
assert_true(vector_index_of(vector, &item) == INVALID_VEC_INDEX);
|
||||
}
|
||||
|
||||
WHEN("Checking access to items") {
|
||||
assert_true( *(item_t *)vector_at(vector, 0) == 0 );
|
||||
assert_true( *(item_t *)vector_at(vector, 10) == 20 );
|
||||
assert_true( (item_t *)vector_at(vector, 20) == NULL );
|
||||
assert_true(*(item_t *)vector_at(vector, 0) == 0);
|
||||
assert_true(*(item_t *)vector_at(vector, 10) == 20);
|
||||
assert_true((item_t *)vector_at(vector, 20) == NULL);
|
||||
}
|
||||
|
||||
WHEN("Erasing items") {
|
||||
assert_true( vector_erase(vector, 20) != FT_SUCCESS );
|
||||
assert_true(vector_erase(vector, 20) != FT_SUCCESS);
|
||||
|
||||
assert_true( vector_erase(vector, 0) == FT_SUCCESS );
|
||||
assert_true( vector_erase(vector, 10) == FT_SUCCESS );
|
||||
assert_true(vector_erase(vector, 0) == FT_SUCCESS);
|
||||
assert_true(vector_erase(vector, 10) == FT_SUCCESS);
|
||||
|
||||
item_t first_item = *(item_t*)vector_at(vector, 0);
|
||||
assert_true( first_item == 2 );
|
||||
item_t first_item = *(item_t *)vector_at(vector, 0);
|
||||
assert_true(first_item == 2);
|
||||
item_t item = 6;
|
||||
assert_true( vector_index_of(vector, &item) == 2 );
|
||||
assert_true(vector_index_of(vector, &item) == 2);
|
||||
item = 26;
|
||||
assert_true( vector_index_of(vector, &item) == 11 );
|
||||
assert_true(vector_index_of(vector, &item) == 11);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +81,9 @@ void test_vector_basic(void)
|
||||
vector_clear(vector);
|
||||
|
||||
THEN("Then size == 0") {
|
||||
assert_true( vector_size(vector) == 0 );
|
||||
assert_true(vector_size(vector) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
destroy_vector( vector );
|
||||
destroy_vector(vector);
|
||||
}
|
||||
|
@@ -50,10 +50,11 @@ struct test_case
|
||||
#define assert_wcs_equal(str1, str2) \
|
||||
if (wcscmp(str1, str2) != 0) \
|
||||
{ \
|
||||
fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __FUNCTION__); \
|
||||
setlocale(LC_CTYPE, ""); \
|
||||
fwprintf(stdout, L"%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __FUNCTION__); \
|
||||
fwprintf(stdout, L"Left string:\n%ls\n", str1); \
|
||||
fwprintf(stdout, L"Right string:\n%ls\n", str2); \
|
||||
fflush(stdout); \
|
||||
exit(EXIT_FAILURE); \
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user