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

Function TestExprColumn

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

Source from the content-addressed store, hash-verified

89}
90
91func TestExprColumn(t *testing.T) {
92 tb := datatable.New("test")
93 tb.AddColumn("champ", datatable.String, datatable.Values("Malzahar", "Xerath", "Teemo"))
94 tb.AddColumn("champion", datatable.String, datatable.Expr("upper(`champ`)"))
95 tb.AddColumn("win", datatable.Int, datatable.Values(10, 20, 666))
96 tb.AddColumn("loose", datatable.Int, datatable.Values(6, 5, 666))
97 tb.AddColumn("winRate", datatable.String, datatable.Expr("(`win` * 100 / (`win` + `loose`)) ~ \" %\""))
98 tb.AddColumn("sum", datatable.Int, datatable.Expr("sum(`win`)"))
99 tb.AddColumn("ok", datatable.Bool, datatable.Expr("true"))
100
101 checkTable(t, tb,
102 "champ", "champion", "win", "loose", "winRate", "sum", "ok",
103 "Malzahar", "MALZAHAR", 10, 6, "62.5 %", 696, true,
104 "Xerath", "XERATH", 20, 5, "80 %", 696, true,
105 "Teemo", "TEEMO", 666, 666, "50 %", 696, true,
106 )
107}
108
109func TestAppendRow(t *testing.T) {
110 tb := datatable.New("test")

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected