github.com/andrewrech/ih-abstract@v0.0.0-20210322142951-2fec1c8d0f38/filter_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/google/go-cmp/cmp" 7 ) 8 9 func BenchmarkFilter(b *testing.B) { 10 for i := 0; i < b.N; i++ { 11 in := helperTestReader(TestFilePhi) 12 13 header := helperCorrectHeader() 14 out, filterDone := filterResults(in, header) 15 16 <-filterDone 17 18 _ = out 19 } 20 } 21 22 func TestFilter(t *testing.T) { 23 in := helperTestReader(TestFile) 24 25 header := helperCorrectHeader() 26 27 out, filterDone := filterResults(in, header) 28 29 <-filterDone 30 31 ts := map[string]struct { 32 input string 33 want int64 34 }{ 35 "diff": {input: string("diff"), want: int64(7)}, 36 "filter (CPD)": {input: string("cpd"), want: int64(1)}, 37 "filter (WBC)": {input: string("wbc"), want: int64(4)}, 38 "filter (PD-L1)": {input: string("pdl1"), want: int64(4)}, 39 "filter (MSI)": {input: string("msi"), want: int64(2)}, 40 } 41 42 for x, n := range ts { 43 x := x 44 n := n 45 46 t.Run(x, func(t *testing.T) { 47 var i int64 48 49 for range out[n.input] { 50 i++ 51 } 52 53 diff := cmp.Diff(n.want, i) 54 55 if diff != "" { 56 t.Fatalf(diff) 57 } 58 }) 59 } 60 }