github.com/kunlun-qilian/sqlx/v3@v3.0.0/scanner/nullable/null_ignore_scanner_test.go (about) 1 package nullable 2 3 import ( 4 "testing" 5 6 "github.com/onsi/gomega" 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 gomega.NewWithT(t).Expect(v).To(gomega.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 gomega.NewWithT(t).Expect(v).To(gomega.Equal(0)) 32 }) 33 }