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

Function TestNewRow

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

Source from the content-addressed store, hash-verified

39}
40
41func TestNewRow(t *testing.T) {
42 tb := datatable.New("test")
43 assert.NoError(t, tb.AddColumn("champ", datatable.String))
44 assert.Equal(t, 1, tb.NumCols())
45 assert.Equal(t, 0, tb.NumRows())
46
47 r := make(datatable.Row)
48 r["champ"] = "Malzahar"
49 tb.Append(r)
50 assert.Equal(t, 1, tb.NumRows())
51
52 tb.Append(nil)
53 assert.Equal(t, 1, tb.NumRows())
54
55 tb.Append()
56 assert.Equal(t, 1, tb.NumRows())
57
58 tb.Append(
59 tb.NewRow().Set("champ", "Xerath"),
60 tb.NewRow().Set("satan", "Teemo"), // wrong column => not set
61 tb.NewRow().Set("champ", "Ahri"),
62 )
63
64 checkTable(t, tb,
65 "champ",
66 "Malzahar",
67 "Xerath",
68 nil,
69 "Ahri",
70 )
71
72 tb.AddColumn("win", datatable.Int)
73 checkTable(t, tb,
74 "champ", "win",
75 "Malzahar", nil,
76 "Xerath", nil,
77 nil, nil,
78 "Ahri", nil,
79 )
80
81 tb.AddColumn("loose", datatable.Int, datatable.Values(3, 4, nil))
82 checkTable(t, tb,
83 "champ", "win", "loose",
84 "Malzahar", nil, 3,
85 "Xerath", nil, 4,
86 nil, nil, nil,
87 "Ahri", nil, nil,
88 )
89}
90
91func TestExprColumn(t *testing.T) {
92 tb := datatable.New("test")

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
ValuesFunction · 0.92
checkTableFunction · 0.85
AddColumnMethod · 0.80
NumColsMethod · 0.80
NumRowsMethod · 0.80
NewRowMethod · 0.80
AppendMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected