...

Source file src/github.com/jackc/pgtype/num_multirange_test.go

Documentation: github.com/jackc/pgtype

     1  package pgtype_test
     2  
     3  import (
     4  	"math/big"
     5  	"testing"
     6  
     7  	"github.com/jackc/pgtype"
     8  	"github.com/jackc/pgtype/testutil"
     9  )
    10  
    11  func TestNumericMultirangeTranscode(t *testing.T) {
    12  	testutil.TestSuccessfulTranscode(t, "nummultirange", []interface{}{
    13  		&pgtype.Nummultirange{
    14  			Ranges: nil,
    15  			Status: pgtype.Present,
    16  		},
    17  		&pgtype.Nummultirange{
    18  			Ranges: []pgtype.Numrange{
    19  				{
    20  					Lower:     pgtype.Numeric{Int: big.NewInt(-543), Exp: 3, Status: pgtype.Present},
    21  					Upper:     pgtype.Numeric{Int: big.NewInt(342), Exp: 1, Status: pgtype.Present},
    22  					LowerType: pgtype.Inclusive,
    23  					UpperType: pgtype.Exclusive,
    24  					Status:    pgtype.Present,
    25  				},
    26  			},
    27  			Status: pgtype.Present,
    28  		},
    29  		&pgtype.Nummultirange{
    30  			Ranges: []pgtype.Numrange{
    31  				{
    32  					Lower:     pgtype.Numeric{Int: big.NewInt(-42), Exp: 1, Status: pgtype.Present},
    33  					Upper:     pgtype.Numeric{Int: big.NewInt(-5), Exp: 0, Status: pgtype.Present},
    34  					LowerType: pgtype.Inclusive,
    35  					UpperType: pgtype.Exclusive,
    36  					Status:    pgtype.Present,
    37  				},
    38  				{
    39  					Lower:     pgtype.Numeric{Int: big.NewInt(5), Exp: 1, Status: pgtype.Present},
    40  					Upper:     pgtype.Numeric{Int: big.NewInt(42), Exp: 1, Status: pgtype.Present},
    41  					LowerType: pgtype.Inclusive,
    42  					UpperType: pgtype.Inclusive,
    43  					Status:    pgtype.Present,
    44  				},
    45  				{
    46  					Lower:     pgtype.Numeric{Int: big.NewInt(42), Exp: 2, Status: pgtype.Present},
    47  					LowerType: pgtype.Exclusive,
    48  					UpperType: pgtype.Unbounded,
    49  					Status:    pgtype.Present,
    50  				},
    51  			},
    52  			Status: pgtype.Present,
    53  		},
    54  	})
    55  }
    56  

View as plain text