BAEL-865 - updated example code (#2029)

* added project files for evaluation article by smatt382@gmail.com

* added project files for evaluation article by smatt382@gmail.com

* added class com.baeldung.string.StringToCharStream by smatt382@gmail.com

* updated the example codes. Use assert statements

* updated example codes

* fixed conflict in pom.xml

* remove redundant files'

* added unit test
This commit is contained in:
Seun Matt
2017-06-09 13:32:20 +01:00
committed by Zeger Hendrikse
parent f18c993d71
commit 920167f5b7
11 changed files with 609 additions and 360 deletions

View File

@@ -0,0 +1,36 @@
package com.baeldung.string;
import org.junit.Test;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Created by smatt on 09/06/2017.
*/
public class StringToCharStreamUnitTest {
String testString = "Tests";
@Test
public void givenTestString_whenChars_thenReturnIntStream() {
assertTrue(testString.chars() instanceof IntStream);
}
@Test
public void givenTestString_whenCodePoints_thenReturnIntStream() {
assertTrue(testString.codePoints() instanceof IntStream);
}
@Test
public void givenIntStream_whenMapToObj_thenReturnCharacterStream() {
Stream<Character> characterStream = testString.chars().mapToObj(c -> (char) c);
Stream<Character> characterStream1 = testString.codePoints().mapToObj(c -> (char) c);
assertNotNull("IntStream returned by chars() did not map to Stream<Character>", characterStream);
assertNotNull("IntStream returned by codePoints() did not map to Stream<Character>", characterStream1);
}
}