File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -939,3 +939,8 @@ func (t *Table) Render() {
939939func (t * Table ) IsEmpty () bool {
940940 return len (t .data ) == 0
941941}
942+
943+ // RowCount returns the number of rows in the table.
944+ func (t * Table ) RowCount () int {
945+ return len (t .data )
946+ }
Original file line number Diff line number Diff line change @@ -830,3 +830,13 @@ func Test_TableIsNotEmpty(t *testing.T) {
830830 table .AddRow ("4" , "5" , "6" )
831831 assert .Equal (t , false , table .IsEmpty ())
832832}
833+
834+ func Test_TableRowCount (t * testing.T ) {
835+ builder := & strings.Builder {}
836+ table := New (builder )
837+ table .SetHeaders ("A" , "B" , "C" )
838+ assert .Equal (t , 0 , table .RowCount ())
839+ table .AddRow ("1" , "2" , "3" )
840+ table .AddRow ("4" , "5" , "6" )
841+ assert .Equal (t , 2 , table .RowCount ())
842+ }
You can’t perform that action at this time.
0 commit comments