(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestStringInterner(t *testing.T) { |
| 10 | si := newStringInterner() |
| 11 | |
| 12 | // Test basic interning |
| 13 | s1 := si.intern("test") |
| 14 | s2 := si.intern("test") |
| 15 | |
| 16 | // Should return the same string value |
| 17 | if s1 != s2 { |
| 18 | t.Error("String interning failed - expected same string value") |
| 19 | } |
| 20 | |
| 21 | // Intern should deduplicate - both should resolve to same underlying string |
| 22 | // This is verified by sync.Map storing it once |
| 23 | count := 0 |
| 24 | si.pool.Range(func(key, value interface{}) bool { |
| 25 | count++ |
| 26 | return true |
| 27 | }) |
| 28 | |
| 29 | if count != 1 { |
| 30 | t.Errorf("Expected 1 unique string in pool, got %d", count) |
| 31 | } |
| 32 | |
| 33 | // Different strings should still work |
| 34 | s3 := si.intern("different") |
| 35 | if s1 == s3 { |
| 36 | t.Error("Different strings should not be equal") |
| 37 | } |
| 38 | |
| 39 | // Pool should now have 2 entries |
| 40 | count = 0 |
| 41 | si.pool.Range(func(key, value interface{}) bool { |
| 42 | count++ |
| 43 | return true |
| 44 | }) |
| 45 | |
| 46 | if count != 2 { |
| 47 | t.Errorf("Expected 2 unique strings in pool, got %d", count) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func TestShouldInternColumn(t *testing.T) { |
| 52 | tests := []struct { |
nothing calls this directly
no test coverage detected