...

Source file src/github.com/aws/aws-sdk-go-v2/internal/rand/rand_test.go

Documentation: github.com/aws/aws-sdk-go-v2/internal/rand

     1  package rand
     2  
     3  import (
     4  	"bytes"
     5  	"io"
     6  	"testing"
     7  )
     8  
     9  func TestGitterDelay(t *testing.T) {
    10  	maxFloat1 := 1 - 1/float64(1<<53)
    11  
    12  	cases := map[string]struct {
    13  		Reader io.Reader
    14  		Expect float64
    15  	}{
    16  		"floor": {
    17  			Reader: bytes.NewReader([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}),
    18  			Expect: 0,
    19  		},
    20  		"ceiling": {
    21  			Reader: bytes.NewReader([]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}),
    22  			Expect: maxFloat1,
    23  		},
    24  	}
    25  
    26  	for name, c := range cases {
    27  		t.Run(name, func(t *testing.T) {
    28  			d, err := Float64(c.Reader)
    29  			if err != nil {
    30  				t.Fatalf("expect no error, %v", err)
    31  			}
    32  
    33  			if e, a := c.Expect, d; e != a {
    34  				t.Errorf("expect %v delay, got %v", e, a)
    35  			}
    36  		})
    37  	}
    38  }
    39  

View as plain text