(t *testing.T)
| 266 | } |
| 267 | |
| 268 | func TestMemoryLimit_Integration(t *testing.T) { |
| 269 | // Simulate real-world scenario |
| 270 | data := [][]string{ |
| 271 | {"Name", "Email", "Country", "Status"}, |
| 272 | } |
| 273 | |
| 274 | // Add 1000 rows of realistic data |
| 275 | for i := 0; i < 1000; i++ { |
| 276 | data = append(data, []string{ |
| 277 | fmt.Sprintf("User_%d", i), |
| 278 | fmt.Sprintf("user%d@example.com", i), |
| 279 | "USA", |
| 280 | "Active", |
| 281 | }) |
| 282 | } |
| 283 | |
| 284 | // Test with reasonable limit |
| 285 | b, err := createNewBufferWithData(data, false) |
| 286 | if err != nil { |
| 287 | t.Fatalf("Failed to create buffer: %v", err) |
| 288 | } |
| 289 | |
| 290 | usage := b.getMemoryUsage() |
| 291 | if usage <= 0 { |
| 292 | t.Error("Memory usage should be tracked") |
| 293 | } |
| 294 | |
| 295 | t.Logf("Buffer with 1000 rows uses approximately %s", formatBytes(usage)) |
| 296 | |
| 297 | // Verify it's within reasonable bounds (should be < 1MB for this data) |
| 298 | if usage > 1024*1024 { |
| 299 | t.Errorf("Memory usage seems too high: %s", formatBytes(usage)) |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | // Benchmark memory tracking overhead |
| 304 | func BenchmarkMemoryTracking(b *testing.B) { |
nothing calls this directly
no test coverage detected