You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StringTranscoderTest.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * StringTranscoderTest.java
  3. * JUnit 4.x based test
  4. *
  5. * Created on 07 August 2007, 15:10
  6. */
  7. package com.dmdirc;
  8. import com.dmdirc.util.StringTranscoder;
  9. import java.nio.charset.Charset;
  10. import junit.framework.TestCase;
  11. import org.junit.After;
  12. import org.junit.AfterClass;
  13. import org.junit.Before;
  14. import org.junit.BeforeClass;
  15. import org.junit.Test;
  16. import static org.junit.Assert.*;
  17. /**
  18. *
  19. * @author Chris
  20. */
  21. public class StringTranscoderTest extends TestCase {
  22. public StringTranscoderTest() {
  23. }
  24. @BeforeClass
  25. public static void setUpClass() throws Exception {
  26. }
  27. @AfterClass
  28. public static void tearDownClass() throws Exception {
  29. }
  30. @Before
  31. public void setUp() throws Exception {
  32. }
  33. @After
  34. public void tearDown() throws Exception {
  35. }
  36. @Test
  37. public void testTranscode() {
  38. String string = new String(new byte[]{(byte) 0xCA, (byte) 0xAE});
  39. StringTranscoder instance = new StringTranscoder(Charset.forName("UTF-8"));
  40. String res = instance.encode(string);
  41. byte[] result = res.getBytes();
  42. assertEquals(string, instance.decode(new String(result)));
  43. }
  44. }