MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_IsPositiveInteger

Function TestSpec_PublicAPI_IsPositiveInteger

pkg/stringutil/spec_test.go:152–202  ·  view source on GitHub ↗

TestSpec_PublicAPI_IsPositiveInteger validates the documented behavior of IsPositiveInteger as described in the package README.md. Specification: "Returns true if and only if s is a decimal integer that is strictly greater than zero, has no leading zeros, and contains no non-digit characters. Retur

(t *testing.T)

Source from the content-addressed store, hash-verified

150// characters. Returns false for "", "0", negative strings (e.g. "-5"), strings
151// with leading zeros (e.g. "007"), and non-numeric strings."
152func TestSpec_PublicAPI_IsPositiveInteger(t *testing.T) {
153 tests := []struct {
154 name string
155 input string
156 expected bool
157 }{
158 {
159 name: "digit-only string > 0 returns true",
160 input: "123",
161 expected: true,
162 },
163 {
164 name: "single positive digit returns true",
165 input: "1",
166 expected: true,
167 },
168 {
169 name: "empty string returns false (documented)",
170 input: "",
171 expected: false,
172 },
173 {
174 name: "zero returns false (documented)",
175 input: "0",
176 expected: false,
177 },
178 {
179 name: "string with leading zeros returns false (documented '007' case)",
180 input: "007",
181 expected: false,
182 },
183 {
184 name: "negative number returns false (documented '-5' case)",
185 input: "-5",
186 expected: false,
187 },
188 {
189 name: "non-numeric string returns false",
190 input: "12a3",
191 expected: false,
192 },
193 }
194
195 for _, tt := range tests {
196 t.Run(tt.name, func(t *testing.T) {
197 result := IsPositiveInteger(tt.input)
198 assert.Equal(t, tt.expected, result,
199 "IsPositiveInteger(%q) should match documented behavior", tt.input)
200 })
201 }
202}
203
204// TestSpec_PublicAPI_StripANSI validates the documented behavior of StripANSI
205// as described in the package README.md.

Callers

nothing calls this directly

Calls 2

IsPositiveIntegerFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected