mirror of
				https://github.com/tailscale/tailscale.git
				synced 2025-10-31 00:01:40 +01:00 
			
		
		
		
	Updates tailscale/corp#29650 Change-Id: Iad4e4ccd9d68ebb1d1a12f335cc5295d0bd05b60 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
		
			
				
	
	
		
			62 lines
		
	
	
		
			998 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			998 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) Tailscale Inc & AUTHORS
 | |
| // SPDX-License-Identifier: BSD-3-Clause
 | |
| 
 | |
| package main
 | |
| 
 | |
| import (
 | |
| 	"reflect"
 | |
| 	"testing"
 | |
| 
 | |
| 	"tailscale.com/cmd/cloner/clonerex"
 | |
| )
 | |
| 
 | |
| func TestSliceContainer(t *testing.T) {
 | |
| 	num := 5
 | |
| 	examples := []struct {
 | |
| 		name string
 | |
| 		in   *clonerex.SliceContainer
 | |
| 	}{
 | |
| 		{
 | |
| 			name: "nil",
 | |
| 			in:   nil,
 | |
| 		},
 | |
| 		{
 | |
| 			name: "zero",
 | |
| 			in:   &clonerex.SliceContainer{},
 | |
| 		},
 | |
| 		{
 | |
| 			name: "empty",
 | |
| 			in: &clonerex.SliceContainer{
 | |
| 				Slice: []*int{},
 | |
| 			},
 | |
| 		},
 | |
| 		{
 | |
| 			name: "nils",
 | |
| 			in: &clonerex.SliceContainer{
 | |
| 				Slice: []*int{nil, nil, nil, nil, nil},
 | |
| 			},
 | |
| 		},
 | |
| 		{
 | |
| 			name: "one",
 | |
| 			in: &clonerex.SliceContainer{
 | |
| 				Slice: []*int{&num},
 | |
| 			},
 | |
| 		},
 | |
| 		{
 | |
| 			name: "several",
 | |
| 			in: &clonerex.SliceContainer{
 | |
| 				Slice: []*int{&num, &num, &num, &num, &num},
 | |
| 			},
 | |
| 		},
 | |
| 	}
 | |
| 
 | |
| 	for _, ex := range examples {
 | |
| 		t.Run(ex.name, func(t *testing.T) {
 | |
| 			out := ex.in.Clone()
 | |
| 			if !reflect.DeepEqual(ex.in, out) {
 | |
| 				t.Errorf("Clone() = %v, want %v", out, ex.in)
 | |
| 			}
 | |
| 		})
 | |
| 	}
 | |
| }
 |