github.com/wabain/gqlgen@v0.7.2/graphql/float_test.go (about)

     1  package graphql
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestFloat(t *testing.T) {
    11  	assert.Equal(t, "123", m2s(MarshalFloat(123)))
    12  	assert.Equal(t, "1.2345678901", m2s(MarshalFloat(1.2345678901)))
    13  	assert.Equal(t, "1.2345678901234567", m2s(MarshalFloat(1.234567890123456789)))
    14  	assert.Equal(t, "1.2e+20", m2s(MarshalFloat(1.2e+20)))
    15  	assert.Equal(t, "1.2e-20", m2s(MarshalFloat(1.2e-20)))
    16  }
    17  
    18  func m2s(m Marshaler) string {
    19  	var b bytes.Buffer
    20  	m.MarshalGQL(&b)
    21  	return b.String()
    22  }