Code Room
Vibe codingHardvc-g149
Subject Ai test reviewLevel Mid–Senior~17 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You asked Claude Code to test a Go LRU cache (Get, Put, eviction at capacity). It produced tests that pass, but several reach into internals:

go
func TestPutEvicts(t *testing.T) {    c := NewLRU(2)    c.Put("a", 1); c.Put("b", 2); c.Put("c", 3)    // a should be evicted    if len(c.items) != 2 { t.Fatal("wrong size") }    if _, ok := c.items["a"]; ok { t.Fatal("a not evicted") }    if c.head.key != "c" { t.Fatal("head wrong") }}

The test passes. What's the problem with how it verifies behavior, and what would you change?

What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.