Merge pull request #12 from seleznevae/issue#11
[F] Fix incorrect border style for the last line in the table (Issue#11)
This commit is contained in:
commit
4d0cd8501b
@ -3,6 +3,7 @@
|
||||
### Bug fixes
|
||||
|
||||
- Changed specific style reset tags to universal reset style tag.
|
||||
- Fix incorrect border style for the last line in the table.
|
||||
|
||||
## v0.1.5
|
||||
|
||||
|
@ -1817,6 +1817,7 @@ const char *ft_to_string(const ft_table_t *table)
|
||||
}
|
||||
cur_row = NULL;
|
||||
cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL;
|
||||
context.row = i;
|
||||
CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context));
|
||||
|
||||
/* Print bottom margin */
|
||||
@ -1920,6 +1921,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
|
||||
}
|
||||
cur_row = NULL;
|
||||
cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL;
|
||||
context.row = i;
|
||||
CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context));
|
||||
|
||||
/* Print bottom margin */
|
||||
|
@ -656,6 +656,7 @@ const char *ft_to_string(const ft_table_t *table)
|
||||
}
|
||||
cur_row = NULL;
|
||||
cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL;
|
||||
context.row = i;
|
||||
CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context));
|
||||
|
||||
/* Print bottom margin */
|
||||
@ -759,6 +760,7 @@ const wchar_t *ft_to_wstring(const ft_table_t *table)
|
||||
}
|
||||
cur_row = NULL;
|
||||
cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL;
|
||||
context.row = i;
|
||||
CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context));
|
||||
|
||||
/* Print bottom margin */
|
||||
|
@ -3,12 +3,11 @@
|
||||
#include <wchar.h>
|
||||
#include "fort.h"
|
||||
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
void test_bug_fixes(void)
|
||||
{
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
SCENARIO("Bug 1") {
|
||||
ft_table_t *table = ft_create_table();
|
||||
|
||||
ft_table_t *table_tmp_1 = ft_create_table();
|
||||
|
||||
// ft_set_border_style(table_tmp_1, FT_EMPTY_STYLE);
|
||||
@ -23,6 +22,8 @@ void test_bug_fixes(void)
|
||||
ft_destroy_table(table_tmp_1);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
SCENARIO("Bug 2") {
|
||||
ft_table_t *table = ft_create_table();
|
||||
@ -84,8 +85,49 @@ void test_bug_fixes(void)
|
||||
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
SCENARIO("Issue 11 - https://github.com/seleznevae/libfort/issues/11") {
|
||||
ft_table_t *table = ft_create_table();
|
||||
ft_set_border_style(table, FT_PLAIN_STYLE);
|
||||
|
||||
ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER);
|
||||
ft_write_ln(table, "1", "2");
|
||||
ft_write_ln(table, "3", "4");
|
||||
|
||||
const char *table_str = ft_to_string(table);
|
||||
assert_true(table_str != NULL);
|
||||
const char *table_str_etalon =
|
||||
" ------- \n"
|
||||
" 1 2 \n"
|
||||
" ------- \n"
|
||||
" 3 4 \n"
|
||||
" \n";
|
||||
assert_str_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
SCENARIO("Issue 11 - https://github.com/seleznevae/libfort/issues/11 (wchar case)") {
|
||||
ft_table_t *table = ft_create_table();
|
||||
ft_set_border_style(table, FT_PLAIN_STYLE);
|
||||
|
||||
ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER);
|
||||
ft_wwrite_ln(table, L"1", L"2");
|
||||
ft_wwrite_ln(table, L"3", L"4");
|
||||
|
||||
const wchar_t *table_str = ft_to_wstring(table);
|
||||
assert_true(table_str != NULL);
|
||||
const wchar_t *table_str_etalon =
|
||||
L" ------- \n"
|
||||
L" 1 2 \n"
|
||||
L" ------- \n"
|
||||
L" 3 4 \n"
|
||||
L" \n";
|
||||
assert_wcs_equal(table_str, table_str_etalon);
|
||||
ft_destroy_table(table);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_table_basic(void)
|
||||
{
|
||||
|
@ -2,6 +2,32 @@
|
||||
#include "fort.hpp"
|
||||
#include "test_utils.hpp"
|
||||
|
||||
void test_cpp_bug_fixes(void)
|
||||
{
|
||||
SCENARIO("Issue 11 - https://github.com/seleznevae/libfort/issues/11") {
|
||||
fort::table table;
|
||||
table << fort::header
|
||||
<< "1" << "2" << fort::endr
|
||||
<< "3" << "4" << fort::endr;
|
||||
|
||||
table.set_border_style(FT_PLAIN_STYLE);
|
||||
table.set_cell_bottom_padding(0);
|
||||
table.set_cell_top_padding(0);
|
||||
table.set_cell_left_padding(1);
|
||||
table.set_cell_right_padding(1);
|
||||
table.set_cell_empty_str_height(0);
|
||||
|
||||
std::string table_str = table.to_string();
|
||||
std::string table_str_etalon =
|
||||
" ------- \n"
|
||||
" 1 2 \n"
|
||||
" ------- \n"
|
||||
" 3 4 \n"
|
||||
" \n";
|
||||
assert_string_equal(table_str, table_str_etalon);
|
||||
}
|
||||
}
|
||||
|
||||
void test_cpp_table_basic(void)
|
||||
{
|
||||
WHEN("All columns are equal and not empty.") {
|
||||
|
@ -3,9 +3,7 @@
|
||||
#include "fort.h"
|
||||
|
||||
/* Test cases */
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
void test_bug_fixes(void);
|
||||
#endif
|
||||
void test_vector_basic(void);
|
||||
void test_vector_stress(void);
|
||||
void test_string_buffer(void);
|
||||
@ -39,9 +37,7 @@ struct test_case wb_test_suite [] = {
|
||||
|
||||
|
||||
struct test_case bb_test_suite [] = {
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
{"test_bug_fixes", test_bug_fixes},
|
||||
#endif
|
||||
{"test_table_basic", test_table_basic},
|
||||
#ifdef FT_HAVE_WCHAR
|
||||
{"test_wcs_table_boundaries", test_wcs_table_boundaries},
|
||||
|
@ -8,7 +8,7 @@ void test_cpp_table_write(void);
|
||||
void test_cpp_table_tbl_properties(void);
|
||||
void test_cpp_table_cell_properties(void);
|
||||
void test_cpp_table_text_styles(void);
|
||||
|
||||
void test_cpp_bug_fixes(void);
|
||||
|
||||
|
||||
struct test_case bb_test_suite [] = {
|
||||
@ -17,6 +17,7 @@ struct test_case bb_test_suite [] = {
|
||||
{"test_cpp_table_tbl_properties", test_cpp_table_tbl_properties},
|
||||
{"test_cpp_table_cell_properties", test_cpp_table_cell_properties},
|
||||
{"test_cpp_table_text_styles", test_cpp_table_text_styles},
|
||||
{"test_cpp_bug_fixes", test_cpp_bug_fixes},
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user