-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6602 from smartcontractkit/release/1.4.1
- Loading branch information
Showing
13 changed files
with
145 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.4.0 | ||
1.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tomlutils | ||
|
||
import ( | ||
"strconv" | ||
) | ||
|
||
// Float32 represents float32 values for TOML | ||
type Float32 float32 | ||
|
||
// UnmarshalText parses the value as a proper float32 | ||
func (t *Float32) UnmarshalText(text []byte) error { | ||
f32, err := strconv.ParseFloat(string(text), 32) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*t = Float32(f32) | ||
|
||
return nil | ||
} | ||
|
||
// Float64 represents float64 values for TOML | ||
type Float64 float64 | ||
|
||
// UnmarshalText parses the value as a proper float64 | ||
func (t *Float64) UnmarshalText(text []byte) error { | ||
f32, err := strconv.ParseFloat(string(text), 64) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
*t = Float64(f32) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package tomlutils | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUtils_TomlFloat32_Success_Decimal(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tomlF32 Float32 | ||
|
||
err := tomlF32.UnmarshalText([]byte("0.23")) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, tomlF32, Float32(0.23)) | ||
} | ||
|
||
func TestUtils_TomlFloat32_Success_Integer(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tomlF32 Float32 | ||
|
||
err := tomlF32.UnmarshalText([]byte("13")) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, tomlF32, Float32(13)) | ||
} | ||
|
||
func TestUtils_TomlFloat32_Failure(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tomlF32 Float32 | ||
|
||
err := tomlF32.UnmarshalText([]byte("1s")) | ||
|
||
assert.NotNil(t, err) | ||
} | ||
|
||
func TestUtils_TomlFloat64_Success_Decimal(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tomlF64 Float64 | ||
|
||
err := tomlF64.UnmarshalText([]byte("2.82")) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, tomlF64, Float64(2.82)) | ||
} | ||
|
||
func TestUtils_TomlFloat64_Success_Integer(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tomlF64 Float64 | ||
|
||
err := tomlF64.UnmarshalText([]byte("3")) | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, tomlF64, Float64(3)) | ||
} | ||
|
||
func TestUtils_TomlFloat64_Failure(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tomlF64 Float64 | ||
|
||
err := tomlF64.UnmarshalText([]byte("1s")) | ||
|
||
assert.NotNil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters