github.com/goki/ki@v1.1.11/kit/slices_test.go (about)

     1  // Copyright (c) 2018, The GoKi Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package kit
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  type TstStruct struct {
    12  	Field1 string
    13  }
    14  
    15  // test slice type functions
    16  func TestSliceType(t *testing.T) {
    17  	var sl []string
    18  
    19  	ts := SliceElType(sl).String()
    20  	if ts != "string" {
    21  		t.Errorf("slice el type should be string, not: %v\n", ts)
    22  	}
    23  
    24  	ts = SliceElType(&sl).String()
    25  	if ts != "string" {
    26  		t.Errorf("slice el type should be string, not: %v\n", ts)
    27  	}
    28  
    29  	var slp []*string
    30  
    31  	ts = SliceElType(slp).String()
    32  	if ts != "*string" {
    33  		t.Errorf("slice el type should be *string, not: %v\n", ts)
    34  	}
    35  
    36  	ts = SliceElType(&slp).String()
    37  	if ts != "*string" {
    38  		t.Errorf("slice el type should be *string, not: %v\n", ts)
    39  	}
    40  
    41  	var slsl [][]string
    42  
    43  	ts = SliceElType(slsl).String()
    44  	if ts != "[]string" {
    45  		t.Errorf("slice el type should be []string, not: %v\n", ts)
    46  	}
    47  
    48  	ts = SliceElType(&slsl).String()
    49  	if ts != "[]string" {
    50  		t.Errorf("slice el type should be []string, not: %v\n", ts)
    51  	}
    52  
    53  	// fmt.Printf("slsl kind: %v\n", SliceElType(slsl).Kind())
    54  
    55  }