12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import java.io.ByteArrayInputStream;
-
- /**
- * The test class ConsoleTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class ConsoleTest
- {
-
- @Test
- public void testInputDouble(){
- ByteArrayInputStream in = new ByteArrayInputStream ("7".getBytes());
- System.setIn(in);
-
- assertEquals(Double.valueOf("7"),Console.inputDouble(),.000000001);
- }
-
- @Test
- public void testInputInt(){
- ByteArrayInputStream in = new ByteArrayInputStream ("7".getBytes());
- System.setIn(in);
-
- assertEquals(7,Console.inputInt());
- }
-
- @Test
- public void testInputString(){
- ByteArrayInputStream in = new ByteArrayInputStream ("7".getBytes());
- System.setIn(in);
-
- assertEquals("7",Console.inputString());
-
- }
-
- @Test
- public void testGetOperator(){
- ByteArrayInputStream in = new ByteArrayInputStream ("a".getBytes());
- System.setIn(in);
-
- assertEquals('a',Console.getOperator());
- }
-
- @Test
- public void TestInputAddMethod()
- {
- assertEquals(5, Console.inputString());
- }
- }
|