Files
gists/projects/go-tools/goipgrep/internal/extract/extract_test.go
T
tobias 1cbf8afb4a chore: cleanup — untrack binaries, consolidate Go dirs, dedupe tools
- Untrack and delete compiled binaries (tarsum, gosoft.exe, rust uniq/uniq2);
  ignore build outputs (dist/, bin/, *.exe, *.test, .ruff_cache/)
- Merge tools/go/ and projects/go-tools/go/ into projects/go-tools/<name>/
- Fix goipgrep .gitignore: bare 'ipgrep' pattern was ignoring cmd/ipgrep/,
  so the main entrypoint was never tracked; now anchored to /ipgrep
- Archive duplicate implementations to archive/experimental/{rust,go}/
  (uniq, between, tarsum rewrites); canonical versions stay in tools/
- Update README tool catalog to match new layout

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:42:45 +02:00

37 lines
857 B
Go

package extract
import (
"context"
"strings"
"testing"
)
func TestGrepIPv4(t *testing.T) {
in := "a 1.2.3.4 b 999.2.3.4 c\nx 10.0.0.1 y"
var got []string
err := Grep(context.Background(), strings.NewReader(in), Options{Mode: ModeIP}, func(s string) {
got = append(got, s)
})
if err != nil {
t.Fatalf("Grep: %v", err)
}
// Candidate matcher intentionally returns 999.2.3.4 too; validation happens elsewhere.
if len(got) != 3 {
t.Fatalf("got %d matches: %#v", len(got), got)
}
}
func TestGrepMAC(t *testing.T) {
in := "aa:bb:cc:dd:ee:ff aabb.ccdd.eeff 00-11-22-33-44-55"
var got []string
err := Grep(context.Background(), strings.NewReader(in), Options{Mode: ModeMAC}, func(s string) {
got = append(got, s)
})
if err != nil {
t.Fatalf("Grep: %v", err)
}
if len(got) != 3 {
t.Fatalf("got %d matches: %#v", len(got), got)
}
}