-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmutate_column_test.go
More file actions
31 lines (26 loc) · 952 Bytes
/
mutate_column_test.go
File metadata and controls
31 lines (26 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package datatable_test
import (
"testing"
"github.com/datasweet/datatable"
)
func TestSwapColumn(t *testing.T) {
tb := datatable.New("test")
tb.AddColumn("champ", datatable.String, datatable.Values("Malzahar", "Xerath", "Teemo"))
tb.AddColumn("champion", datatable.String, datatable.Expr("upper(`champ`)"))
tb.AddColumn("win", datatable.Int, datatable.Values(10, 20, 666))
tb.AddColumn("loose", datatable.Int, datatable.Values(6, 5, 666))
tb.AddColumn("winRate", datatable.Float64, datatable.Expr("(`win` * 100 / (`win` + `loose`))"))
checkTable(t, tb,
"champ", "champion", "win", "loose", "winRate",
"Malzahar", "MALZAHAR", 10, 6, 62.5,
"Xerath", "XERATH", 20, 5, 80.0,
"Teemo", "TEEMO", 666, 666, 50.0,
)
tb.SwapColumn("champion", "winRate")
checkTable(t, tb,
"champ", "winRate", "win", "loose", "champion",
"Malzahar", 62.5, 10, 6, "MALZAHAR",
"Xerath", 80.0, 20, 5, "XERATH",
"Teemo", 50.0, 666, 666, "TEEMO",
)
}