added to test class for string to char array char array to string conversion

This commit is contained in:
Stephen Braimah 2017-01-03 09:02:30 +00:00
parent 4018d45a2c
commit b6bb1e18d4
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.baeldung.java.conversion;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
public class StringCharArrayConversionTest {
@Test
public void stringToCharArray() throws Exception {
String beforeConvCharArr = "Text";
char[] afterConvCharArr = {'T','e','x','t'};
assertArrayEquals(beforeConvCharArr.toCharArray(),afterConvCharArr);
}
@Test
public void charArrayToString() throws Exception {
char[] beforeConvStr = {'T','e','x','t'};
String afterConvStr = "Text";
assertEquals(String.valueOf(beforeConvStr),afterConvStr);
}
}