MCPcopy Create free account
hub / github.com/1Password/for-open-source / TestParseNumber

Function TestParseNumber

script/validator_test.go:67–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestParseNumber(t *testing.T) {
68 testCases := []struct {
69 input string
70 expectedPass bool
71 expectedValue int
72 expectedError string
73 }{
74 {"123", true, 123, ""},
75 {"abc123", true, 123, ""},
76 {"123abc", true, 123, ""},
77 {"abc", false, 0, "could not be parsed into a number"},
78 }
79
80 for _, tc := range testCases {
81 pass, value, _ := ParseNumber(tc.input)
82 if pass != tc.expectedPass {
83 t.Errorf("ParseNumber(%s) passing is %v, expected %v", tc.input, pass, tc.expectedPass)
84 }
85
86 if value != tc.expectedValue {
87 t.Errorf("ParseNumber(%s) got new value %v, expected %v", tc.input, value, tc.expectedValue)
88 }
89 }
90}
91
92func TestParseBool(t *testing.T) {
93 testCases := []struct {

Callers

nothing calls this directly

Calls 1

ParseNumberFunction · 0.85

Tested by

no test coverage detected