github.com/dolthub/go-mysql-server@v0.18.0/sql/expression/function/spatial/multipoint_test.go (about)

     1  // Copyright 2020-2022 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package spatial
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/stretchr/testify/require"
    21  
    22  	"github.com/dolthub/go-mysql-server/sql"
    23  	"github.com/dolthub/go-mysql-server/sql/expression"
    24  	"github.com/dolthub/go-mysql-server/sql/types"
    25  )
    26  
    27  func TestMultiPoint(t *testing.T) {
    28  	t.Run("create valid multipoint with points", func(t *testing.T) {
    29  		require := require.New(t)
    30  		f, err := NewMultiPoint(expression.NewLiteral(types.Point{X: 1, Y: 2}, types.PointType{}),
    31  			expression.NewLiteral(types.Point{X: 3, Y: 4}, types.PointType{}),
    32  			expression.NewLiteral(types.Point{X: 5, Y: 6}, types.PointType{}),
    33  		)
    34  		require.NoError(err)
    35  
    36  		v, err := f.Eval(sql.NewEmptyContext(), nil)
    37  		require.NoError(err)
    38  		require.Equal(types.MultiPoint{Points: []types.Point{{X: 1, Y: 2}, {X: 3, Y: 4}, {X: 5, Y: 6}}}, v)
    39  	})
    40  }
    41  
    42  func TestNewMultiPoint(t *testing.T) {
    43  	require := require.New(t)
    44  	_, err := NewMultiPoint(expression.NewLiteral(nil, types.PointType{}),
    45  		expression.NewLiteral(nil, types.PointType{}),
    46  		expression.NewLiteral(nil, types.PointType{}),
    47  	)
    48  	require.NoError(err)
    49  }