(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestIsValidSeparator(t *testing.T) { |
| 94 | sd := sepDetecor{} |
| 95 | |
| 96 | tests := []struct { |
| 97 | name string |
| 98 | lines []string |
| 99 | sep rune |
| 100 | expected bool |
| 101 | }{ |
| 102 | { |
| 103 | "Valid comma", |
| 104 | []string{"a,b,c", "1,2,3"}, |
| 105 | ',', |
| 106 | true, |
| 107 | }, |
| 108 | { |
| 109 | "Invalid separator", |
| 110 | []string{"a,b,c", "1,2,3"}, |
| 111 | '|', |
| 112 | false, |
| 113 | }, |
| 114 | { |
| 115 | "Inconsistent counts", |
| 116 | []string{"a,b,c", "1,2"}, |
| 117 | ',', |
| 118 | false, |
| 119 | }, |
| 120 | { |
| 121 | "Empty lines", |
| 122 | []string{}, |
| 123 | ',', |
| 124 | false, |
| 125 | }, |
| 126 | } |
| 127 | |
| 128 | for _, tt := range tests { |
| 129 | t.Run(tt.name, func(t *testing.T) { |
| 130 | result := sd.isValidSeparator(tt.lines, tt.sep) |
| 131 | if result != tt.expected { |
| 132 | t.Errorf("isValidSeparator() = %v, want %v", result, tt.expected) |
| 133 | } |
| 134 | }) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | func TestCountRuneFast(t *testing.T) { |
| 139 | tests := []struct { |
nothing calls this directly
no test coverage detected