MCPcopy Create free account
hub / github.com/codechenx/FastTableViewer / TestPerformSearch

Function TestPerformSearch

search_test.go:8–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestPerformSearch(t *testing.T) {
9 // Create test buffer
10 testData := [][]string{
11 {"Name", "Age", "City"},
12 {"John", "25", "New York"},
13 {"Jane", "30", "Los Angeles"},
14 {"Bob", "35", "Chicago"},
15 }
16
17 b, err := createNewBufferWithData(testData, false)
18 if err != nil {
19 t.Fatalf("Failed to create buffer: %v", err)
20 }
21
22 // Test case-insensitive search (non-regex)
23 results := performSearch(b, "john", false, false)
24 if len(results) != 1 {
25 t.Errorf("Expected 1 result for 'john', got %d", len(results))
26 }
27 if len(results) > 0 && (results[0].Row != 1 || results[0].Col != 0) {
28 t.Errorf("Expected result at (1,0), got (%d,%d)", results[0].Row, results[0].Col)
29 }
30
31 // Test case-sensitive search (non-regex)
32 results = performSearch(b, "John", false, true)
33 if len(results) != 1 {
34 t.Errorf("Expected 1 result for 'John', got %d", len(results))
35 }
36
37 // Test case-sensitive search with no results (non-regex)
38 results = performSearch(b, "john", false, true)
39 if len(results) != 0 {
40 t.Errorf("Expected 0 results for 'john' case-sensitive, got %d", len(results))
41 }
42
43 // Test partial match (non-regex)
44 results = performSearch(b, "an", false, false)
45 if len(results) != 2 { // "Jane" and "Los Angeles"
46 t.Errorf("Expected 2 results for 'an', got %d", len(results))
47 }
48
49 // Test no match (non-regex)
50 results = performSearch(b, "xyz", false, false)
51 if len(results) != 0 {
52 t.Errorf("Expected 0 results for 'xyz', got %d", len(results))
53 }
54}
55
56func TestPerformSearchRegex(t *testing.T) {
57 // Create test buffer

Callers

nothing calls this directly

Calls 2

createNewBufferWithDataFunction · 0.85
performSearchFunction · 0.85

Tested by

no test coverage detected