MCPcopy
hub / github.com/redis/go-redis / TestAtoi

Function TestAtoi

internal/util/strconv_test.go:8–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestAtoi(t *testing.T) {
9 tests := []struct {
10 input []byte
11 expected int
12 wantErr bool
13 }{
14 {[]byte("123"), 123, false},
15 {[]byte("-456"), -456, false},
16 {[]byte("abc"), 0, true},
17 }
18
19 for _, tt := range tests {
20 result, err := Atoi(tt.input)
21 if (err != nil) != tt.wantErr {
22 t.Errorf("Atoi(%q) error = %v, wantErr %v", tt.input, err, tt.wantErr)
23 }
24 if result != tt.expected && !tt.wantErr {
25 t.Errorf("Atoi(%q) = %d, want %d", tt.input, result, tt.expected)
26 }
27 }
28}
29
30func TestParseInt(t *testing.T) {
31 tests := []struct {

Callers

nothing calls this directly

Calls 1

AtoiFunction · 0.85

Tested by

no test coverage detected