Skip to content

Commit

Permalink
[A] Added border tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seleznevae committed May 6, 2018
1 parent a87ad88 commit 1c86313
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 8 deletions.
12 changes: 8 additions & 4 deletions lib/fort.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,11 +2071,12 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
const char *ft_to_string(const ft_table_t *table)
{
typedef char char_type;
const char_type *empty_string = "";
// const char_type *empty_string = "";
const enum str_buf_type buf_type = CharBuf;
const char *space_char = " ";
const char *new_line_char = "\n";
#define cur_F_STRDUP F_STRDUP
#define EMPTY_STRING ""
int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row;
int (*print_row_separator_)(char *, size_t,
const size_t *, size_t,
Expand Down Expand Up @@ -2118,7 +2119,7 @@ const char *ft_to_string(const ft_table_t *table)
return NULL;

if (rows == 0)
return cur_F_STRDUP(empty_string);
return EMPTY_STRING;

int written = 0;
int tmp = 0;
Expand Down Expand Up @@ -2166,6 +2167,7 @@ const char *ft_to_string(const ft_table_t *table)
// F_FREE(buffer);
return NULL;
#undef cur_F_STRDUP
#undef EMPTY_STRING
}


Expand All @@ -2174,11 +2176,12 @@ const char *ft_to_string(const ft_table_t *table)
const wchar_t *ft_to_wstring(const ft_table_t *table)
{
typedef wchar_t char_type;
const char_type *empty_string = L"";
// const char_type *empty_string = L"";
const enum str_buf_type buf_type = WCharBuf;
const char *space_char = " ";
const char *new_line_char = "\n";
#define cur_F_STRDUP F_WCSDUP
#define EMPTY_STRING L""
int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row;
int (*print_row_separator_)(wchar_t *, size_t,
const size_t *, size_t,
Expand Down Expand Up @@ -2221,7 +2224,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows);

if (rows == 0)
return cur_F_STRDUP(empty_string);
return EMPTY_STRING;

if (FT_IS_ERROR(status))
return NULL;
Expand Down Expand Up @@ -2271,6 +2274,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
// F_FREE(buffer);
return NULL;
#undef cur_F_STRDUP
#undef EMPTY_STRING
}

#endif
Expand Down
12 changes: 8 additions & 4 deletions src/fort_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,12 @@ int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_
const char *ft_to_string(const ft_table_t *table)
{
typedef char char_type;
const char_type *empty_string = "";
// const char_type *empty_string = "";
const enum str_buf_type buf_type = CharBuf;
const char *space_char = " ";
const char *new_line_char = "\n";
#define cur_F_STRDUP F_STRDUP
#define EMPTY_STRING ""
int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row;
int (*print_row_separator_)(char *, size_t,
const size_t *, size_t,
Expand Down Expand Up @@ -582,7 +583,7 @@ const char *ft_to_string(const ft_table_t *table)
return NULL;

if (rows == 0)
return cur_F_STRDUP(empty_string);
return EMPTY_STRING;

int written = 0;
int tmp = 0;
Expand Down Expand Up @@ -630,6 +631,7 @@ const char *ft_to_string(const ft_table_t *table)
// F_FREE(buffer);
return NULL;
#undef cur_F_STRDUP
#undef EMPTY_STRING
}


Expand All @@ -638,11 +640,12 @@ const char *ft_to_string(const ft_table_t *table)
const wchar_t *ft_to_wstring(const ft_table_t *table)
{
typedef wchar_t char_type;
const char_type *empty_string = L"";
// const char_type *empty_string = L"";
const enum str_buf_type buf_type = WCharBuf;
const char *space_char = " ";
const char *new_line_char = "\n";
#define cur_F_STRDUP F_WCSDUP
#define EMPTY_STRING L""
int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row;
int (*print_row_separator_)(wchar_t *, size_t,
const size_t *, size_t,
Expand Down Expand Up @@ -685,7 +688,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows);

if (rows == 0)
return cur_F_STRDUP(empty_string);
return EMPTY_STRING;

if (FT_IS_ERROR(status))
return NULL;
Expand Down Expand Up @@ -735,6 +738,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
// F_FREE(buffer);
return NULL;
#undef cur_F_STRDUP
#undef EMPTY_STRING
}

#endif
Expand Down

0 comments on commit 1c86313

Please sign in to comment.