...

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

Documentation: github.com/jackc/pgtype

     1  package pgtype_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/jackc/pgtype"
     7  	"github.com/jackc/pgtype/testutil"
     8  )
     9  
    10  func TestInt8multirangeTranscode(t *testing.T) {
    11  	testutil.TestSuccessfulTranscode(t, "int8multirange", []interface{}{
    12  		&pgtype.Int8multirange{
    13  			Ranges: nil,
    14  			Status: pgtype.Present,
    15  		},
    16  		&pgtype.Int8multirange{
    17  			Ranges: []pgtype.Int8range{
    18  				{
    19  					Lower:     pgtype.Int8{Int: -543, Status: pgtype.Present},
    20  					Upper:     pgtype.Int8{Int: 342, Status: pgtype.Present},
    21  					LowerType: pgtype.Inclusive,
    22  					UpperType: pgtype.Exclusive,
    23  					Status:    pgtype.Present,
    24  				},
    25  			},
    26  			Status: pgtype.Present,
    27  		},
    28  		&pgtype.Int8multirange{
    29  			Ranges: []pgtype.Int8range{
    30  				{
    31  					Lower:     pgtype.Int8{Int: -42, Status: pgtype.Present},
    32  					Upper:     pgtype.Int8{Int: -5, Status: pgtype.Present},
    33  					LowerType: pgtype.Inclusive,
    34  					UpperType: pgtype.Exclusive,
    35  					Status:    pgtype.Present,
    36  				},
    37  				{
    38  					Lower:     pgtype.Int8{Int: 5, Status: pgtype.Present},
    39  					Upper:     pgtype.Int8{Int: 42, Status: pgtype.Present},
    40  					LowerType: pgtype.Inclusive,
    41  					UpperType: pgtype.Exclusive,
    42  					Status:    pgtype.Present,
    43  				},
    44  				{
    45  					Lower:     pgtype.Int8{Int: 52, Status: pgtype.Present},
    46  					LowerType: pgtype.Inclusive,
    47  					UpperType: pgtype.Unbounded,
    48  					Status:    pgtype.Present,
    49  				},
    50  			},
    51  			Status: pgtype.Present,
    52  		},
    53  	})
    54  }
    55  
    56  func TestInt8multirangeNormalize(t *testing.T) {
    57  	testutil.TestSuccessfulNormalize(t, []testutil.NormalizeTest{
    58  		{
    59  			SQL: "select int8multirange(int8range(1, 14, '(]'), int8range(20, 25, '()'))",
    60  			Value: pgtype.Int8multirange{
    61  				Ranges: []pgtype.Int8range{
    62  					{
    63  						Lower:     pgtype.Int8{Int: 2, Status: pgtype.Present},
    64  						Upper:     pgtype.Int8{Int: 15, Status: pgtype.Present},
    65  						LowerType: pgtype.Inclusive,
    66  						UpperType: pgtype.Exclusive,
    67  						Status:    pgtype.Present,
    68  					},
    69  					{
    70  						Lower:     pgtype.Int8{Int: 21, Status: pgtype.Present},
    71  						Upper:     pgtype.Int8{Int: 25, Status: pgtype.Present},
    72  						LowerType: pgtype.Inclusive,
    73  						UpperType: pgtype.Exclusive,
    74  						Status:    pgtype.Present,
    75  					},
    76  				},
    77  				Status: pgtype.Present,
    78  			},
    79  		},
    80  	})
    81  }
    82  

View as plain text