...

Source file src/github.com/xrash/smetrics/tests/wagner-fischer_test.go

Documentation: github.com/xrash/smetrics/tests

     1  package tests
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/xrash/smetrics"
     6  	"testing"
     7  )
     8  
     9  func TestWagnerFischer(t *testing.T) {
    10  	cases := []levenshteincase{
    11  		{"RASH", "RASH", 1, 1, 2, 0},
    12  		{"POTATO", "POTTATO", 1, 1, 2, 1},
    13  		{"POTTATO", "POTATO", 1, 1, 2, 1},
    14  		{"HOUSE", "MOUSE", 1, 1, 2, 2},
    15  		{"MOUSE", "HOUSE", 2, 2, 4, 4},
    16  		{"abc", "xy", 2, 3, 5, 13},
    17  		{"xy", "abc", 2, 3, 5, 12},
    18  	}
    19  
    20  	for _, c := range cases {
    21  		if r := smetrics.WagnerFischer(c.s, c.t, c.icost, c.dcost, c.scost); r != c.r {
    22  			fmt.Println(r, "instead of", c.r)
    23  			t.Fail()
    24  		}
    25  	}
    26  }
    27  

View as plain text