Skip to content

Commit b6bb1e1

Browse files
author
Stephen Braimah
committed
added to test class for string to char array char array to string conversion
1 parent 4018d45 commit b6bb1e1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.baeldung.java.conversion;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertArrayEquals;
6+
import static org.junit.Assert.assertEquals;
7+
8+
public class StringCharArrayConversionTest {
9+
10+
@Test
11+
public void stringToCharArray() throws Exception {
12+
String beforeConvCharArr = "Text";
13+
char[] afterConvCharArr = {'T','e','x','t'};
14+
15+
assertArrayEquals(beforeConvCharArr.toCharArray(),afterConvCharArr);
16+
}
17+
18+
@Test
19+
public void charArrayToString() throws Exception {
20+
char[] beforeConvStr = {'T','e','x','t'};
21+
String afterConvStr = "Text";
22+
23+
assertEquals(String.valueOf(beforeConvStr),afterConvStr);
24+
}
25+
}

0 commit comments

Comments
 (0)