[R] Refactoring of tests

This commit is contained in:
seleznevae
2018-03-19 23:07:18 +03:00
parent 2b5a2f3fa0
commit ef7640f5e6
17 changed files with 910 additions and 881 deletions

View File

@@ -196,7 +196,7 @@ int ft_write(FTABLE *FT_RESTRICT table, const char* FT_RESTRICT cell_content)
assert(table);
string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table);
if (str_buffer == NULL)
return F_ERROR;
return FT_ERROR;
int status = fill_buffer_from_string(str_buffer, cell_content);
if (IS_SUCCESS(status)) {
@@ -220,7 +220,7 @@ int ft_wwrite(FTABLE *FT_RESTRICT table, const wchar_t* FT_RESTRICT cell_content
assert(table);
string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table);
if (str_buffer == NULL)
return F_ERROR;
return FT_ERROR;
int status = fill_buffer_from_wstring(str_buffer, cell_content);
if (IS_SUCCESS(status)) {
@@ -345,7 +345,7 @@ int ft_row_write(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT
return status;
}
}
return F_SUCCESS;
return FT_SUCCESS;
}
int ft_row_write_ln(FTABLE *FT_RESTRICT table, size_t cols, const char* FT_RESTRICT cells[])
@@ -375,7 +375,7 @@ int ft_s_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const
if (i != rows - 1)
ft_ln(table);
}
return F_SUCCESS;
return FT_SUCCESS;
}
int ft_s_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* FT_RESTRICT table_cells[rows][cols])
@@ -402,7 +402,7 @@ int ft_table_write(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const ch
if (i != rows - 1)
ft_ln(table);
}
return F_SUCCESS;
return FT_SUCCESS;
}
int ft_table_write_ln(FTABLE *FT_RESTRICT table, size_t rows, size_t cols, const char* * FT_RESTRICT table_cells[rows])
@@ -649,7 +649,7 @@ int ft_add_separator(FTABLE *table)
while(vector_size(table->separators) <= table->cur_row) {
separator_t *sep_p = create_separator(F_FALSE);
if (sep_p == NULL)
return F_MEMORY_ERROR;
return FT_MEMORY_ERROR;
int status = vector_push(table->separators, &sep_p);
if (IS_ERROR(status))
return status;
@@ -662,8 +662,8 @@ int ft_add_separator(FTABLE *table)
(*sep_p)->enabled = F_TRUE;
if (*sep_p == NULL)
return F_ERROR;
return F_SUCCESS;
return FT_ERROR;
return FT_SUCCESS;
}
@@ -753,7 +753,7 @@ static void set_border_options_for_options(fort_table_options_t *options, struct
int ft_set_default_border_style(struct ft_border_style *style)
{
set_border_options_for_options(&g_table_options, style);
return F_SUCCESS;
return FT_SUCCESS;
}
int ft_set_border_style(FTABLE *table, struct ft_border_style *style)
@@ -762,10 +762,10 @@ int ft_set_border_style(FTABLE *table, struct ft_border_style *style)
if (table->options == NULL) {
table->options = create_table_options();
if (table->options == NULL)
return F_MEMORY_ERROR;
return FT_MEMORY_ERROR;
}
set_border_options_for_options(table->options, style);
return F_SUCCESS;
return FT_SUCCESS;
}
@@ -777,12 +777,12 @@ int ft_set_option(FTABLE *table, unsigned row, unsigned col, uint32_t option, in
if (table->options == NULL) {
table->options = create_table_options();
if (table->options == NULL)
return F_MEMORY_ERROR;
return FT_MEMORY_ERROR;
}
if (table->options->cell_options == NULL) {
table->options->cell_options = create_cell_opt_container();
if (table->options->cell_options == NULL) {
return F_ERROR;
return FT_ERROR;
}
}
return set_cell_option(table->options->cell_options, row, col, option, value);

View File

@@ -61,9 +61,9 @@ enum F_BOOL
* RETURN CODES
* ***************************************************************************/
typedef int fort_status_t;
#define F_SUCCESS 0
#define F_MEMORY_ERROR -1
#define F_ERROR -2
#define FT_SUCCESS 0
#define FT_MEMORY_ERROR -1
#define FT_ERROR -2
#define IS_SUCCESS(arg) ((arg) >= 0)
#define IS_ERROR(arg) ((arg) < 0)

View File

@@ -175,7 +175,7 @@ static fort_status_t set_cell_option_impl(fort_cell_options_t *opt, uint32_t opt
opt->row_type = (enum RowType)value;
}
return F_SUCCESS;
return FT_SUCCESS;
}
@@ -183,7 +183,7 @@ fort_status_t set_cell_option(fort_cell_opt_container_t *cont, unsigned row, uns
{
fort_cell_options_t* opt = get_cell_opt_and_create_if_not_exists(cont, row, col);
if (opt == NULL)
return F_ERROR;
return FT_ERROR;
return set_cell_option_impl(opt, option, value);
/*
@@ -194,7 +194,7 @@ fort_status_t set_cell_option(fort_cell_opt_container_t *cont, unsigned row, uns
opt->align = value;
}
return F_SUCCESS;
return FT_SUCCESS;
*/
}

View File

@@ -157,12 +157,12 @@ fort_status_t realloc_string_buffer_without_copy(string_buffer_t *buffer)
assert(buffer);
char *new_str = (char*)F_MALLOC(buffer->data_sz * 2);
if (new_str == NULL) {
return F_MEMORY_ERROR;
return FT_MEMORY_ERROR;
}
F_FREE(buffer->str.data);
buffer->str.data = new_str;
buffer->data_sz *= 2;
return F_SUCCESS;
return FT_SUCCESS;
}
fort_status_t fill_buffer_from_string(string_buffer_t *buffer, const char *str)
@@ -173,7 +173,7 @@ fort_status_t fill_buffer_from_string(string_buffer_t *buffer, const char *str)
size_t sz = strlen(str);
char * copy = F_STRDUP(str);
if (copy == NULL)
return F_MEMORY_ERROR;
return FT_MEMORY_ERROR;
while (sz >= string_buffer_capacity(buffer)) {
int status = realloc_string_buffer_without_copy(buffer);
@@ -185,7 +185,7 @@ fort_status_t fill_buffer_from_string(string_buffer_t *buffer, const char *str)
buffer->str.cstr = copy;
buffer->type = CharBuf;
return F_SUCCESS;
return FT_SUCCESS;
}
fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *str)
@@ -196,7 +196,7 @@ fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *s
size_t sz = wcslen(str);
wchar_t * copy = F_WCSDUP(str);
if (copy == NULL)
return F_MEMORY_ERROR;
return FT_MEMORY_ERROR;
while (sz >= string_buffer_capacity(buffer)) {
int status = realloc_string_buffer_without_copy(buffer);
@@ -208,7 +208,7 @@ fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *s
buffer->str.wstr = copy;
buffer->type = WCharBuf;
return F_SUCCESS;
return FT_SUCCESS;
}

View File

@@ -85,7 +85,7 @@ fort_status_t get_table_sizes(const FTABLE *table, size_t *rows, size_t *cols)
*cols = cols_in_row;
}
}
return F_SUCCESS;
return FT_SUCCESS;
}
fort_status_t table_rows_and_cols_geometry(const FTABLE *table,
@@ -93,7 +93,7 @@ fort_status_t table_rows_and_cols_geometry(const FTABLE *table,
size_t **row_height_arr_p, size_t *row_height_arr_sz)
{
if (table == NULL) {
return F_ERROR;
return FT_ERROR;
}
@@ -109,7 +109,7 @@ fort_status_t table_rows_and_cols_geometry(const FTABLE *table,
if (col_width_arr == NULL || row_height_arr == NULL) {
F_FREE(col_width_arr);
F_FREE(row_height_arr);
return F_ERROR;
return FT_ERROR;
}
context_t context;
@@ -146,7 +146,7 @@ fort_status_t table_rows_and_cols_geometry(const FTABLE *table,
*col_width_arr_sz = cols;
*row_height_arr_p = row_height_arr;
*row_height_arr_sz = rows;
return F_SUCCESS;
return FT_SUCCESS;
}
/*
@@ -155,7 +155,7 @@ fort_status_t table_rows_and_cols_geometry(const FTABLE *table,
fort_status_t table_geometry(const FTABLE *table, size_t *height, size_t *width)
{
if (table == NULL)
return F_ERROR;
return FT_ERROR;
*height = 0;
*width = 0;
@@ -181,7 +181,7 @@ fort_status_t table_geometry(const FTABLE *table, size_t *height, size_t *width)
}
F_FREE(col_width_arr);
F_FREE(row_height_arr);
return F_SUCCESS;
return FT_SUCCESS;
}

View File

@@ -116,7 +116,7 @@ int vector_push (vector_t* vector, const void* item)
if (vector->m_size == vector->m_capacity) {
if (vector_reallocate_(vector, vector->m_capacity * 2) == -1)
return F_ERROR;
return FT_ERROR;
vector->m_capacity = vector->m_capacity * 2;
}
@@ -125,7 +125,7 @@ int vector_push (vector_t* vector, const void* item)
++(vector->m_size);
return F_SUCCESS;
return FT_SUCCESS;
}
@@ -134,13 +134,13 @@ int vector_erase(vector_t *vector, size_t index)
assert(vector);
if (vector->m_size == 0 || index >= vector->m_size)
return F_ERROR;
return FT_ERROR;
memmove((char*)vector->m_data + vector->m_item_size * index,
(char*)vector->m_data + vector->m_item_size * (index + 1),
(vector->m_size - 1 - index) * vector->m_item_size);
vector->m_size--;
return F_SUCCESS;
return FT_SUCCESS;
}