(t *testing.T)
| 137 | } |
| 138 | |
| 139 | func TestRenderSlice_StructsAsTable(t *testing.T) { |
| 140 | var output strings.Builder |
| 141 | data := []SliceTestStruct{ |
| 142 | {ID: 1, Name: "first"}, |
| 143 | {ID: 2, Name: "second"}, |
| 144 | } |
| 145 | val := reflect.ValueOf(data) |
| 146 | |
| 147 | renderSlice(val, "Test Table", &output, 0) |
| 148 | |
| 149 | result := output.String() |
| 150 | |
| 151 | // Should have title |
| 152 | if !strings.Contains(result, "# Test Table") { |
| 153 | t.Errorf("Output should contain title, got: %q", result) |
| 154 | } |
| 155 | |
| 156 | // Should render as table (check for table headers from console tags) |
| 157 | if !strings.Contains(result, "ID") { |
| 158 | t.Error("Output should contain ID column header") |
| 159 | } |
| 160 | if !strings.Contains(result, "Name") { |
| 161 | t.Error("Output should contain Name column header") |
| 162 | } |
| 163 | if !strings.Contains(result, "first") { |
| 164 | t.Error("Output should contain data from first row") |
| 165 | } |
| 166 | if !strings.Contains(result, "second") { |
| 167 | t.Error("Output should contain data from second row") |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | func TestRenderSlice_PointerToStructsAsTable(t *testing.T) { |
| 172 | var output strings.Builder |
nothing calls this directly
no test coverage detected