github.com/seeker-insurance/kit@v0.0.13/address/compare_test.go (about)

     1  package address
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestNormalizedSharedComponentDistanceSlice(t *testing.T) {
     9  	type args struct {
    10  		placeA Address
    11  		placeB Address
    12  	}
    13  	tests := []struct {
    14  		name          string
    15  		args          args
    16  		wantDistances []int
    17  	}{
    18  		{
    19  			name: "all shared",
    20  			args: args{
    21  				placeA: Address{Street: "foo"},
    22  				placeB: Address{Street: "bar"},
    23  			},
    24  			wantDistances: []int{3},
    25  		},
    26  		{
    27  			name: "some shared",
    28  			args: args{
    29  				placeA: Address{Street: "foo", POBox: "foo"},
    30  				placeB: Address{Street: "bar", Country: "bar"},
    31  			},
    32  			wantDistances: []int{3},
    33  		},
    34  	}
    35  	for _, tt := range tests {
    36  		t.Run(tt.name, func(t *testing.T) {
    37  			if gotDistances := NormalizedSharedComponentDistanceSlice(tt.args.placeA, tt.args.placeB); !reflect.DeepEqual(gotDistances, tt.wantDistances) {
    38  				t.Errorf("NormalizedSharedComponentDistanceSlice() = %v, want %v", gotDistances, tt.wantDistances)
    39  			}
    40  		})
    41  	}
    42  }