File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
test/F23.StringSimilarity.Tests Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ public JaroWinkler(double threshold)
7373 */
7474 public double Similarity ( string s1 , string s2 )
7575 {
76+ if ( s1 == null ) s1 = string . Empty ;
77+ if ( s2 == null ) s2 = string . Empty ;
78+
79+ if ( string . Equals ( s1 , s2 ) ) return 1f ;
80+
7681 int [ ] mtp = Matches ( s1 , s2 ) ;
7782 float m = mtp [ 0 ] ;
7883 if ( m == 0 )
Original file line number Diff line number Diff line change @@ -49,5 +49,17 @@ public void TestSimilarity()
4949 precision : 6 // 0.000001
5050 ) ;
5151 }
52+
53+ [ Fact ]
54+ public void TestSimilarityBothEmpty ( )
55+ {
56+ var instance = new JaroWinkler ( ) ;
57+
58+ Assert . Equal (
59+ expected : 1 ,
60+ actual : instance . Similarity ( string . Empty , string . Empty ) ,
61+ precision : 6 // 0.000001
62+ ) ;
63+ }
5264 }
5365}
You can’t perform that action at this time.
0 commit comments