package nl.jteam.encoding.examples; 
 
/** 
 * @author Jelmer Kuperus 
 */ 
public class ExampleTest extends AbstractEncodingTestCase { 
 
    public void testEncodeJava() throws Exception { 
        assertEquals(asByteArray(74, 97, 118, 97), "Java".getBytes("US-ASCII")); 
    } 
 
    public void testEncodeResume() throws Exception { 
        assertEquals("My rגsumג", new String("My résumé".getBytes("IBM850"), "IBM862")); 
    } 
 
    public void testEndians() throws Exception { 
        byte[] bigEndianBytes =    asByteArray(254, 255, 0, 74, 0, 97, 0, 118, 0, 97); 
        byte[] littleEndianBytes = asByteArray(255, 254, 74, 0, 97, 0, 118, 0, 97, 0); 
        assertEquals("Java", new String(bigEndianBytes, "UTF-16")); 
        assertEquals("Java", new String(littleEndianBytes, "UTF-16")); 
    } 
 
    public void testCompareByteSizes() throws Exception { 
        String text = "My résumé"; 
        // 2 bytes for the byte order mark and and two bytes for every letter 
        assertEquals(20,  text.getBytes("UTF-16").length); 
        // 1 byte for every ASCII character, 2 bytes for every non ASCII character (eg. the é) 
        assertEquals(11, text.getBytes("UTF-8").length); 
        // 1 byte for every character 
        assertEquals(9, text.getBytes("ISO-8859-1").length); 
    } 
 
 
 
}