Junits
parent
67fda3e35c
commit
f9e4108705
|
@ -6,5 +6,6 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package inputOutput;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import org.junit.Test;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
|
public class ConsoleTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadString() {
|
||||||
|
String input = "Test String";
|
||||||
|
System.setIn(new ByteArrayInputStream(input.getBytes()));
|
||||||
|
assertEquals(input, Console.readString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadCharArray() {
|
||||||
|
String input = "Test Char Array";
|
||||||
|
System.setIn(new ByteArrayInputStream(input.getBytes()));
|
||||||
|
char[] expected = input.toCharArray();
|
||||||
|
assertArrayEquals(expected, Console.readCharArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadBooleanTrue() {
|
||||||
|
String input = "true";
|
||||||
|
System.setIn(new ByteArrayInputStream(input.getBytes()));
|
||||||
|
assertTrue(Console.readBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadBooleanFalse() {
|
||||||
|
String input = "false";
|
||||||
|
System.setIn(new ByteArrayInputStream(input.getBytes()));
|
||||||
|
assertFalse(Console.readBoolean());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue