Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Format floats to allow for very large/small values #52

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,30 @@ func TestKeys(t *testing.T) {
IfExists().toCmd(),
Expected: "FSET agent 47 XX cash 100500",
},
{
Cmd: keys.FSet("agent", "47").
Field("id", 123456789012345680).
IfExists().toCmd(),
Expected: "FSET agent 47 XX id 123456789012345680",
},
{
Cmd: keys.FSet("agent", "47").
Field("id", -123456789012345680).
IfExists().toCmd(),
Expected: "FSET agent 47 XX id -123456789012345680",
},
{
Cmd: keys.FSet("agent", "47").
Field("small", 0.00000000012345678901234568).
IfExists().toCmd(),
Expected: "FSET agent 47 XX small 0.00000000012345678901234568",
},
{
Cmd: keys.FSet("agent", "47").
Field("small", -0.00000000012345678901234568).
IfExists().toCmd(),
Expected: "FSET agent 47 XX small -0.00000000012345678901234568",
},
{
Cmd: keys.JSet("foo", "bar", "some.field", "some-value").Raw().toCmd(),
Expected: "JSET foo bar some.field some-value RAW",
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (c cmd) String() string {
}

func floatString(val float64) string {
return strconv.FormatFloat(val, 'g', 10, 64)
return strconv.FormatFloat(val, 'f', -1, 64)
}

func rawEventHandler(handler func(*GeofenceEvent)) func([]byte) error {
Expand Down