diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 17:32:24 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 17:32:24 +0200 |
| commit | 1561987330cb898f5ff64383a9c78e7e6559f118 (patch) | |
| tree | 69a823e8f98dce572566c97e6879c11c9d591bda /internal/tui/flamegraph/testdata_fixture_test.go | |
| parent | 96225fb6159212a8851043a08d781aba721b4e78 (diff) | |
| parent | 110a193e04b81abb8d8e159abd73f9f6ed1acd7e (diff) | |
Merge branch 'feat/bubbletea-v2-migration'
Diffstat (limited to 'internal/tui/flamegraph/testdata_fixture_test.go')
| -rw-r--r-- | internal/tui/flamegraph/testdata_fixture_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/testdata_fixture_test.go b/internal/tui/flamegraph/testdata_fixture_test.go new file mode 100644 index 0000000..1f22c26 --- /dev/null +++ b/internal/tui/flamegraph/testdata_fixture_test.go @@ -0,0 +1,39 @@ +package flamegraph + +import "testing" + +func TestFixtureSnapshotsHaveApproximateFrameCounts(t *testing.T) { + fixtures := []struct { + name string + depth int + breadth int + expect int + }{ + {name: "small", depth: fixtureSmallDepth, breadth: fixtureSmallBreadth, expect: 121}, + {name: "medium", depth: fixtureMediumDepth, breadth: fixtureMediumBreadth, expect: 2500}, + {name: "large", depth: fixtureLargeDepth, breadth: fixtureLargeBreadth, expect: 12000}, + {name: "deep", depth: fixtureDeepDepth, breadth: fixtureDeepBreadth, expect: 100}, + {name: "wide", depth: fixtureWideDepth, breadth: fixtureWideBreadth, expect: 5000}, + } + + for _, fixture := range fixtures { + t.Run(fixture.name, func(t *testing.T) { + snap := generateTestSnapshot(fixture.depth, fixture.breadth) + got := snapshotNodeCount(snap) + if !approxEqualCount(got, fixture.expect) { + t.Fatalf("%s fixture nodes=%d, expected approximately %d", fixture.name, got, fixture.expect) + } + }) + } +} + +func TestGenerateTestTrieProducesSnapshotData(t *testing.T) { + lt := generateTestTrie(fixtureSmallDepth, fixtureSmallBreadth) + snap, err := decodeTrieSnapshot(lt) + if err != nil { + t.Fatalf("decode trie snapshot: %v", err) + } + if snap.Total == 0 { + t.Fatalf("expected generated trie snapshot to contain data") + } +} |
