MCPcopy Create free account
hub / github.com/prometheus/procfs / TestValueParser

Function TestValueParser

internal/util/valueparser_test.go:24–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestValueParser(t *testing.T) {
25 tests := []struct {
26 name string
27 v string
28 ok bool
29 fn func(t *testing.T, vp *util.ValueParser)
30 }{
31 {
32 name: "ok Int",
33 v: "10",
34 ok: true,
35 fn: func(t *testing.T, vp *util.ValueParser) {
36 want := 10
37 got := vp.Int()
38
39 if diff := cmp.Diff(want, got); diff != "" {
40 t.Fatalf("unexpected integer (-want +got):\n%s", diff)
41 }
42 },
43 },
44 {
45 name: "bad PInt64",
46 v: "hello",
47 fn: func(_ *testing.T, vp *util.ValueParser) {
48 _ = vp.PInt64()
49 },
50 },
51 {
52 name: "bad hex PInt64",
53 v: "0xhello",
54 fn: func(_ *testing.T, vp *util.ValueParser) {
55 _ = vp.PInt64()
56 },
57 },
58 {
59 name: "ok PInt64",
60 v: "1",
61 ok: true,
62 fn: func(t *testing.T, vp *util.ValueParser) {
63 want := int64(1)
64 got := vp.PInt64()
65
66 if diff := cmp.Diff(&want, got); diff != "" {
67 t.Fatalf("unexpected integer (-want +got):\n%s", diff)
68 }
69 },
70 },
71 {
72 name: "ok hex PInt64",
73 v: "0xff",
74 ok: true,
75 fn: func(t *testing.T, vp *util.ValueParser) {
76 want := int64(255)
77 got := vp.PInt64()
78
79 if diff := cmp.Diff(&want, got); diff != "" {
80 t.Fatalf("unexpected integer (-want +got):\n%s", diff)
81 }

Callers

nothing calls this directly

Calls 5

IntMethod · 0.95
PInt64Method · 0.95
PUInt64Method · 0.95
ErrMethod · 0.95
NewValueParserFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…