github.com/blend/go-sdk@v1.20220411.3/configutil/int_ptr_test.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package configutil 9 10 import ( 11 "context" 12 "testing" 13 14 "github.com/blend/go-sdk/assert" 15 ) 16 17 func TestIntPtr(t *testing.T) { 18 assert := assert.New(t) 19 20 isNil := IntPtr(nil) 21 value := 1 22 hasValue := IntPtr(&value) 23 value2 := 2 24 hasValue2 := IntPtr(&value2) 25 26 var setValue int 27 assert.Nil(SetInt(&setValue, isNil, hasValue, hasValue2)(context.TODO())) 28 assert.Equal(1, setValue) 29 } 30 31 func TestIntPtr_Zero(t *testing.T) { 32 assert := assert.New(t) 33 34 isNil := IntPtr(nil) 35 36 zero := 0 37 zeroValue := IntPtr(&zero) 38 39 value := 1 40 hasValue := IntPtr(&value) 41 value2 := 2 42 hasValue2 := IntPtr(&value2) 43 44 setValue := 3 45 assert.Nil(SetInt(&setValue, isNil, zeroValue, hasValue, hasValue2)(context.TODO())) 46 assert.Zero(setValue) 47 }