java-tutorials/java-strings/src/test/java/com/baeldung/string/ReplaceCharInStringUnitTest.java
Shashank agarwal 547f99925f Added the code of Replace char in a string at specific index (#5869)
* Added the code of Replace char in a string at specific index

* added test cases

* Renamed the Test class name end with UnitTest

* Renamed the Test class name end with UnitTest

* Renamed the Test class name end with UnitTest

* Replaced README with the upstream repo
2018-12-19 22:49:27 -06:00

24 lines
746 B
Java

package com.baeldung.string;
import org.junit.Test;
import static org.junit.Assert.*;
public class ReplaceCharInStringUnitTest {
private ReplaceCharacterInString characterInString = new ReplaceCharacterInString();
@Test
public void whenReplaceCharAtIndexUsingSubstring_thenSuccess(){
assertEquals("abcme",characterInString.replaceCharSubstring("abcde",'m',3));
}
@Test
public void whenReplaceCharAtIndexUsingStringBuilder_thenSuccess(){
assertEquals("abcme",characterInString.replaceCharStringBuilder("abcde",'m',3));
}
@Test
public void whenReplaceCharAtIndexUsingStringBuffer_thenSuccess(){
assertEquals("abcme",characterInString.replaceCharStringBuffer("abcde",'m',3));
}
}