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

Function TestDetectAllColumnTypes

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

Source from the content-addressed store, hash-verified

274}
275
276func TestDetectAllColumnTypes(t *testing.T) {
277 data := [][]string{
278 {"Name", "Age", "Date", "Mixed"},
279 {"Alice", "30", "2024-01-15", "Value1"},
280 {"Bob", "25", "2024-02-20", "123"},
281 {"Charlie", "35", "2024-03-10", "ABC"},
282 }
283
284 b, err := createNewBufferWithData(data, false)
285 if err != nil {
286 t.Fatalf("Failed to create buffer: %v", err)
287 }
288 b.rowFreeze = 1
289
290 // Detect all column types
291 b.detectAllColumnTypes()
292
293 // Check detected types
294 if b.getColType(0) != colTypeStr {
295 t.Errorf("Column 0 (Name) should be String, got %s", type2name(b.getColType(0)))
296 }
297 if b.getColType(1) != colTypeFloat {
298 t.Errorf("Column 1 (Age) should be Number, got %s", type2name(b.getColType(1)))
299 }
300 if b.getColType(2) != colTypeDate {
301 t.Errorf("Column 2 (Date) should be Date, got %s", type2name(b.getColType(2)))
302 }
303 if b.getColType(3) != colTypeStr {
304 t.Errorf("Column 3 (Mixed) should be String, got %s", type2name(b.getColType(3)))
305 }
306}

Callers

nothing calls this directly

Calls 4

createNewBufferWithDataFunction · 0.85
type2nameFunction · 0.85
detectAllColumnTypesMethod · 0.80
getColTypeMethod · 0.80

Tested by

no test coverage detected