MCPcopy Create free account
hub / github.com/datasweet/datatable / TestRows

Function TestRows

table_test.go:129–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

127}
128
129func TestRows(t *testing.T) {
130 tb := datatable.New("test")
131 assert.NoError(t, tb.AddColumn("champ", datatable.String))
132 assert.NoError(t, tb.AddColumn("win", datatable.Int))
133 assert.NoError(t, tb.AddColumn("loose", datatable.Int, datatable.ColumnHidden(true)))
134 assert.NoError(t, tb.AddColumn("winRate", datatable.Float64, datatable.Expr("(`win` * 100 / (`win` + `loose`))")))
135 assert.Error(t, tb.AddColumn("winRate", datatable.String, datatable.Expr("test")))
136
137 assert.NoError(t, tb.AppendRow("Xerath", 25, 15, "expr"))
138 assert.NoError(t, tb.AppendRow("Malzahar", 16, 16, nil))
139 assert.NoError(t, tb.AppendRow("Vel'Koz", 7, 5, 3))
140
141 checkTable(t, tb,
142 "champ", "win", "winRate",
143 "Xerath", 25, 62.5,
144 "Malzahar", 16, 50.0,
145 "Vel'Koz", 7, 58.333333333333336,
146 )
147
148 for _, r := range tb.Rows() {
149 assert.Len(t, r, 3)
150 }
151
152 for _, r := range tb.Rows(datatable.ExportHidden(true)) {
153 assert.Len(t, r, 4)
154 }
155}
156
157func TestRow(t *testing.T) {
158 tb := datatable.New("test")

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
ColumnHiddenFunction · 0.92
ExprFunction · 0.92
ExportHiddenFunction · 0.92
checkTableFunction · 0.85
AddColumnMethod · 0.80
AppendRowMethod · 0.80
RowsMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected