2018-03-19 21:07:18 +01:00
|
|
|
//#define FT_EXTERN static
|
|
|
|
#include "tests.h"
|
|
|
|
#include "fort.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "options.h"
|
|
|
|
#include "vector.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
void test_table_tbl_options(void)
|
|
|
|
{
|
|
|
|
FTABLE *table = NULL;
|
|
|
|
|
|
|
|
WHEN("Test setting entire table options") {
|
|
|
|
set_test_options_as_default();
|
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-25 10:11:08 +02:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+---+----+----+\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";
|
2018-03-25 10:11:08 +02:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
|
|
|
|
|
|
|
/* Now set table options */
|
|
|
|
ft_set_tbl_option(table, FT_TOPT_TOP_MARGIN, 3);
|
|
|
|
ft_set_tbl_option(table, FT_TOPT_BOTTOM_MARGIN, 4);
|
2018-03-25 10:32:10 +02:00
|
|
|
ft_set_tbl_option(table, FT_TOPT_LEFT_MARGIN, 1);
|
|
|
|
ft_set_tbl_option(table, FT_TOPT_RIGHT_MARGIN, 2);
|
2018-03-25 10:11:08 +02:00
|
|
|
table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-25 10:11:08 +02:00
|
|
|
table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
" \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";
|
2018-03-25 10:11:08 +02:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
|
|
|
|
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
2018-03-25 10:32:10 +02:00
|
|
|
|
|
|
|
|
2018-04-16 20:01:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef FT_HAVE_WCHAR
|
2018-03-25 13:19:35 +02:00
|
|
|
WHEN("Test setting entire table options(wide strings case)") {
|
2018-03-25 10:32:10 +02:00
|
|
|
set_test_options_as_default();
|
|
|
|
|
|
|
|
table = create_test_int_wtable(0);
|
|
|
|
|
|
|
|
const wchar_t *table_str = ft_to_wstring(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-25 10:32:10 +02:00
|
|
|
const wchar_t *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
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";
|
2018-03-25 10:32:10 +02:00
|
|
|
assert_wcs_equal(table_str, table_str_etalon);
|
|
|
|
|
|
|
|
/* Now set table options */
|
|
|
|
ft_set_tbl_option(table, FT_TOPT_TOP_MARGIN, 3);
|
|
|
|
ft_set_tbl_option(table, FT_TOPT_BOTTOM_MARGIN, 4);
|
|
|
|
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);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-25 10:32:10 +02:00
|
|
|
table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
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";
|
2018-03-25 10:32:10 +02:00
|
|
|
assert_wcs_equal(table_str, table_str_etalon);
|
|
|
|
|
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
2018-04-16 20:01:45 +02:00
|
|
|
#endif
|
2018-03-25 10:11:08 +02:00
|
|
|
}
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
void test_table_cell_options(void)
|
2018-03-19 21:07:18 +01:00
|
|
|
{
|
|
|
|
FTABLE *table = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
WHEN("All paddings = 1") {
|
|
|
|
set_test_options_as_default();
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+---+----+----+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WHEN("Top and bottom padding = 0") {
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_TOP_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+---+----+----+\n"
|
|
|
|
"| 3 | 4 | 55 | 67 |\n"
|
|
|
|
"+---+---+----+----+\n"
|
|
|
|
"| 3 | 4 | 55 | 67 |\n"
|
|
|
|
"+---+---+----+----+\n"
|
|
|
|
"| 3 | 4 | 55 | 67 |\n"
|
|
|
|
"+---+---+----+----+\n";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
WHEN("Left and right padding = 0") {
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 0);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+-+-+--+--+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
WHEN("All paddings = 0") {
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_TOP_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 0);
|
|
|
|
ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 0);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+-+-+--+--+\n"
|
|
|
|
"|3|4|55|67|\n"
|
|
|
|
"+-+-+--+--+\n"
|
|
|
|
"|3|4|55|67|\n"
|
|
|
|
"+-+-+--+--+\n"
|
|
|
|
"|3|4|55|67|\n"
|
|
|
|
"+-+-+--+--+\n";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
WHEN("Empty string has 0 heigt") {
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_default_cell_option(FT_COPT_BOTTOM_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_TOP_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_LEFT_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_RIGHT_PADDING, 1);
|
|
|
|
ft_set_default_cell_option(FT_COPT_EMPTY_STR_HEIGHT, 0);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
int n = ft_printf_ln(table, "|||");
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(n == 4);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+---+----+----+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WHEN("Setting options for a particular table") {
|
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
set_test_options_for_table(table);
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_BOTTOM_PADDING, 0);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_TOP_PADDING, 0);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_LEFT_PADDING, 0);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 0);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+-+-+--+--+\n"
|
|
|
|
"|3|4|55|67|\n"
|
|
|
|
"+-+-+--+--+\n"
|
|
|
|
"|3|4|55|67|\n"
|
|
|
|
"+-+-+--+--+\n"
|
|
|
|
"|3|4|55|67|\n"
|
|
|
|
"+-+-+--+--+\n";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_BOTTOM_PADDING, 1);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_TOP_PADDING, 1);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_LEFT_PADDING, 0);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_RIGHT_PADDING, 0);
|
|
|
|
ft_set_cell_option(table, FT_ANY_ROW, FT_ANY_COLUMN, FT_COPT_EMPTY_STR_HEIGHT, 0);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+-+-+--+--+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WHEN("Set table width and column alignment") {
|
|
|
|
|
|
|
|
set_test_options_as_default();
|
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
int status = FT_SUCCESS;
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_MIN_WIDTH, 7);
|
2018-04-01 12:27:02 +02:00
|
|
|
status |= ft_set_cell_option(table, FT_ANY_ROW, 1, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
2018-03-25 10:11:08 +02:00
|
|
|
status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_COPT_MIN_WIDTH, 8);
|
2018-04-01 12:27:02 +02:00
|
|
|
status |= ft_set_cell_option(table, FT_ANY_ROW, 2, FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
status |= ft_set_cell_option(table, 2, 3, FT_COPT_MIN_WIDTH, 6);
|
2018-04-01 12:27:02 +02:00
|
|
|
status |= ft_set_cell_option(table, 2, 3, FT_COPT_TEXT_ALIGN, FT_ALIGNED_LEFT);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(status == FT_SUCCESS);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+-------+--------+------+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
WHEN("Set table width and column alignment as default") {
|
|
|
|
|
|
|
|
set_test_options_as_default();
|
|
|
|
|
|
|
|
int status = FT_SUCCESS;
|
2018-03-25 10:11:08 +02:00
|
|
|
status |= ft_set_default_cell_option(FT_COPT_MIN_WIDTH, 5);
|
2018-04-01 12:27:02 +02:00
|
|
|
status |= ft_set_default_cell_option(FT_COPT_TEXT_ALIGN, FT_ALIGNED_CENTER);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(status == FT_SUCCESS);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
table = create_test_int_table(0);
|
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+-----+-----+-----+-----+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
|
2018-03-25 10:11:08 +02:00
|
|
|
WHEN("Multiline cell") {
|
2018-03-19 21:07:18 +01:00
|
|
|
set_test_options_as_default();
|
|
|
|
|
|
|
|
table = ft_create_table();
|
|
|
|
|
2018-04-01 12:27:02 +02:00
|
|
|
ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER);
|
2018-03-19 21:07:18 +01:00
|
|
|
int n = ft_printf_ln(table, "%d|%c|%s|%f", 4, 'c', "234", 3.14);
|
|
|
|
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(n == 4);
|
2018-04-24 19:41:14 +02:00
|
|
|
n = ft_write_ln(table, "5", "c", "234\n12", "3.140000");
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(n == FT_SUCCESS);
|
2018-03-19 21:07:18 +01:00
|
|
|
n = ft_printf_ln(table, "%d|%c|%s|%f", 3, 'c', "234", 3.14);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(n == 4);
|
2018-03-19 21:07:18 +01:00
|
|
|
|
|
|
|
const char *table_str = ft_to_string(table);
|
2018-03-31 12:33:37 +02:00
|
|
|
assert_true(table_str != NULL);
|
2018-03-19 21:07:18 +01:00
|
|
|
const char *table_str_etalon =
|
2018-03-31 12:33:37 +02:00
|
|
|
"+---+---+-----+----------+\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";
|
2018-03-24 15:01:29 +01:00
|
|
|
assert_str_equal(table_str, table_str_etalon);
|
2018-03-19 21:07:18 +01:00
|
|
|
ft_destroy_table(table);
|
|
|
|
}
|
|
|
|
}
|