github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/internal/sql/scanner/nullable/null_ignore_scanner_test.go (about)

     1  package nullable
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/octohelm/storage/internal/testutil"
     7  )
     8  
     9  func BenchmarkNewNullIgnoreScanner(b *testing.B) {
    10  	v := 0
    11  	for i := 0; i < b.N; i++ {
    12  		_ = NewNullIgnoreScanner(&v).Scan(2)
    13  	}
    14  	b.Log(v)
    15  }
    16  
    17  func TestNullIgnoreScanner(t *testing.T) {
    18  	t.Run("scan value", func(t *testing.T) {
    19  		v := 0
    20  		s := NewNullIgnoreScanner(&v)
    21  		_ = s.Scan(2)
    22  
    23  		testutil.Expect(t, v, testutil.Equal(2))
    24  	})
    25  
    26  	t.Run("scan nil", func(t *testing.T) {
    27  		v := 0
    28  		s := NewNullIgnoreScanner(&v)
    29  		_ = s.Scan(nil)
    30  
    31  		testutil.Expect(t, v, testutil.Equal(0))
    32  	})
    33  }