Skip to content

Commit

Permalink
Rename col_count to column_count, call discover_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi committed Jul 27, 2023
1 parent e5335ef commit 044cf03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl Table {
///
/// assert_eq!(table.col_count(), 3);
/// ```
pub fn col_count(&self) -> usize {
pub fn column_count(&mut self) -> usize {
self.discover_columns();
self.columns.len()
}

Expand Down
10 changes: 5 additions & 5 deletions tests/all/counts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ fn test_col_count_header() {
let mut table = Table::new();

table.set_header(vec!["Col 1", "Col 2", "Col 3"]);
assert_eq!(table.col_count(), 3);
assert_eq!(table.column_count(), 3);

table.set_header(vec!["Col 1", "Col 2", "Col 3", "Col 4"]);
assert_eq!(table.col_count(), 4);
assert_eq!(table.column_count(), 4);

table.set_header(vec!["Col I", "Col II"]);
assert_eq!(table.col_count(), 4);
assert_eq!(table.column_count(), 4);
}

#[test]
fn test_col_count_row() {
let mut table = Table::new();

table.add_row(vec!["Foo", "Bar"]);
assert_eq!(table.col_count(), 2);
assert_eq!(table.column_count(), 2);

table.add_row(vec!["Bar", "Foo", "Baz"]);
assert_eq!(table.col_count(), 3);
assert_eq!(table.column_count(), 3);
}

#[test]
Expand Down

0 comments on commit 044cf03

Please sign in to comment.