Skip to content

Commit

Permalink
fix(match-float): differentiate float vs int in dsl.Match. Fixes #93
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jul 31, 2018
1 parent ea42258 commit 48038ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions dsl/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ func match(srcType reflect.Type, params params) Matcher {
case reflect.Bool:
return Like(true)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Float32, reflect.Float64:
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return Like(1)
case reflect.Float32, reflect.Float64:
return Like(1.1)
default:
panic(fmt.Sprintf("match: unhandled type: %v", srcType))
}
Expand Down
4 changes: 2 additions & 2 deletions dsl/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,14 @@ func TestMatch(t *testing.T) {
args: args{
src: float32(1),
},
want: Like(1),
want: Like(1.1),
},
{
name: "base case - float64",
args: args{
src: float64(1),
},
want: Like(1),
want: Like(1.1),
},
{
name: "error - unhandled type",
Expand Down

0 comments on commit 48038ff

Please sign in to comment.