Implement ft_col_count() along with corresponding unit tests

This pairs with the existing ft_row_count() using the same column
counting method used elsewhere in the code (i.e., iterate over rows
and find the biggest).

Added unit tests for ft_row_count(), ft_col_count(), ft_is_empty(),
and use a myriad of insertion methods to increase coverage.
This commit is contained in:
Sean Morrison
2020-11-29 12:38:31 -05:00
parent b1c32b6751
commit c4be1ca649
5 changed files with 116 additions and 0 deletions

View File

@@ -233,6 +233,19 @@ size_t ft_row_count(const ft_table_t *table)
return vector_size(table->rows);
}
size_t ft_col_count(const ft_table_t *table)
{
assert(table && table->rows);
size_t cols_n = 0;
size_t rows_n = vector_size(table->rows);
for (size_t i = 0; i < rows_n; ++i) {
f_row_t *row = VECTOR_AT(table->rows, i, f_row_t *);
size_t ncols = columns_in_row(row);
cols_n = MAX(cols_n, ncols);
}
return cols_n;
}
int ft_erase_range(ft_table_t *table,
size_t top_left_row, size_t top_left_col,
size_t bottom_right_row, size_t bottom_right_col)