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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user