github.com/kaydxh/golang@v0.0.131/pkg/gocv/cvtable/cvtable_test.go (about) 1 package cvtable_test 2 3 import ( 4 "fmt" 5 "testing" 6 7 cvtable_ "github.com/kaydxh/golang/pkg/gocv/cvtable" 8 ) 9 10 func TestSim(t *testing.T) { 11 cvtable, err := cvtable_.NewCVTable("./testdata/cvtable.conf") 12 if err != nil { 13 t.Fatalf("failed to new cvtable, err: %v", err) 14 } 15 16 testCases := []struct { 17 score float64 18 expected string 19 }{ 20 { 21 score: 95.13, 22 expected: "", 23 }, 24 { 25 score: 200.13, 26 expected: "", 27 }, 28 } 29 30 for i, testCase := range testCases { 31 t.Run(fmt.Sprintf("case-%v", i), func(t *testing.T) { 32 sim := cvtable.Sim(testCase.score) 33 t.Logf("get sim %v for score %v", sim, testCase.score) 34 }) 35 } 36 } 37 38 func TestScore(t *testing.T) { 39 cvtable, err := cvtable_.NewCVTable("./testdata/cvtable.conf") 40 if err != nil { 41 t.Fatalf("failed to new cvtable, err: %v", err) 42 } 43 44 testCases := []struct { 45 sim float64 46 expected string 47 }{ 48 { 49 sim: 0.9513, 50 expected: "", 51 }, 52 { 53 sim: 1.20013, 54 expected: "", 55 }, 56 } 57 58 for i, testCase := range testCases { 59 t.Run(fmt.Sprintf("case-%v", i), func(t *testing.T) { 60 score := cvtable.Score(testCase.sim) 61 t.Logf("get score %v for sim %v", score, testCase.sim) 62 }) 63 } 64 }