]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/go/arrow/array/null_test.go
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / go / arrow / array / null_test.go
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
17 package array_test
18
19 import (
20 "testing"
21
22 "github.com/apache/arrow/go/v6/arrow"
23 "github.com/apache/arrow/go/v6/arrow/array"
24 "github.com/apache/arrow/go/v6/arrow/memory"
25 )
26
27 func TestNullArray(t *testing.T) {
28 pool := memory.NewCheckedAllocator(memory.NewGoAllocator())
29 defer pool.AssertSize(t, 0)
30
31 b := array.NewNullBuilder(pool)
32 defer b.Release()
33
34 b.AppendNull()
35 b.AppendNull()
36
37 arr1 := b.NewArray().(*array.Null)
38 defer arr1.Release()
39
40 if got, want := arr1.Len(), 2; got != want {
41 t.Fatalf("invalid null array length: got=%d, want=%d", got, want)
42 }
43
44 if got, want := arr1.NullN(), 2; got != want {
45 t.Fatalf("invalid number of nulls: got=%d, want=%d", got, want)
46 }
47
48 if got, want := arr1.DataType(), arrow.Null; got != want {
49 t.Fatalf("invalid null data type: got=%v, want=%v", got, want)
50 }
51
52 arr1.Retain()
53 arr1.Release()
54
55 if arr1.Data() == nil {
56 t.Fatalf("invalid null data")
57 }
58
59 arr2 := b.NewNullArray()
60 defer arr2.Release()
61
62 if got, want := arr2.Len(), 0; got != want {
63 t.Fatalf("invalid null array length: got=%d, want=%d", got, want)
64 }
65
66 arr3 := array.NewNull(10)
67 defer arr3.Release()
68
69 if got, want := arr3.Len(), 10; got != want {
70 t.Fatalf("invalid null array length: got=%d, want=%d", got, want)
71 }
72
73 if got, want := arr3.NullN(), 10; got != want {
74 t.Fatalf("invalid number of nulls: got=%d, want=%d", got, want)
75 }
76
77 }