Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class LZWWriterTest {
  2.  
  3. @Test
  4. public void Test() throws IOException {
  5.  
  6. char[] cbufOut = { 'T', 'O', 'B', 'E', 'O', 'R', 'N', 'O', 'T', 'T',
  7. 'O', 'B', 'E', 'O', 'R', 'T', 'O', 'B', 'E', 'O', 'R', 'N',
  8. 'O', 'T' };
  9. char[] cbufIn = new char[24];
  10. byte[] bytes = new byte[1024];
  11.  
  12. OutputStream out = new ByteArrayOutputStream();
  13. InputStream in = new ByteArrayInputStream(bytes);
  14.  
  15. LZWWriter lzwwriter = new LZWWriter(out);
  16. LZWReader lzwreader = new LZWReader(in);
  17.  
  18. lzwwriter.write(cbufOut, 0, 24);
  19. lzwwriter.close();
  20.  
  21. lzwreader.read(cbufIn, 0, 24);
  22. lzwreader.close();
  23.  
  24. for (int i = 0; i < 256; i++) {
  25. System.out.println(lzwwriter.getDictionary().get("" + (char) i));
  26. }
  27.  
  28. assertEquals("Strings didnt match", cbufOut, cbufIn);
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement