File: valid_go18_test.go

package info (click to toggle)
golang-github-segmentio-asm 1.2.0%2Bgit20231107.1cfacc8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: asm: 6,093; makefile: 32
file content (25 lines) | stat: -rw-r--r-- 482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//go:build go1.18
// +build go1.18

package utf8

import (
	"testing"
	stdlib "unicode/utf8"

	"github.com/segmentio/asm/ascii"
)

func FuzzValid(f *testing.F) {
	f.Fuzz(func(t *testing.T, data []byte) {
		v := Validate(data)
		ru := stdlib.Valid(data)
		if ru != v.IsUTF8() {
			t.Errorf("Validate(%q) UTF8 = %v; want %v", data, v.IsUTF8(), ru)
		}
		ra := ascii.Valid(data)
		if ra != v.IsASCII() {
			t.Errorf("Validate(%q) ASCII = %v; want %v", data, v.IsASCII(), ra)
		}
	})
}