MCPcopy Index your code
hub / github.com/dunglas/httpsfv / TestParseBareItem

Function TestParseBareItem

bareitem_test.go:10–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestParseBareItem(t *testing.T) {
11 t.Parallel()
12
13 data := []struct {
14 in string
15 out interface{}
16 err bool
17 }{
18 {"?1", true, false},
19 {"?0", false, false},
20 {"22", int64(22), false},
21 {"-2.2", -2.2, false},
22 {`"foo"`, "foo", false},
23 {"abc", Token("abc"), false},
24 {"*abc", Token("*abc"), false},
25 {":YWJj:", []byte("abc"), false},
26 {"@1659578233", time.Unix(1659578233, 0), false},
27 {"", nil, true},
28 {"~", nil, true},
29 }
30
31 for _, d := range data {
32 s := &scanner{data: d.in}
33
34 i, err := parseBareItem(s)
35 if d.err && err == nil {
36 t.Errorf("parseBareItem(%s): error expected", d.in)
37 }
38
39 if !d.err && !reflect.DeepEqual(d.out, i) {
40 t.Errorf("parseBareItem(%s) = %v, %v; %v, <nil> expected", d.in, i, err, d.out)
41 }
42 }
43}
44
45func TestMarshalBareItem(t *testing.T) {
46 t.Parallel()

Callers

nothing calls this directly

Calls 2

TokenTypeAlias · 0.85
parseBareItemFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…