Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. package AAAufgabe18;
  2. import static org.junit.Assert.*;
  3. import java.io.*;
  4. import org.junit.Test;
  5.  
  6. public class ToUpperCaseWriterTest
  7. {
  8. public void writeCharTest(char c1, String c2)
  9. {
  10. try(ByteArrayOutputStream baos = new ByteArrayOutputStream();
  11. OutputStreamWriter osw = new OutputStreamWriter(baos);
  12. ToUpperCaseWriter writer = new ToUpperCaseWriter(osw);)
  13. {
  14. writer.write(c1);
  15. writer.flush();
  16. String uppercase = baos.toString();
  17. assertEquals(c2, uppercase);
  18. }
  19. catch (IOException e)
  20. {
  21. fail("IOException" + e.getMessage());
  22. }
  23. }
  24.  
  25. @Test
  26. public void TestA()
  27. {
  28. writeCharTest('a',"A");
  29. }
  30. @Test
  31. public void Test1()
  32. {
  33. writeCharTest('1',"1");
  34. }
  35. @Test
  36. public void TestAscii()
  37. {
  38. char [] ascii = new char [128];
  39. for(int i = 0; i<128; i++)
  40. {
  41. ascii[i] = (char) i;
  42. }
  43.  
  44. for(int i = 0; i<128; i++)
  45. {
  46.  
  47. String s = Character.toString(ascii[i]);
  48.  
  49. if (i < 97 && i > 122) writeCharTest(ascii[i], s);
  50. else
  51. {
  52. char temp = Character.toUpperCase(ascii[i]);
  53. String ss = Character.toString(temp);
  54. writeCharTest(ascii[i], ss);
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement