@@ -357,6 +357,80 @@ public void testExactMatchDistance() {
357357 }
358358 }
359359
360+ @ Test
361+ public void testEditDistanceExceptions () {
362+ final EditDistance d = new EditDistance (1.5 , 1.5 , 1.5 );
363+ UnsupportedOperationException thrown = assertThrows (
364+ UnsupportedOperationException .class ,
365+ () -> d .distance (new int [1 ], new int [1 ])
366+ );
367+ thrown = assertThrows (
368+ UnsupportedOperationException .class ,
369+ () -> d .distance (new long [1 ], new long [1 ])
370+ );
371+ thrown = assertThrows (
372+ UnsupportedOperationException .class ,
373+ () -> d .distance (new short [1 ], new short [1 ])
374+ );
375+ thrown = assertThrows (
376+ UnsupportedOperationException .class ,
377+ () -> d .distance (new byte [1 ], new byte [1 ])
378+ );
379+ thrown = assertThrows (
380+ UnsupportedOperationException .class ,
381+ () -> d .distance (new double [1 ], new double [1 ])
382+ );
383+ thrown = assertThrows (
384+ UnsupportedOperationException .class ,
385+ () -> d .distance (new float [1 ], new float [1 ])
386+ );
387+ thrown = assertThrows (
388+ UnsupportedOperationException .class ,
389+ () -> d .distance (new boolean [1 ], new boolean [1 ])
390+ );
391+ thrown = assertThrows (
392+ UnsupportedOperationException .class ,
393+ () -> d .distance (new char [1 ], new char [1 ])
394+ );
395+ thrown = assertThrows (
396+ UnsupportedOperationException .class ,
397+ () -> d .distance (new String [1 ], new String [1 ])
398+ );
399+ thrown = assertThrows (
400+ UnsupportedOperationException .class ,
401+ () -> d .distance (new ArrayList <String >(), new ArrayList <String >())
402+ );
403+ thrown = assertThrows (
404+ UnsupportedOperationException .class ,
405+ () -> d .distance ("a" , "a" )
406+ );
407+
408+ IllegalArgumentException illegal = assertThrows (
409+ IllegalArgumentException .class ,
410+ () -> new EditDistance (-1 , 0 , 0 )
411+ );
412+ illegal = assertThrows (
413+ IllegalArgumentException .class ,
414+ () -> new EditDistance (0 , -1 , 0 )
415+ );
416+ illegal = assertThrows (
417+ IllegalArgumentException .class ,
418+ () -> new EditDistance (0 , 0 , -1 )
419+ );
420+ illegal = assertThrows (
421+ IllegalArgumentException .class ,
422+ () -> new EditDistance (-0.01 , 0 , 0 )
423+ );
424+ illegal = assertThrows (
425+ IllegalArgumentException .class ,
426+ () -> new EditDistance (0 , -0.01 , 0 )
427+ );
428+ illegal = assertThrows (
429+ IllegalArgumentException .class ,
430+ () -> new EditDistance (0 , 0 , -0.01 )
431+ );
432+ }
433+
360434 @ Test
361435 public void testEditDistance () {
362436 EditDistance d = new EditDistance (1 , 2 , 10 );
@@ -574,6 +648,12 @@ public void testEditDistance() {
574648 assertEquals (45 , d .distance (b1 ,b2 ));
575649 assertEquals (45.0 , d .distancef (b1 ,b2 ), EPSILON );
576650 }
651+ EditDistance dist1 = new EditDistance (1.1 , 2.0 , 2.0 );
652+ EditDistance dist2 = new EditDistance (2.0 , 1.1 , 2.0 );
653+ EditDistance dist3 = new EditDistance (2.0 , 2.0 , 1.1 );
654+ assertEquals (1.1 , dist1 .distancef ("a" , "ab" ), EPSILON );
655+ assertEquals (1.1 , dist2 .distancef ("ab" , "a" ), EPSILON );
656+ assertEquals (1.1 , dist3 .distancef ("a" , "b" ), EPSILON );
577657 }
578658
579659 @ Test
0 commit comments