Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml_test: adapt around undefined behavior in float64->int64 casting #42

Merged
Merged
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
5 changes: 3 additions & 2 deletions yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ foo: baz
}

func TestJSONObjectToYAMLObject(t *testing.T) {
const bigUint64 = ((uint64(1) << 63) + 500) / 1000 * 1000
intOrInt64 := func(i64 int64) interface{} {
if i := int(i64); i64 == int64(i) {
return i
Expand Down Expand Up @@ -459,7 +460,7 @@ func TestJSONObjectToYAMLObject(t *testing.T) {
"map": map[string]interface{}{"foo": "bar"},
"slice": []interface{}{"foo", "bar"},
"string": string("foo"),
"uint64 big": float64(math.Pow(2, 63)),
"uint64 big": bigUint64,
},
expected: yaml.MapSlice{
{Key: "nil slice"},
Expand All @@ -476,7 +477,7 @@ func TestJSONObjectToYAMLObject(t *testing.T) {
{Key: "map", Value: yaml.MapSlice{{Key: "foo", Value: "bar"}}},
{Key: "slice", Value: []interface{}{"foo", "bar"}},
{Key: "string", Value: string("foo")},
{Key: "uint64 big", Value: uint64(1) << 63},
{Key: "uint64 big", Value: bigUint64},
},
},
}
Expand Down