]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/go/arrow/scalar/numeric.gen_test.go.tmpl
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / go / arrow / scalar / numeric.gen_test.go.tmpl
CommitLineData
1d09f67e
TL
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package scalar_test
18
19import (
20 "testing"
21
22 "github.com/apache/arrow/go/v6/arrow"
23 "github.com/apache/arrow/go/v6/arrow/scalar"
24 "github.com/stretchr/testify/assert"
25)
26
27
28{{range .In}}
29func TestBasic{{.Name}}Scalars(t *testing.T) {
30 value := {{.Type}}(1)
31
32 scalarVal := scalar.New{{.Name}}Scalar(value)
33 assert.Equal(t, value, scalarVal.Value)
34 assert.True(t, scalarVal.IsValid())
35 assert.NoError(t, scalarVal.ValidateFull())
36
37 expectedType := arrow.PrimitiveTypes.{{.Name}}
38 assert.True(t, arrow.TypeEqual(scalarVal.DataType(), expectedType))
39
40 other := {{.Type}}(2)
41 scalarOther := scalar.New{{.Name}}Scalar(other)
42 assert.NotEqual(t, scalarVal, scalarOther)
43 assert.False(t, scalar.Equals(scalarVal, scalarOther))
44
45 scalarVal.Value = other
46 assert.Equal(t, other, scalarVal.Value)
47 assert.Equal(t, scalarVal, scalarOther)
48 assert.True(t, scalar.Equals(scalarVal, scalarOther))
49
50 nullVal := scalar.MakeNullScalar(arrow.PrimitiveTypes.{{.Name}})
51 assert.False(t, nullVal.IsValid())
52 assert.NoError(t, nullVal.ValidateFull())
53}
54
55func TestMakeScalar{{.Name}}(t *testing.T) {
56 three := scalar.MakeScalar({{.Type}}(3))
57 assert.NoError(t, three.ValidateFull())
58 assert.Equal(t, scalar.New{{.Name}}Scalar(3), three)
59
60 assertMakeScalar(t, scalar.New{{.Name}}Scalar(3), {{.Type}}(3))
61 assertParseScalar(t, arrow.PrimitiveTypes.{{.Name}}, "3", scalar.New{{.Name}}Scalar(3))
62}
63{{end}}