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

Function TestAppendRow

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

Source from the content-addressed store, hash-verified

107}
108
109func TestAppendRow(t *testing.T) {
110 tb := datatable.New("test")
111 assert.NoError(t, tb.AddColumn("champ", datatable.String))
112 assert.NoError(t, tb.AddColumn("win", datatable.Int))
113 assert.NoError(t, tb.AddColumn("loose", datatable.Int))
114 assert.NoError(t, tb.AddColumn("winRate", datatable.Float64, datatable.Expr("(`win` * 100 / (`win` + `loose`))")))
115 assert.Error(t, tb.AddColumn("winRate", datatable.String, datatable.Expr("test")))
116
117 assert.NoError(t, tb.AppendRow("Xerath", 25, 15, "expr"))
118 assert.NoError(t, tb.AppendRow("Malzahar", 16, 16, nil))
119 assert.NoError(t, tb.AppendRow("Vel'Koz", 7, 5, 3))
120
121 checkTable(t, tb,
122 "champ", "win", "loose", "winRate",
123 "Xerath", 25, 15, 62.5,
124 "Malzahar", 16, 16, 50.0,
125 "Vel'Koz", 7, 5, 58.333333333333336,
126 )
127}
128
129func TestRows(t *testing.T) {
130 tb := datatable.New("test")

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
ExprFunction · 0.92
checkTableFunction · 0.85
AddColumnMethod · 0.80
AppendRowMethod · 0.80

Tested by

no test coverage detected