Files
go-extractor/sites/internal/parse/parse_test.go
Steve Dudenhoeffer 132817144e
All checks were successful
CI / build (pull_request) Successful in 29s
CI / vet (pull_request) Successful in 1m1s
CI / test (pull_request) Successful in 1m4s
refactor: deduplicate numericOnly and DuckDuckGo result extraction
- Extract identical numericOnly inline functions from powerball and
  megamillions into shared sites/internal/parse.NumericOnly with tests
- Extract duplicated DuckDuckGo result parsing from Search() and
  GetResults() into shared extractResults() helper

Closes #13, #14

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 16:26:54 +00:00

26 lines
433 B
Go

package parse
import "testing"
func TestNumericOnly(t *testing.T) {
tests := []struct {
input string
want float64
}{
{"$1.5 Billion", 1.5},
{"$100 Million", 100},
{"$200,000", 200000},
{"no numbers", 0},
{"", 0},
{"42", 42},
{"3.14159", 3.14159},
}
for _, tt := range tests {
got := NumericOnly(tt.input)
if got != tt.want {
t.Errorf("NumericOnly(%q) = %v, want %v", tt.input, got, tt.want)
}
}
}