package strings;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static strings.ReplaceAndRemove.replaceAndRemove;

class ReplaceAndRemoveTest {

    private String expected;
    private String input;
    private int k;

    @Test
    void replaceAndRemove1() {
        expected = "dd";
        input = "a ";
        k=1;

        test(expected, input, k);
    }

    @Test
    void replaceAndRemove2() {
        expected = " ";
        input = "b";
        k=1;

        test(expected, input, k);
    }

    @Test
    void replaceAndRemove3() {
        expected = "dd";
        input = "ab";
        k=2;

        test(expected, input, k);
    }

    @Test
    void replaceAndRemove4() {
        expected = "ddddc";
        input = "abac ";
        k=4;

        test(expected, input, k);
    }

    @Test
    void replaceAndRemove5() {
        expected = "ddcdcdd";
        input = "acdbbca";
        k=7;

        test(expected, input, k);
    }

    private void test(String expected, String input, int k) {
        assertEquals(expected, replaceAndRemove(input.toCharArray(), k));
    }
}
@@ -448,149 +448,8 @@
 ) %7B%0A
-        expected = %22 %22;%0A        input = %22b%22;%0A        k=1;%0A%0A        test(expected, input, k);%0A    %7D%0A%0A    @Test%0A    void replaceAndRemove3() %7B%0A
     
@@ -461,32 +461,32 @@
 xpected = %22dd%22;%0A
+
         input = 
@@ -581,17 +581,17 @@
 ndRemove
-4
+3
 () %7B%0A   
@@ -734,9 +734,9 @@
 move
-5
+4
 () %7B

Test case with mismatch and array size removed