MCPcopy Index your code
hub / github.com/codechenx/FastTableViewer / TestAutoDetectColumnType

Function TestAutoDetectColumnType

coltype_test.go:70–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestAutoDetectColumnType(t *testing.T) {
71 tests := []struct {
72 name string
73 data [][]string
74 colIndex int
75 expectedType int
76 }{
77 {
78 name: "String column",
79 data: [][]string{
80 {"Name", "Age"},
81 {"Alice", "30"},
82 {"Bob", "25"},
83 {"Charlie", "35"},
84 },
85 colIndex: 0,
86 expectedType: colTypeStr,
87 },
88 {
89 name: "Number column",
90 data: [][]string{
91 {"Name", "Age"},
92 {"Alice", "30"},
93 {"Bob", "25"},
94 {"Charlie", "35"},
95 },
96 colIndex: 1,
97 expectedType: colTypeFloat,
98 },
99 {
100 name: "Date column",
101 data: [][]string{
102 {"Name", "Date"},
103 {"Event1", "2024-01-15"},
104 {"Event2", "2024-02-20"},
105 {"Event3", "2024-03-10"},
106 },
107 colIndex: 1,
108 expectedType: colTypeDate,
109 },
110 {
111 name: "Mixed column defaults to string",
112 data: [][]string{
113 {"Name", "Value"},
114 {"Item1", "100"},
115 {"Item2", "abc"},
116 {"Item3", "200"},
117 },
118 colIndex: 1,
119 expectedType: colTypeStr,
120 },
121 {
122 name: "Numeric with NA values",
123 data: [][]string{
124 {"Name", "Score"},
125 {"Test1", "95.5"},
126 {"Test2", "NA"},
127 {"Test3", "87.3"},

Callers

nothing calls this directly

Calls 3

createNewBufferWithDataFunction · 0.85
type2nameFunction · 0.85
autoDetectColumnTypeMethod · 0.80

Tested by

no test coverage detected