@@ -10,6 +10,16 @@ import (
1010 "github.com/cybertec-postgresql/pgcov/internal/parser"
1111)
1212
13+ // getCoveragePointBySignal finds a coverage point by its signal ID. Used only in tests.
14+ func getCoveragePointBySignal (instrumented * InstrumentedSQL , signalID string ) * CoveragePoint {
15+ for i := range instrumented .Locations {
16+ if instrumented .Locations [i ].SignalID == signalID {
17+ return & instrumented .Locations [i ]
18+ }
19+ }
20+ return nil
21+ }
22+
1323func TestInstrumentWithLexer (t * testing.T ) {
1424 sql := `CREATE OR REPLACE FUNCTION get_grade(score INT)
1525RETURNS TEXT AS $$
@@ -423,21 +433,21 @@ func TestGetCoveragePointBySignal(t *testing.T) {
423433
424434 // Test finding a coverage point by signal
425435 signal := instrumented .Locations [0 ].SignalID
426- cp := GetCoveragePointBySignal (instrumented , signal )
436+ cp := getCoveragePointBySignal (instrumented , signal )
427437 if cp == nil {
428438 t .Errorf ("GetCoveragePointBySignal() returned nil for signal %q" , signal )
429439 } else if cp .SignalID != signal {
430440 t .Errorf ("GetCoveragePointBySignal() got signal %q, want %q" , cp .SignalID , signal )
431441 }
432442
433443 // Test non-existent signal
434- cp = GetCoveragePointBySignal (instrumented , "nonexistent:signal" )
444+ cp = getCoveragePointBySignal (instrumented , "nonexistent:signal" )
435445 if cp != nil {
436446 t .Errorf ("GetCoveragePointBySignal() expected nil for nonexistent signal, got %v" , cp )
437447 }
438448
439449 // Test returned pointer refers to actual slice element, not a loop-copy
440- cp = GetCoveragePointBySignal (instrumented , signal )
450+ cp = getCoveragePointBySignal (instrumented , signal )
441451 if cp != & instrumented .Locations [0 ] {
442452 t .Error ("GetCoveragePointBySignal() returned pointer to copy, not to original slice element" )
443453 }
0 commit comments