github.com/jackc/pgx/v5@v5.5.5/pgtype/zeronull/float8_test.go (about)

     1  package zeronull_test
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/jackc/pgx/v5/pgtype/zeronull"
     8  	"github.com/jackc/pgx/v5/pgxtest"
     9  )
    10  
    11  func isExpectedEq(a any) func(any) bool {
    12  	return func(v any) bool {
    13  		return a == v
    14  	}
    15  }
    16  
    17  func TestFloat8Transcode(t *testing.T) {
    18  	pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "float8", []pgxtest.ValueRoundTripTest{
    19  		{
    20  			(zeronull.Float8)(1),
    21  			new(zeronull.Float8),
    22  			isExpectedEq((zeronull.Float8)(1)),
    23  		},
    24  		{
    25  			nil,
    26  			new(zeronull.Float8),
    27  			isExpectedEq((zeronull.Float8)(0)),
    28  		},
    29  		{
    30  			(zeronull.Float8)(0),
    31  			new(any),
    32  			isExpectedEq(nil),
    33  		},
    34  	})
    35  }