Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package AAAufgabe18;
- import static org.junit.Assert.*;
- import java.io.*;
- import org.junit.Test;
- public class ToUpperCaseWriterTest
- {
- public void writeCharTest(char c1, String c2)
- {
- try(ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OutputStreamWriter osw = new OutputStreamWriter(baos);
- ToUpperCaseWriter writer = new ToUpperCaseWriter(osw);)
- {
- writer.write(c1);
- writer.flush();
- String uppercase = baos.toString();
- assertEquals(c2, uppercase);
- }
- catch (IOException e)
- {
- fail("IOException" + e.getMessage());
- }
- }
- @Test
- public void TestA()
- {
- writeCharTest('a',"A");
- }
- @Test
- public void Test1()
- {
- writeCharTest('1',"1");
- }
- @Test
- public void TestAscii()
- {
- char [] ascii = new char [128];
- for(int i = 0; i<128; i++)
- {
- ascii[i] = (char) i;
- }
- for(int i = 0; i<128; i++)
- {
- String s = Character.toString(ascii[i]);
- if (i < 97 && i > 122) writeCharTest(ascii[i], s);
- else
- {
- char temp = Character.toUpperCase(ascii[i]);
- String ss = Character.toString(temp);
- writeCharTest(ascii[i], ss);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement