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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 java.nio.charset.Charset;
  9. import junit.framework.TestCase;
  10. import org.junit.After;
  11. import org.junit.AfterClass;
  12. import org.junit.Before;
  13. import org.junit.BeforeClass;
  14. import org.junit.Test;
  15. import static org.junit.Assert.*;
  16. /**
  17. *
  18. * @author Chris
  19. */
  20. public class StringTranscoderTest extends TestCase {
  21. public StringTranscoderTest() {
  22. }
  23. @BeforeClass
  24. public static void setUpClass() throws Exception {
  25. }
  26. @AfterClass
  27. public static void tearDownClass() throws Exception {
  28. }
  29. @Before
  30. public void setUp() throws Exception {
  31. }
  32. @After
  33. public void tearDown() throws Exception {
  34. }
  35. @Test
  36. public void testTranscode() {
  37. String string = new String(new byte[]{(byte) 0xCA, (byte) 0xAE});
  38. StringTranscoder instance = new StringTranscoder(Charset.forName("UTF-8"));
  39. String res = instance.encode(string);
  40. byte[] result = res.getBytes();
  41. assertEquals(string, instance.decode(new String(result)));
  42. }
  43. }