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

Function TestMarshalToken

token_test.go:8–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestMarshalToken(t *testing.T) {
9 t.Parallel()
10
11 data := []struct {
12 in string
13 valid bool
14 }{
15 {"abc'!#$%*+-.^_|~:/`", true},
16 {"H3lLo", true},
17 {"a*foo", true},
18 {"a!1", true},
19 {"a#1", true},
20 {"a$1", true},
21 {"a%1", true},
22 {"a&1", true},
23 {"a'1", true},
24 {"a*1", true},
25 {"a+1", true},
26 {"a-1", true},
27 {"a.1", true},
28 {"a^1", true},
29 {"a_1", true},
30 {"a`1", true},
31 {"a|1", true},
32 {"a~1", true},
33 {"a:1", true},
34 {"a/1", true},
35 {`0foo`, false},
36 {`!foo`, false},
37 {"1abc", false},
38 {"", false},
39 {"hel\tlo", false},
40 {"hel\x1flo", false},
41 {"hel\x7flo", false},
42 {"Kévin", false},
43 }
44
45 var b strings.Builder
46
47 for _, d := range data {
48 b.Reset()
49
50 err := Token(d.in).marshalSFV(&b)
51 if d.valid && err != nil {
52 t.Errorf("error not expected for %v, got %v", d.in, err)
53 } else if !d.valid && err == nil {
54 t.Errorf("error expected for %v, got %v", d.in, err)
55 }
56
57 if d.valid && b.String() != d.in {
58 t.Errorf("got %v; want %v", b.String(), d.in)
59 }
60 }
61}
62
63func TestParseToken(t *testing.T) {
64 t.Parallel()

Callers

nothing calls this directly

Calls 2

TokenTypeAlias · 0.85
marshalSFVMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…