/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.text;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
import static net.ranides.assira.junit.NewAssert.*;
import org.junit.Test;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class MazoviaCharsetTest {

    @Test
    public void testConstruct() {
        assertNotNull(Charset.forName("mazovia"));
        assertNotNull(Charset.forName("CP896"));
        assertThrows(UnsupportedCharsetException.class, ()-> {
            Charset.forName("mazovia.unknown.cs");
        });
    }
    
    @Test
    public void testEncode() {
        String text = "Źrebię na łące biega gdy świeci słońce.";
        ByteBuffer buf = Charset.forName("mazovia").encode(text);
        String str = Charset.forName("mazovia").decode(buf).toString();
        
        assertEquals("A0 72 65 62 69 91 20 6E 61 20 92 86 63 65 20 62 69 65 67 61 20 67 64 79 20 9E 77 69 65 63 69 20 73 92 6F A4 63 65 2E", FormatHex.format(buf.array()));
        assertEquals(text, str);
    }
    
}
