MCPcopy Create free account
hub / github.com/dunglas/httpsfv / TestParseDisplayString

Function TestParseDisplayString

displaystring_test.go:39–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestParseDisplayString(t *testing.T) {
40 t.Parallel()
41
42 data := []struct {
43 in string
44 out string
45 err bool
46 }{
47 {`%"foo"`, "foo", false},
48 {`%"K%c3%a9vin"`, "Kévin", false},
49 {`%"K%00vin"`, "", true},
50 {`"K%e9vin"`, "", true},
51 {`%K%e9vin"`, "", true},
52 {`%"K%e9vin`, "", true},
53 }
54
55 for _, d := range data {
56 s := &scanner{data: d.in}
57
58 i, err := parseDisplayString(s)
59 if d.err && err == nil {
60 t.Errorf("parse(%s): error expected", d.in)
61 }
62
63 if !d.err && d.out != string(i) {
64 fmt.Printf("%q\n", i)
65 fmt.Printf("%q\n", d.out)
66 t.Errorf("parse(%s) = %v, %v; %v, <nil> expected", d.in, i, err, d.out)
67 }
68 }
69}

Callers

nothing calls this directly

Calls 1

parseDisplayStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…