Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96d29fd8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added test for max distance on editDistance()." into qt-dev

parents 332d34e3 c7be4205
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ final class EditDistanceScorer {
     *     the edit distance is at least as big as the {@code max} parameter
     */
    // Note: copied verbatim from com.android.tools.lint.detector.api.LintUtils.java
    private static int editDistance(@NonNull String s, @NonNull String t, int max) {
    public static int editDistance(@NonNull String s, @NonNull String t, int max) {
        if (s.equals(t)) {
            return 0;
        }
+6 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.ext.services.autofill;

import static android.ext.services.autofill.EditDistanceScorer.calculateScore;
import static android.ext.services.autofill.EditDistanceScorer.editDistance;

import static com.google.common.truth.Truth.assertThat;

@@ -73,9 +74,12 @@ public class EditDistanceScorerTest {
        assertFloat(calculateScore(AutofillValue.forText("DUDx"), "Dude"), 0.75F);
    }

    @Test
    public void testEditDistance_maxDistance() {
        assertFloat(editDistance("testing", "b", 4), Integer.MAX_VALUE);
    }

    public static void assertFloat(float actualValue, float expectedValue) {
        assertThat(actualValue).isWithin(0.01F).of(expectedValue);
    }


}