Source file src/runtime/float_test.go

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package runtime_test
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestIssue48807(t *testing.T) {
    12  	for _, i := range []uint64{
    13  		0x8234508000000001, // from issue48807
    14  		1<<56 + 1<<32 + 1,
    15  	} {
    16  		got := float32(i)
    17  		dontwant := float32(float64(i))
    18  		if got == dontwant {
    19  			// The test cases above should be uint64s such that
    20  			// this equality doesn't hold. These examples trigger
    21  			// the case where using an intermediate float64 doesn't work.
    22  			t.Errorf("direct float32 conversion doesn't work: arg=%x got=%x dontwant=%x", i, got, dontwant)
    23  		}
    24  	}
    25  }
    26  

View as plain text