Skip to content

Commit

Permalink
Remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
kislaykishore committed Sep 25, 2024
1 parent 82678eb commit c108b3a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
11 changes: 0 additions & 11 deletions cfg/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package cfg
import (
"fmt"
"runtime"
"strconv"
"strings"
"time"
)

Expand Down Expand Up @@ -47,12 +45,3 @@ func ListCacheTTLSecsToDuration(secs int64) time.Duration {

return time.Duration(secs * int64(time.Second))
}

func IsNegativeNumber(str string) bool {
str = strings.TrimSpace(str)
num, err := strconv.ParseFloat(str, 64)
if err != nil {
return false // Conversion failed; not a valid number
}
return num < 0
}
22 changes: 0 additions & 22 deletions cfg/config_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,3 @@ func Test_ListCacheTtlSecsToDuration_InvalidCall(t *testing.T) {
// Calling with invalid argument to trigger panic.
ListCacheTTLSecsToDuration(-3)
}

func TestIsNegativeNumber(t *testing.T) {
testCases := []struct {
name string
input string
expected bool
}{
{"negative_integer", "-123", true},
{"positive_integer", "456", false},
{"negative_float", "-3.14", true},
{"zero", "0", false},
{"string", "abc", false},
{"invalid", "-12.34invalid", false},
{"negative_with_spaces", " -5 ", true}, // Test with leading/trailing spaces
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, IsNegativeNumber(tc.input))
})
}
}

0 comments on commit c108b3a

Please sign in to comment.