[A] Added test for superscripts and subscripts

This commit is contained in:
seleznevae 2019-09-17 21:07:29 +03:00
parent 6c62660dfe
commit e4adeed195
2 changed files with 44 additions and 0 deletions

View File

@ -36,6 +36,24 @@ void base_example(void)
ft_destroy_table(table); ft_destroy_table(table);
} }
void math_example(void)
{
#ifdef FT_HAVE_UTF8
ft_table_t *table = ft_create_table();
ft_set_border_style(table, FT_DOUBLE2_STYLE);
ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER);
ft_u8write_ln(table, "N", "Figure", "Volume, cm³", "Accuracy");
ft_u8write_ln(table, "1", "", "3.145", "±0.3");
ft_u8write_ln(table, "2", "", "4.95", "±0.25");
printf("%s\n", (const char *)ft_to_u8string(table));
ft_destroy_table(table);
#endif /* FT_HAVE_UTF8 */
}
void complex_layout_example(void) void complex_layout_example(void)
{ {
ft_table_t *table = ft_create_table(); ft_table_t *table = ft_create_table();
@ -266,6 +284,7 @@ int main(void)
different_cell_properties_example(); different_cell_properties_example();
fill_table_with_data_example(); fill_table_with_data_example();
complex_layout_example(); complex_layout_example();
math_example();
custom_border_style_example(); custom_border_style_example();
colorfull_table(); colorfull_table();

View File

@ -163,6 +163,31 @@ void test_bug_fixes(void)
ft_destroy_table(table); ft_destroy_table(table);
} }
#endif /* FT_HAVE_UTF8 */ #endif /* FT_HAVE_UTF8 */
#ifdef FT_HAVE_UTF8
SCENARIO("Issue 16 - https://github.com/seleznevae/libfort/issues/16") {
ft_table_t *table = ft_create_table();
ft_set_border_style(table, FT_DOUBLE2_STYLE);
ft_set_cell_prop(table, 0, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE, FT_ROW_HEADER);
ft_u8write_ln(table, "cm³", "cm²");
ft_u8write_ln(table, "123", "123");
ft_u8write_ln(table, "yxₙ", "yx₌");
const char *table_str = ft_to_u8string(table);
assert_true(table_str != NULL);
const char *table_str_etalon =
"╔═════╤═════╗\n"
"║ cm³ │ cm² ║\n"
"╠═════╪═════╣\n"
"║ 123 │ 123 ║\n"
"╟─────┼─────╢\n"
"║ yxₙ │ yx₌ ║\n"
"╚═════╧═════╝\n";
assert_str_equal(table_str, table_str_etalon);
ft_destroy_table(table);
}
#endif /* FT_HAVE_UTF8 */
} }
void test_table_basic(void) void test_table_basic(void)